Permalink
Browse files

more tests for nested warden

  • Loading branch information...
1 parent bb37857 commit b06c3439792c1dc430d5ca7cea5be105f10d0dce Gary Liu committed Sep 5, 2013
Showing with 17 additions and 27 deletions.
  1. +1 −1 warden/spec/assets/config/child-linux.yml
  2. +16 −26 warden/spec/container/linux_nested_spec.rb
@@ -13,7 +13,7 @@ server:
# The grace time can be disabled by setting it to nil:
# container_grace_time: ~
#
- container_grace_time: 5
+ container_grace_time: 30
unix_domain_permissions: 0777
@@ -67,7 +67,7 @@
execute("#{clear} #{container_depot_path} > /dev/null")
end
- #execute("rmdir #{container_depot_path}")
+ execute("rm -rf #{container_depot_path}")
end
@@ -77,19 +77,6 @@ def execute(command)
end
end
- def unmount_depot(tries = 100)
- out = execute("umount #{container_depot_path} 2>&1")
- raise "Failed unmounting #{container_depot_path}: #{out}" unless $?.success?
- rescue
- tries -= 1
- if tries > 0
- raise
- else
- sleep 0.01
- retry
- end
- end
-
def create_client
client = ::Warden::Client.new(unix_domain_path)
client.connect
@@ -154,7 +141,6 @@ def run_as_root(script)
response = client.run(:handle => handle, :script => script, :privileged => true)
puts response.stdout, response.stderr unless response.exit_status == 0
response.exit_status.should == 0
-
end
def create
@@ -168,13 +154,14 @@ def create
warden_repo = File.expand_path('../../../..' ,__FILE__)
+ # whiteout rootfs/dev beforehand to avoid 'overlayfs: operation not permitted' error
+ `rm -rf /tmp/warden/rootfs/dev/*`
+
@bind_mount_warden = Warden::Protocol::CreateRequest::BindMount.new
@bind_mount_warden.src_path = File.join(warden_repo, 'warden')
@bind_mount_warden.dst_path = "/warden"
@bind_mount_warden.mode = Warden::Protocol::CreateRequest::BindMount::Mode::RO
- # whiteout rootfs/dev beforehand to avoid 'overlayfs: operation not permitted'
- `rm -rf /tmp/warden/rootfs/dev/*`
@bind_mount_rootfs = Warden::Protocol::CreateRequest::BindMount.new
@bind_mount_rootfs.src_path = "/tmp/warden/rootfs"
@bind_mount_rootfs.dst_path = "/tmp/warden/rootfs"
@@ -194,37 +181,40 @@ def create
run_as_root 'source /etc/profile.d/rvm.sh; cd /warden && bundle install --quiet'
run_as_root 'rm /tmp/warden.sock || true'
run_as_root 'source /etc/profile.d/rvm.sh; cd /warden && bundle exec rake warden:start[spec/assets/config/child-linux.yml] &'
- puts "GGGG warden server should be running, please check"
- sleep 5 #wait ward server start up
+
+ sleep 5 #wait warden server to start up
run_as_root 'ls /tmp/warden.sock'
end
after :all do
+ #destroy nested containers if there is any
+ run_as_root '/warden/root/linux/clear.sh /tmp/warden/containers > /dev/null'
+
+ #stop child warden server
run_as_root "ps -ef|grep [r]ake |awk '{print $2}'|xargs kill"
end
it 'should run nested containers' do
run_as_root 'source /etc/profile.d/rvm.sh; /warden/bin/warden -- create'
- sleep 10 # wait containers to die
end
it 'should setup nested cgroup' do
run_as_root 'source /etc/profile.d/rvm.sh; /warden/bin/warden -- create'
- puts `/tmp/warden/cgroup/cpu/instance-#{handle}/instance-*`
Dir.glob("/tmp/warden/cgroup/cpu/instance-#{handle}/instance-*").should_not be_empty
- sleep 10 # wait containers to die
- sleep 60*10
-
- puts
end
- xit 'should allow inbond traffic to nested container' do
+ it 'should allow inbound traffic to nested containers' do
+
+ execute "route add -net 10.254.0.0/22 gw 10.244.0.2"
+ run_as_root 'source /etc/profile.d/rvm.sh; /warden/bin/warden -- create --network 10.254.0.126'
+ execute 'ping -c3 10.254.0.126'
+ execute "route del -net 10.254.0.0/22 gw 10.244.0.2"
end
end

0 comments on commit b06c343

Please sign in to comment.