Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
test_container: make container names unique
Browse files Browse the repository at this point in the history
Locally, tests very often fail and until now, I wasn't sure why. It
turns out that when I make container names from the tests unique, tests
don't fail locally anymore. Therefore, I'm guessing that it will make
our tests less flaky.
  • Loading branch information
Virgil Dupras committed Mar 30, 2017
1 parent e936511 commit 2eda9ea
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/integration/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def dummy_action(self):
class TestContainer(LXDTestCase):
def test_can_set_up_a_container_that_does_not_exist(self):
container_options = {
'name': self.containername('dummy'), 'image': 'ubuntu/xenial', 'mode': 'pull', }
'name': self.containername('newcontainer'), 'image': 'ubuntu/xenial', 'mode': 'pull', }
container = Container('myproject', THIS_DIR, self.client, **container_options)
container.up()
assert container._container.status_code == constants.CONTAINER_RUNNING
Expand All @@ -44,7 +44,7 @@ def test_can_set_up_a_container_that_exists_but_is_not_running(self, persistent_

def test_can_destroy_a_container_and_run_this_action_for_a_container_that_does_not_exist(self):
container_options = {
'name': self.containername('dummy'), 'image': 'ubuntu/xenial', 'mode': 'pull', }
'name': self.containername('doesnotexist'), 'image': 'ubuntu/xenial', 'mode': 'pull', }
container = Container('myproject', THIS_DIR, self.client, **container_options)
container.destroy()
assert not container.exists
Expand All @@ -64,7 +64,7 @@ def test_can_try_to_halt_a_container_that_is_already_stoppeds(self, persistent_c

def test_can_provision_a_container(self):
container_options = {
'name': self.containername('dummy'), 'image': 'ubuntu/xenial', 'mode': 'pull',
'name': self.containername('willprovision'), 'image': 'ubuntu/xenial', 'mode': 'pull',
'provisioning': [
{'type': 'ansible',
'playbook': os.path.join(THIS_DIR, 'fixtures/provision_with_ansible.yml'), }
Expand All @@ -85,7 +85,7 @@ def test_can_open_a_shell_for_the_root_user(self, mocked_call, persistent_contai
@unittest.mock.patch('subprocess.call')
def test_can_open_a_shell_for_a_specific_shelluser(self, mocked_call):
container_options = {
'name': self.containername('dummy'), 'image': 'ubuntu/xenial', 'mode': 'pull',
'name': self.containername('shellspecificuser'), 'image': 'ubuntu/xenial',
'shell': {'user': 'test', 'home': '/opt', },
}
container = Container('myproject', THIS_DIR, self.client, **container_options)
Expand Down

0 comments on commit 2eda9ea

Please sign in to comment.