From d0ac32eefd56a5648f278902916545f71cd04f41 Mon Sep 17 00:00:00 2001
From: Jakob Meng <code@jakobmeng.de>
Date: Thu, 3 Nov 2022 15:40:06 +0100
Subject: [PATCH] Refactored integration test of openstacksdk logging feature

Instead of asserting that openstacksdk created a logging file,
we read the contents of that log file now. The benefit is, that
this integration test gives users an idea how to actually use the
logging feature and also read the contents of the log file.

Change-Id: I9e3c75dda4c1c920937c9780fbdcbe3caeb4d6ad
---
 ci/roles/logging/tasks/main.yaml | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/ci/roles/logging/tasks/main.yaml b/ci/roles/logging/tasks/main.yaml
index 56263e9..d9c0e8d 100644
--- a/ci/roles/logging/tasks/main.yaml
+++ b/ci/roles/logging/tasks/main.yaml
@@ -1,20 +1,15 @@
 ---
-- name: Trigger flavor listing
+- name: Trigger flavor listing to create logs
   openstack.cloud.compute_flavor_info:
     cloud: "{{ cloud }}"
     sdk_log_path: "{{ sdk_log_file_path }}"
     sdk_log_level: "DEBUG"
 
-- name: Check log file presence
-  ansible.builtin.stat:
-    path: "{{ sdk_log_file_path }}"
-  register: sdk_log_file
+- name: Read openstacksdk's log file
+  ansible.builtin.slurp:
+    src: "{{ sdk_log_file_path }}"
+  register: log
 
-- name: Assert
-  ansible.builtin.assert:
-    that:
-      - "sdk_log_file.stat.exists"
-
-- name: Debug log file content
+- name: Print contents of openstacksdk's log
   ansible.builtin.debug:
-    msg: "{{ lookup('ansible.builtin.file', sdk_log_file_path) }}"
+    msg: "{{ log['content'] | b64decode }}"
-- 
GitLab