def test_run_container_without_security_groups(self):
     gen_model = datagen.container_data()
     delattr(gen_model, 'security_groups')
     _, model = self._run_container(gen_model=gen_model)
     sgs = self._get_all_security_groups(model)
     self.assertEqual(1, len(sgs))
     self.assertEqual('default', sgs[0])
Exemple #2
0
    def _run_container(self, **kwargs):
        gen_model = datagen.container_data(**kwargs)
        resp, model = self.container_client.run_container(gen_model)
        self.assertEqual(202, resp.status)
        # Wait for container to started
        self.container_client.ensure_container_in_desired_state(
            model.uuid, 'Running')

        # Assert the container is started
        resp, model = self.container_client.get_container(model.uuid)
        self.assertEqual('Running', model.status)
        self.assertEqual('Running', self._get_container_state(model.uuid))
        return resp, model
    def _create_container(self, **kwargs):
        gen_model = datagen.container_data(**kwargs)
        resp, model = self.container_client.post_container(gen_model)
        self.assertEqual(202, resp.status)
        # Wait for container to finish creation
        self.container_client.ensure_container_in_desired_state(
            model.uuid, 'Created')

        # Assert the container is created
        resp, model = self.container_client.get_container(model.uuid)
        self.assertEqual(200, resp.status)
        self.assertEqual('Created', model.status)
        self.assertEqual('Created', self._get_container_state(model.uuid))
        return resp, model
Exemple #4
0
    def test_run_container_without_security_groups(self):
        gen_model = datagen.container_data()
        delattr(gen_model, 'security_groups')
        _, model = self._run_container(gen_model=gen_model)

        # find the neutron port of this container
        port_ids = set()
        for addrs_list in model.addresses.values():
            for addr in addrs_list:
                port_id = addr['port']
                port_ids.add(port_id)
        self.assertEqual(1, len(port_ids))
        # verify default security_group is applied
        port_id = port_ids.pop()
        port = self.ports_client.show_port(port_id)
        sg_ids = port['port']['security_groups']
        self.assertEqual(1, len(sg_ids))
        sg = self.sgs_client.show_security_group(sg_ids[0])
        self.assertEqual('default', sg['security_group']['name'])
 def test_run_container_with_minimal_params(self):
     gen_model = datagen.container_data({'image': 'nginx'})
     self._run_container(gen_model=gen_model)