コード例 #1
0
class JujuStateSinglePredeployTest(unittest.TestCase):
    "Read the 'juju status' yaml for single pre-deploy"

    def setUp(self):
        with open('test/juju-output/juju-status-single-pre-deploy.yaml') as f:
            self.juju = JujuState(f.read())

    def test_one_machine_allocated(self):
        ml = self.juju.machines_allocated()
        self.assertEqual(1, len(ml))

    def test_no_services(self):
        sl = list(self.juju.services)
        self.assertEqual(0, len(sl))

    def test_no_containers(self):
        m_one = self.juju.machines_allocated()[0]
        cl = list(m_one.containers)
        self.assertEqual(0, len(cl))
コード例 #2
0
class JujuStateSinglePredeployTest(unittest.TestCase):
    "Read the 'juju status' yaml for single pre-deploy"

    def setUp(self):
        with open('test/juju-output/juju-status-single-pre-deploy.yaml') as f:
            self.juju = JujuState(f.read())

    def test_one_machine_allocated(self):
        ml = self.juju.machines_allocated()
        self.assertEqual(1, len(ml))

    def test_no_services(self):
        sl = list(self.juju.services)
        self.assertEqual(0, len(sl))

    def test_no_containers(self):
        m_one = self.juju.machines_allocated()[0]
        cl = list(m_one.containers)
        self.assertEqual(0, len(cl))
コード例 #3
0
class JujuStateSingleTest(unittest.TestCase):
    "Read the 'juju status' yaml for single post-install"

    def setUp(self):
        with open('test/juju-output/juju-status-single-install.yaml') as f:
            self.juju = JujuState(f.read())

        self.m_one = self.juju.machine("1")
        self.c_one = self.m_one.container("1/lxc/0")

    def test_ignore_bootstrap_node(self):
        "jujustate.machines() should not include #0"
        self.assertEqual(len(list(self.juju.machines())), 2)

    def test_services(self):
        "All services parsed correctly"
        expected = [
            'glance', 'juju-gui', 'keystone', 'mysql', 'nova-cloud-controller',
            'nova-compute', 'openstack-dashboard', 'rabbitmq-server'
        ]
        actual = list(self.juju.services)
        actual_names = [s.service_name for s in actual]
        self.assertEqual(set(actual_names), set(expected))

    def test_find_service(self):
        "Find a service based on charm name"
        cn = "juju-gui"
        s = self.juju.service(cn)
        self.assertEqual(cn, s.service_name)

    def test_bogus_service_returns_none(self):
        "return empty dictionary for nonexistent services"
        cn = "fake-bogus-charm"
        s = self.juju.service(cn)
        self.assertEqual({}, s.service)

    def test_two_machines_allocated(self):
        ml = self.juju.machines_allocated()
        self.assertEqual(2, len(ml))

    def test_m_one_containers(self):
        cl = list(self.m_one.containers)
        self.assertEqual(7, len(cl))
        self.assertEqual(self.c_one.agent_state, "started")

    def test_get_hardware(self):
        cpu_cores = self.m_one.hardware("cpu-cores")
        self.assertEqual(cpu_cores, '3')
        self.assertEqual(self.c_one.hardware("arch"), "amd64")
コード例 #4
0
class JujuStateSingleTest(unittest.TestCase):
    "Read the 'juju status' yaml for single post-install"

    def setUp(self):
        with open('test/juju-output/juju-status-single-install.yaml') as f:
            self.juju = JujuState(f.read())

        self.m_one = self.juju.machine("1")
        self.c_one = self.m_one.container("1/lxc/0")

    def test_ignore_bootstrap_node(self):
        "jujustate.machines() should not include #0"
        self.assertEqual(len(list(self.juju.machines())), 2)

    def test_services(self):
        "All services parsed correctly"
        expected = ['glance', 'juju-gui', 'keystone', 'mysql',
                    'nova-cloud-controller', 'nova-compute',
                    'openstack-dashboard', 'rabbitmq-server']
        actual = list(self.juju.services)
        actual_names = [s.service_name for s in actual]
        self.assertEqual(set(actual_names), set(expected))

    def test_find_service(self):
        "Find a service based on charm name"
        cn = "juju-gui"
        s = self.juju.service(cn)
        self.assertEqual(cn, s.service_name)

    def test_bogus_service_returns_none(self):
        "return empty dictionary for nonexistent services"
        cn = "fake-bogus-charm"
        s = self.juju.service(cn)
        self.assertEqual({}, s.service)

    def test_two_machines_allocated(self):
        ml = self.juju.machines_allocated()
        self.assertEqual(2, len(ml))

    def test_m_one_containers(self):
        cl = list(self.m_one.containers)
        self.assertEqual(7, len(cl))
        self.assertEqual(self.c_one.agent_state, "started")

    def test_get_hardware(self):
        cpu_cores = self.m_one.hardware("cpu-cores")
        self.assertEqual(cpu_cores, '3')
        self.assertEqual(self.c_one.hardware("arch"), "amd64")