Skip to content

Commit 5f87bde

Browse files
lsimonswilderrodrigues
authored andcommitted
Set up rsync for systemvm patches.
Note the convenience of 'vagrant rsync-auto'.
1 parent 6ffb063 commit 5f87bde

2 files changed

Lines changed: 50 additions & 9 deletions

File tree

test/systemvm/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,22 @@ class HelloSystemVMTestCase(SystemVMTestCase):
5454
def test_something(self):
5555
assert something_to_do('foo')
5656
```
57+
58+
Edit, test, edit, test
59+
======================
60+
The SystemVM Vagrantfile sets up rsync from systemvm/patches. These rsyncs run
61+
once, when you type 'vagrant up'. To do these rsyncs every time you change a
62+
patch file, run 'vagrant rsync-auto'. With that, your development process can
63+
be,
64+
65+
* once, start up vagrant with 'vagrant up'
66+
* once, start up the rsync watcher with 'vagrant rsync-auto'
67+
* iterate:
68+
* write a test, save the file
69+
* run 'nostests' to check that the test fails
70+
* change a systemvm script to help the test pass, save the file
71+
* vagrant rsyncs the changed file
72+
* run 'nosetests' to check that the test now passes
73+
74+
If you use PyDev or PyCharm you can set it up to watch your test files for
75+
changes and auto-run any changed tests.

tools/vagrant/systemvm/Vagrantfile

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# under the License.
2020

2121
include RbConfig
22+
basedir = File.dirname(__FILE__)
2223

2324
VAGRANTFILE_API_VERSION = '2'
2425

@@ -36,31 +37,31 @@ if ARGV[0] == 'up'
3637
puts 'Windows is not supported'
3738
exit 1
3839
when /linux|arch/i
39-
iso_util='mkisofs -J -o systemvm.iso ./iso'
40+
iso_util = "mkisofs -J -o #{basedir}/systemvm.iso #{basedir}/iso"
4041
when /sunos|solaris/i
4142
puts 'Solaris is not supported'
4243
exit 1
4344
when /darwin/i
44-
iso_util='hdiutil makehybrid -iso -joliet -o systemvm.iso ./iso/'
45+
iso_util = "hdiutil makehybrid -iso -joliet -o #{basedir}/systemvm.iso #{basedir}/iso/"
4546
else
4647
puts 'This OS is not supported'
4748
exit 1
4849
end
4950

50-
system 'rm -rf ./systemvm.iso'
51-
system 'mkdir -p iso/'
52-
unless File.exist? '../../../systemvm/dist/cloud-scripts.tgz'
51+
system "rm -rf #{basedir}/systemvm.iso"
52+
system "mkdir -p #{basedir}/iso/"
53+
unless File.exist? "#{basedir}/../../../systemvm/dist/cloud-scripts.tgz"
5354
puts 'No cloud-scripts.tgz found. Did you run the maven build?'
5455
exit 1
5556
end
56-
system 'cp ../../../systemvm/dist/cloud-scripts.tgz iso/'
57-
unless File.exist? '../../../systemvm/dist/systemvm.zip'
57+
system "cp #{basedir}/../../../systemvm/dist/cloud-scripts.tgz #{basedir}/iso/"
58+
unless File.exist? "#{basedir}/../../../systemvm/dist/systemvm.zip"
5859
puts 'No systemvm.zip found. Did you run the maven build?'
5960
exit 1
6061
end
61-
system 'cp ../../../systemvm/dist/systemvm.zip iso/'
62+
system "cp #{basedir}/../../../systemvm/dist/systemvm.zip #{basedir}/iso/"
6263

63-
system 'cp vagrant.pub iso/authorized_keys'
64+
system "cp #{basedir}/vagrant.pub #{basedir}/iso/authorized_keys"
6465
system 'chmod 600 iso/authorized_keys'
6566

6667
system iso_util
@@ -71,6 +72,27 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7172
config.vm.network 'private_network', ip: VPC_IP, auto_config: false
7273
config.vm.synced_folder 'vagrant', '/vagrant', disabled: true
7374

75+
#noinspection RubyStringKeysInHashInspection
76+
patches = {
77+
'config/etc' => '/etc',
78+
'config/opt' => '/opt',
79+
'config/root' => '/root',
80+
'config/var' => '/var',
81+
'vpn/etc' => '/etc',
82+
'vpn/opt' => '/opt',
83+
'xe' => '/usr/sbin'
84+
}
85+
86+
patches.each_pair do |patch, dest|
87+
config.vm.synced_folder(
88+
"#{basedir}/../../../systemvm/patches/debian/#{patch}",
89+
dest,
90+
type: 'rsync',
91+
rsync__chown: false,
92+
rsync__args: %w(--verbose --archive --exclude=authorized_keys) # no --delete!
93+
)
94+
end
95+
7496
config.ssh.forward_agent = true
7597
config.ssh.username = 'root'
7698
config.ssh.host = VPC_IP

0 commit comments

Comments
 (0)