testlab 0.6.10 → 0.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
| 
         @@ -8,23 +8,29 @@ class TestLab 
     | 
|
| 
       8 
8 
     | 
    
         
             
                  # Renders the supplied content into a file on the container and proceeds
         
     | 
| 
       9 
9 
     | 
    
         
             
                  # to execute it on the container as root.
         
     | 
| 
       10 
10 
     | 
    
         
             
                  #
         
     | 
| 
      
 11 
     | 
    
         
            +
                  # On rare occasion it appears that the container will wipe '/tmp' after
         
     | 
| 
      
 12 
     | 
    
         
            +
                  # the bootstrap script is seeded but before it is executed via lxc-attach.
         
     | 
| 
      
 13 
     | 
    
         
            +
                  # This results in a 'No such file or directory' bash error when attempting
         
     | 
| 
      
 14 
     | 
    
         
            +
                  # to execute the script.  We allow 5 retries to seed the bootstrap script
         
     | 
| 
      
 15 
     | 
    
         
            +
                  # after which time the exception will be thrown and execution halted.
         
     | 
| 
      
 16 
     | 
    
         
            +
                  #
         
     | 
| 
       11 
17 
     | 
    
         
             
                  # @param [String] content The content to render on the container and
         
     | 
| 
       12 
18 
     | 
    
         
             
                  #   execute.  This is generally a bash script of some sort for example.
         
     | 
| 
       13 
19 
     | 
    
         
             
                  # @return [String] The output of *lxc-attach*.
         
     | 
| 
       14 
20 
     | 
    
         
             
                  def bootstrap(content)
         
     | 
| 
       15 
21 
     | 
    
         
             
                    output = nil
         
     | 
| 
       16 
