~bac/lpsetup/lxc-integration

« back to all changes in this revision

Viewing changes to lpsetup/tests/integration/lxc.py

  • Committer: Brad Crittenden
  • Date: 2012-07-19 17:48:40 UTC
  • Revision ID: bac@canonical.com-20120719174840-ug3lkp29018pgwpt
RemovedĀ --code-dirĀ option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    repo = '~/launchpad-testing/lp-branches'
32
32
 
33
33
    def get_branch(self, dir='.'):
34
 
        branch,_ = Branch.open_containing(dir)
 
34
        branch, _ = Branch.open_containing(dir)
35
35
        return branch
36
36
 
37
37
    def get_push_location(self, branch=None):
39
39
            branch = self.get_branch()
40
40
        return branch.get_push_location()
41
41
 
42
 
 
43
42
    def check_environment(self):
44
43
        """Be sure the test environment doesn't exist."""
45
44
        # We want to be really sure we do not clobber an existing LXC
68
67
        except NotBranchError:
69
68
            raise RuntimeError(
70
69
                'The branch has never been pushed to Launchpad.')
71
 
        tree,_ = WorkingTree.open_containing_paths(None)
 
70
        tree, _ = WorkingTree.open_containing_paths(None)
72
71
        stream = StringIO()
73
72
        show_tree_status(tree, to_file=stream)
74
73
        if stream.getvalue():
86
85
        cmd = 'sudo python setup.py install'
87
86
        check_call(cmd.split())
88
87
 
89
 
 
90
88
    def do_test(self):
91
89
        """Run an end-to-end integration tests of the non-LXC lpsetup story."""
92
90
        super(LXCIntegrationTest, self).do_test()
94
92
            self.push_location, self.repo, LXC_NAME)
95
93
        check_call(cmd.split())
96
94
 
97
 
 
98
95
    def tear_down(self):
99
96
        super(LXCIntegrationTest, self).tear_down()
 
97
 
100
98
        def lxc_cmd(cmd_name):
101
99
            cmd = 'sudo {} -n {}'.format(cmd_name, LXC_NAME)
102
100
            check_call(cmd.split())
 
101
 
103
102
        try:
104
 
            if '--no-tear-down' not in self.args:
105
 
                lxc_cmd('lxc-stop')
106
 
                lxc_cmd('lxc-destroy')
 
103
            lxc_cmd('lxc-stop')
 
104
            lxc_cmd('lxc-destroy')
107
105
        except:
108
106
            pass
109
107