diff --git a/test/systemvm/README.md b/test/systemvm/README.md index b23eab65663..ad84037a958 100644 --- a/test/systemvm/README.md +++ b/test/systemvm/README.md @@ -54,3 +54,22 @@ class HelloSystemVMTestCase(SystemVMTestCase): def test_something(self): assert something_to_do('foo') ``` + +Edit, test, edit, test +====================== +The SystemVM Vagrantfile sets up rsync from systemvm/patches. These rsyncs run +once, when you type 'vagrant up'. To do these rsyncs every time you change a +patch file, run 'vagrant rsync-auto'. With that, your development process can +be, + +* once, start up vagrant with 'vagrant up' +* once, start up the rsync watcher with 'vagrant rsync-auto' +* iterate: + * write a test, save the file + * run 'nostests' to check that the test fails + * change a systemvm script to help the test pass, save the file + * vagrant rsyncs the changed file + * run 'nosetests' to check that the test now passes + +If you use PyDev or PyCharm you can set it up to watch your test files for +changes and auto-run any changed tests. diff --git a/tools/vagrant/systemvm/Vagrantfile b/tools/vagrant/systemvm/Vagrantfile index c5aa7aac4d9..03d9ad420e9 100644 --- a/tools/vagrant/systemvm/Vagrantfile +++ b/tools/vagrant/systemvm/Vagrantfile @@ -19,6 +19,7 @@ # under the License. include RbConfig +basedir = File.dirname(__FILE__) VAGRANTFILE_API_VERSION = '2' @@ -36,31 +37,31 @@ if ARGV[0] == 'up' puts 'Windows is not supported' exit 1 when /linux|arch/i - iso_util='mkisofs -J -o systemvm.iso ./iso' + iso_util = "mkisofs -J -o #{basedir}/systemvm.iso #{basedir}/iso" when /sunos|solaris/i puts 'Solaris is not supported' exit 1 when /darwin/i - iso_util='hdiutil makehybrid -iso -joliet -o systemvm.iso ./iso/' + iso_util = "hdiutil makehybrid -iso -joliet -o #{basedir}/systemvm.iso #{basedir}/iso/" else puts 'This OS is not supported' exit 1 end - system 'rm -rf ./systemvm.iso' - system 'mkdir -p iso/' - unless File.exist? '../../../systemvm/dist/cloud-scripts.tgz' + system "rm -rf #{basedir}/systemvm.iso" + system "mkdir -p #{basedir}/iso/" + unless File.exist? "#{basedir}/../../../systemvm/dist/cloud-scripts.tgz" puts 'No cloud-scripts.tgz found. Did you run the maven build?' exit 1 end - system 'cp ../../../systemvm/dist/cloud-scripts.tgz iso/' - unless File.exist? '../../../systemvm/dist/systemvm.zip' + system "cp #{basedir}/../../../systemvm/dist/cloud-scripts.tgz #{basedir}/iso/" + unless File.exist? "#{basedir}/../../../systemvm/dist/systemvm.zip" puts 'No systemvm.zip found. Did you run the maven build?' exit 1 end - system 'cp ../../../systemvm/dist/systemvm.zip iso/' + system "cp #{basedir}/../../../systemvm/dist/systemvm.zip #{basedir}/iso/" - system 'cp vagrant.pub iso/authorized_keys' + system "cp #{basedir}/vagrant.pub #{basedir}/iso/authorized_keys" system 'chmod 600 iso/authorized_keys' system iso_util @@ -71,6 +72,27 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.network 'private_network', ip: VPC_IP, auto_config: false config.vm.synced_folder 'vagrant', '/vagrant', disabled: true + #noinspection RubyStringKeysInHashInspection + patches = { + 'config/etc' => '/etc', + 'config/opt' => '/opt', + 'config/root' => '/root', + 'config/var' => '/var', + 'vpn/etc' => '/etc', + 'vpn/opt' => '/opt', + 'xe' => '/usr/sbin' + } + + patches.each_pair do |patch, dest| + config.vm.synced_folder( + "#{basedir}/../../../systemvm/patches/debian/#{patch}", + dest, + type: 'rsync', + rsync__chown: false, + rsync__args: %w(--verbose --archive --exclude=authorized_keys) # no --delete! + ) + end + config.ssh.forward_agent = true config.ssh.username = 'root' config.ssh.host = VPC_IP