~ubuntu-branches/ubuntu/precise/juju/precise

« back to all changes in this revision

Viewing changes to juju/lib/lxc/tests/test_lxc.py

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-02-16 03:44:02 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120216034402-zi79nfc84vb0bj88
Tags: 0.5+bzr457-0ubuntu1
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
        self.addCleanup(self.clean_container, DEFAULT_CONTAINER)
70
70
 
71
71
        _lxc_create(DEFAULT_CONTAINER, config_file=self.config)
72
 
 
73
72
        _lxc_start(DEFAULT_CONTAINER)
74
73
        _lxc_stop(DEFAULT_CONTAINER)
75
74
 
84
83
    def test_lxc_container(self):
85
84
        self.addCleanup(self.clean_container, DEFAULT_CONTAINER)
86
85
        customize_log = self.makeFile()
87
 
        c = LXCContainer(
88
 
            DEFAULT_CONTAINER, "dsa...", "ppa", customize_log=customize_log)
89
 
 
 
86
        c = LXCContainer(DEFAULT_CONTAINER,
 
87
                         "dsa...",
 
88
                         "precise",
 
89
                         "ppa",
 
90
                         customize_log=customize_log)
90
91
        running = yield c.is_running()
91
92
        self.assertFalse(running)
92
93
        self.assertFalse(c.is_constructed())
 
94
 
93
95
        # verify we can't run a non-constructed container
94
96
        failure = c.run()
95
97
        yield self.assertFailure(failure, LXCError)
107
109
        output = _lxc_ls()
108
110
        self.assertIn(DEFAULT_CONTAINER, output)
109
111
 
110
 
        # verify we have a path into the container
 
112
        # Verify we have a path into the container
111
113
        self.assertTrue(os.path.exists(c.rootfs))
112
114
        self.assertTrue(c.is_constructed())
113
115
 
114
 
        self.verify_container(c, "dsa...", "ppa")
 
116
        self.verify_container(c, "dsa...", "precise", "ppa")
115
117
 
116
 
        # verify that we are in containers
 
118
        # Verify that we are in containers
117
119
        containers = yield get_containers(None)
118
120
        self.assertEqual(containers[DEFAULT_CONTAINER], True)
119
121
 
158
160
 
159
161
        master_container = LXCContainer(DEFAULT_CONTAINER,
160
162
                                        origin="ppa",
161
 
                                        public_key="dsa...")
 
163
                                        public_key="dsa...",
 
164
                                        series="oneiric")
162
165
 
163
166
        # verify that we cannot clone an unconstructed container
164
167
        failure = master_container.clone("test_lxc_fail")
182
185
        output = _lxc_ls()
183
186
        self.assertIn(DEFAULT_CONTAINER, output)
184
187
 
185
 
        self.verify_container(c, "dsa...", "ppa")
 
188
        self.verify_container(c, "dsa...", "oneiric", "ppa")
186
189
 
187
190
        # verify that we are in containers
188
191
        containers = yield get_containers(None)
202
205
 
203
206
        yield master_container.destroy()
204
207
 
205
 
    def verify_container(self, c, public_key, origin):
 
208
    def verify_container(self, c, public_key, series, origin):
206
209
        """Verify properties of an LXCContainer"""
207
210
 
208
211
        def p(path):
259
262
        self.assertIn('Acquire::http { Proxy "http://192.168.122.1:3142"; };',
260
263
                      apt_proxy)
261
264
 
 
265
        # Verify the container release series.
 
266
        with open(os.path.join(c.rootfs, "etc", "lsb-release")) as fh:
 
267
            lsb_info = fh.read()
 
268
        self.assertIn(series, lsb_info)
 
269
 
262
270
        # check basic juju installation
263
271
        # these could be more through
264
272
        if origin == "ppa":