22 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
                    ZTK::RescueRetry.try(:tries =>  
     | 
| 
      
 23 
     | 
    
         
            +
                    ZTK::RescueRetry.try(:tries => 5, :on => ContainerError) do
         
     | 
| 
       18 
24 
     | 
    
         
             
                      tempfile = Tempfile.new("bootstrap")
         
     | 
| 
       19 
     | 
    
         
            -
                      remote_tempfile = File.join("/tmp", File.basename(tempfile.path))
         
     | 
| 
       20 
     | 
    
         
            -
                       
     | 
| 
      
 25 
     | 
    
         
            +
                      remote_tempfile = File.join("/", "tmp", File.basename(tempfile.path))
         
     | 
| 
      
 26 
     | 
    
         
            +
                      target_tempfile = File.join(self.fs_root, remote_tempfile)
         
     | 
| 
       21 
27 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
                      self.node.ssh.file(:target =>  
     | 
| 
      
 28 
     | 
    
         
            +
                      self.node.ssh.file(:target => target_tempfile, :chmod => '0777', :chown => 'root:root') do |file|
         
     | 
| 
       23 
29 
     | 
    
         
             
                        file.puts(content)
         
     | 
| 
       24 
30 
     | 
    
         
             
                      end
         
     | 
| 
       25 
31 
     | 
    
         | 
| 
       26 
32 
     | 
    
         
             
                      output = self.lxc.attach(%(--), %(/bin/bash), remote_tempfile)
         
     | 
| 
       27 
     | 
    
         
            -
                      if output =~  
     | 
| 
      
 33 
     | 
    
         
            +
                      if !(output =~ /#{remote_tempfile}: No such file or directory/).nil?
         
     | 
| 
       28 
34 
     | 
    
         
             
                        raise ContainerError, "We could not find the bootstrap file!"
         
     | 
| 
       29 
35 
     | 
    
         
             
                      end
         
     | 
| 
       30 
36 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -42,7 +42,7 @@ class TestLab 
     | 
|
| 
       42 
42 
     | 
    
         
             
                      }
         
     | 
| 
       43 
43 
     | 
    
         
             
                    }
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
       45 
     | 
    
         
            -
                    apt_conf_d_proxy_file = File.join("/etc", "apt", "apt.conf.d", "00proxy")
         
     | 
| 
      
 45 
     | 
    
         
            +
                    apt_conf_d_proxy_file = File.join("/", "etc", "apt", "apt.conf.d", "00proxy")
         
     | 
| 
       46 
46 
     | 
    
         
             
                    node.ssh.file(:target => apt_conf_d_proxy_file, :chown => "root:root", :chmod => "0644") do |file|
         
     | 
| 
       47 
47 
     | 
    
         
             
                      file.puts(ZTK::Template.render(@apt_conf_d_proxy_file_template, context))
         
     | 
| 
       48 
48 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -60,17 +60,17 @@ class TestLab 
     | 
|
| 
       60 
60 
     | 
    
         | 
| 
       61 
61 
     | 
    
         
             
                    # Ensure the container APT calls use apt-cacher-ng on the node
         
     | 
| 
       62 
62 
     | 
    
         
             
                    gateway_ip                     = container.primary_interface.network.ip
         
     | 
| 
       63 
     | 
    
         
            -
                    apt_conf_d_proxy_file          = File.join( 
     | 
| 
      
 63 
     | 
    
         
            +
                    apt_conf_d_proxy_file          = File.join("/", "etc", "apt", "apt.conf.d", "00proxy")
         
     | 
| 
       64 
64 
     | 
    
         | 
| 
       65 
65 
     | 
    
         
             
                    @config[:apt][:cacher_ng] = { :proxy_url => "http://#{gateway_ip}:3142" }.merge(@config[:apt][:cacher_ng])
         
     | 
| 
       66 
66 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
                    container. 
     | 
| 
      
 67 
     | 
    
         
            +
                    container.ssh.file(:target => apt_conf_d_proxy_file, :chown => "root:root", :chmod => "0644") do |file|
         
     | 
| 
       68 
68 
     | 
    
         
             
                      file.puts(ZTK::Template.render(@apt_conf_d_proxy_file_template, @config))
         
     | 
| 
       69 
69 
     | 
    
         
             
                    end
         
     | 
| 
       70 
70 
     | 
    
         | 
| 
       71 
71 
     | 
    
         
             
                    # Fix the APT sources since LXC mudges them when using apt-cacher-ng
         
     | 
| 
       72 
     | 
    
         
            -
                    apt_conf_sources_file = File.join( 
     | 
| 
       73 
     | 
    
         
            -
                    container. 
     | 
| 
      
 72 
     | 
    
         
            +
                    apt_conf_sources_file = File.join("/", "etc", "apt", "sources.list")
         
     | 
| 
      
 73 
     | 
    
         
            +
                    container.ssh.exec(%(sudo sed -i 's/127.0.0.1:3142\\///g' #{apt_conf_sources_file}))
         
     | 
| 
       74 
74 
     | 
    
         
             
                  end
         
     | 
| 
       75 
75 
     | 
    
         | 
| 
       76 
76 
     | 
    
         
             
                end
         
     | 
    
        data/lib/testlab/version.rb
    CHANGED
    
    
| 
         @@ -41,16 +41,24 @@ describe TestLab::Provisioner::Shell do 
     | 
|
| 
       41 
41 
     | 
    
         
             
                  context "bootstrap successful" do
         
     | 
| 
       42 
42 
     | 
    
         
             
                    it "should provision the container" do
         
     | 
| 
       43 
43 
     | 
    
         
             
                      subject.node.ssh.stub(:file).and_yield(StringIO.new)
         
     | 
| 
      
 44 
     | 
    
         
            +
                      subject.stub(:fs_root) { "/var/lib/lxc/#{subject.id}/rootfs" }
         
     | 
| 
       44 
45 
     | 
    
         
             
                      subject.lxc.stub(:attach) { "" }
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                      p = TestLab::Provisioner::Shell.new(subject.config, @ui)
         
     | 
| 
      
 48 
     | 
    
         
            +
                      p.on_container_setup(subject)
         
     | 
| 
       46 
49 
     | 
    
         
             
                    end
         
     | 
| 
       47 
50 
     | 
    
         
             
                  end
         
     | 
| 
       48 
51 
     | 
    
         | 
| 
       49 
52 
     | 
    
         
             
                  context "bootstrap fails" do
         
     | 
| 
       50 
53 
     | 
    
         
             
                    it "should raise an exception" do
         
     | 
| 
       51 
54 
     | 
    
         
             
                      subject.node.ssh.stub(:file).and_yield(StringIO.new)
         
     | 
| 
       52 
     | 
    
         
            -
                      subject. 
     | 
| 
       53 
     | 
    
         
            -
                       
     | 
| 
      
 55 
     | 
    
         
            +
                      subject.stub(:fs_root) { "/var/lib/lxc/#{subject.id}/rootfs" }
         
     | 
| 
      
 56 
     | 
    
         
            +
                      subject.lxc.stub(:attach) do |arg0, arg1, arg2|
         
     | 
| 
      
 57 
     | 
    
         
            +
                        "#{arg2}: No such file or directory"
         
     | 
| 
      
 58 
     | 
    
         
            +
                      end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                      p = TestLab::Provisioner::Shell.new(subject.config, @ui)
         
     | 
| 
      
 61 
     | 
    
         
            +
                      lambda{ p.on_container_setup(subject) }.should raise_error TestLab::ContainerError
         
     | 
| 
       54 
62 
     | 
    
         
             
                    end
         
     | 
| 
       55 
63 
     | 
    
         
             
                  end
         
     | 
| 
       56 
64 
     | 
    
         
             
                end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: testlab
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.6. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.6.11
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2013-06- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2013-06-19 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: gli
         
     | 
| 
         @@ -300,7 +300,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       300 
300 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       301 
301 
     | 
    
         
             
                  segments:
         
     | 
| 
       302 
302 
     | 
    
         
             
                  - 0
         
     | 
| 
       303 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 303 
     | 
    
         
            +
                  hash: -168179665040294334
         
     | 
| 
       304 
304 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       305 
305 
     | 
    
         
             
              none: false
         
     | 
| 
       306 
306 
     | 
    
         
             
              requirements:
         
     | 
| 
         @@ -309,7 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       309 
309 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       310 
310 
     | 
    
         
             
                  segments:
         
     | 
| 
       311 
311 
     | 
    
         
             
                  - 0
         
     | 
| 
       312 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 312 
     | 
    
         
            +
                  hash: -168179665040294334
         
     | 
| 
       313 
313 
     | 
    
         
             
            requirements: []
         
     | 
| 
       314 
314 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       315 
315 
     | 
    
         
             
            rubygems_version: 1.8.25
         
     |