예제 #1
0
 def test_if_build_from_and_latest(self):
     fake_context = FakeRunningContext()
     fake_service = FakeService()
     fake_service.image = "service:latest"
     fake_service.build_from = "the/service/dir"
     agent = ServiceAgent(fake_service, DEFAULT_OPTIONS, fake_context)
     agent.start_service()
     agent.join()
     assert len(self.docker._images_built) == 1
예제 #2
0
 def test_build_on_start(self):
     fake_context = FakeRunningContext()
     fake_service = FakeService()
     fake_service.build_from = "the/service/dir"
     options = attr.evolve(DEFAULT_OPTIONS, build=[fake_service.name])
     agent = ServiceAgent(fake_service, options, fake_context)
     agent.start_service()
     agent.join()
     assert len(self.docker._images_built) == 1
예제 #3
0
 def test_build_image_dockerfile(self):
     fake_service = FakeService(name='myservice')
     fake_service.dockerfile = 'Dockerfile.other'
     fake_service.build_from = "the/service/dir"
     agent = ServiceAgent(fake_service, DEFAULT_OPTIONS,
                          FakeRunningContext())
     agent.build_image()
     assert len(self.docker._images_built) == 1
     _, dockerfile, _ = self.docker._images_built[0]
     assert dockerfile == 'Dockerfile.other'
예제 #4
0
 def test_build_image(self, mock_datetime):
     now = datetime.now()
     mock_datetime.now.return_value = now
     fake_service = FakeService(name='myservice')
     fake_service.build_from = "the/service/dir"
     agent = ServiceAgent(fake_service, DEFAULT_OPTIONS,
                          FakeRunningContext())
     retval = agent.build_image()
     assert len(self.docker._images_built) == 1
     build_dir, dockerfile, image_tag = self.docker._images_built[0]
     assert build_dir == "/etc/the/service/dir"
     assert dockerfile == 'Dockerfile'
     assert image_tag == now.strftime("myservice-%Y-%m-%d-%H%M")
     assert retval == image_tag
     assert RunCondition.BUILD_IMAGE in agent.run_condition.actions