Skip to content

Commit

Permalink
Fetch docker logs before to shutdown the services (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
fchauvel committed Nov 15, 2019
1 parent 022fa87 commit 6d52887
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
18 changes: 17 additions & 1 deletion camp/execute/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ def collecting_reports_for(self, configuration):
pass


def collecting_logs_for(self, configuration):
pass


def on_reading_report(self, report):
pass

Expand Down Expand Up @@ -233,6 +237,9 @@ def execute(self, configurations):
test_results.append(results)

finally:
self._listener.collecting_logs_for(each_path)
self._collect_logs_for(each_path)

self._listener.stopping_services_for(each_path)
self._stop_services(each_path)

Expand All @@ -252,7 +259,6 @@ def _start_services(self, path):
_START_SERVICES = "docker-compose up -d"



def _run_tests(self, path):

if self._component.test_settings.include_liveness_test:
Expand Down Expand Up @@ -350,6 +356,16 @@ def _parse_test_reports(self, path):



def _collect_logs_for(self, path):
self._shell.execute(self.FETCH_LOG_FILE, path, allow_failure=True)


FETCH_LOG_FILE = ("sh -c 'docker-compose logs "
"--no-color "
"--timestamps "
" > docker_run.log'")


def _stop_services(self, path):
self._shell.execute(self._STOP_SERVICES, path)

Expand Down
6 changes: 5 additions & 1 deletion camp/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ def collecting_reports_for(self, path):
self._print(" 4. Collecting reports ...")


def collecting_logs_for(self, path):
self._print(" 5. Collecting logs ...")


def stopping_services_for(self, path):
self._print(" 5. Stopping Services ...")
self._print(" 6. Stopping Services ...")


def on_shell_command(self, command, working_directory):
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/execute/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ def test_notify_listener(self):
expected_calls.append(call.starting_services_for(each))
expected_calls.append(call.running_tests_for(each))
expected_calls.append(call.collecting_reports_for(each))
expected_calls.append(call.collecting_logs_for(each))
expected_calls.append(call.stopping_services_for(each))

self._listener.assert_has_calls(expected_calls)
Expand Down Expand Up @@ -281,6 +282,14 @@ def test_fetch_test_reports(self):
self._verify(each_path, docker_cp)


def test_collect_logfiles_for_each_service(self):
self._call_execute()

for each_path, _ in self._configurations:
docker_logs = Engine.FETCH_LOG_FILE
self._verify(each_path, docker_logs)


def test_stop_services_for_all_configurations(self):
self._call_execute()

Expand Down

0 comments on commit 6d52887

Please sign in to comment.