summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Angel Ajo <majopela@redhat.com>2018-10-11 12:22:34 +0200
committerMiguel Angel Ajo <mangelajo@redhat.com>2018-10-15 09:50:13 +0000
commit6b87af03cd779097f09a5dfc5f69afd0af1e75e7 (patch)
tree657aa85086cf831bd6f900458fe7c9da65af9d3d
parent222bb2a98478f8b3fc8786b8a69eefc873f94a55 (diff)
Add functional test for var log messages and enhance functional scriptHEADmaster
This test adds testing for var log messages format. In this commit we also enhance the functional.sh script to: 1) make sed usage more compatible with other systems (--expression -> -e) 2) Add color to output PASSED / FAILED 3) Generate template files for non existing outputs 4) Generate failed outputs for manual verification Change-Id: I1146b96fe9c91473c0127d0c47f890db1ddfb7b5
Notes
Notes (review): Code-Review+2: Daniel Alvarez <dalvarez@redhat.com> Workflow+1: Miguel Angel Ajo <mangelajo@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 15 Oct 2018 11:28:05 +0000 Reviewed-on: https://review.openstack.org/609659 Project: openstack/os-log-merger Branch: refs/heads/master
-rw-r--r--oslogmerger/tests/functional/data/02-var-log-messages/in/nova-api.log9
-rw-r--r--oslogmerger/tests/functional/data/02-var-log-messages/in/var_log_messages9
-rw-r--r--oslogmerger/tests/functional/data/02-var-log-messages/in/var_log_messages_ms9
-rw-r--r--oslogmerger/tests/functional/data/02-var-log-messages/out/mixed.log18
-rw-r--r--oslogmerger/tests/functional/data/02-var-log-messages/out/mixed_ms.log27
-rw-r--r--oslogmerger/tests/functional/functional.sh29
6 files changed, 97 insertions, 4 deletions
diff --git a/oslogmerger/tests/functional/data/02-var-log-messages/in/nova-api.log b/oslogmerger/tests/functional/data/02-var-log-messages/in/nova-api.log
new file mode 100644
index 0000000..9c52dcd
--- /dev/null
+++ b/oslogmerger/tests/functional/data/02-var-log-messages/in/nova-api.log
@@ -0,0 +1,9 @@
12018-10-11 08:00:49.397 16 INFO nova.api.openstack.requestlog [req-53208dc7-ecfa-4513-ab32-45dfbca11606 da7b75a2835b4ac4b96601359670a922 83d7d5557c61458b8f95322d95305a41 - default default] 172.16.2.13 "OPTIONS /" status: 200 len: 431 microversion: - time: 0.001817
22018-10-11 08:00:50.902 16 INFO nova.api.openstack.requestlog [req-53208dc7-ecfa-4513-ab32-45dfbca11606 da7b75a2835b4ac4b96601359670a922 83d7d5557c61458b8f95322d95305a41 - default default] 172.16.2.4 "OPTIONS /" status: 200 len: 431 microversion: - time: 0.000306
3 multiline part 1
4 multiline part 2
52018-10-11 08:00:51.091 16 INFO nova.api.openstack.requestlog [req-53208dc7-ecfa-4513-ab32-45dfbca11606 da7b75a2835b4ac4b96601359670a922 83d7d5557c61458b8f95322d95305a41 - default default] 172.16.2.29 "OPTIONS /" status: 200 len: 431 microversion: - time: 0.000300
6 more multiline
7and more multiline...
82018-10-11 08:00:51.404 16 INFO nova.api.openstack.requestlog [req-53208dc7-ecfa-4513-ab32-45dfbca11606 da7b75a2835b4ac4b96601359670a922 83d7d5557c61458b8f95322d95305a41 - default default] 172.16.2.13 "OPTIONS /" status: 200 len: 431 microversion: - time: 0.000322
92018-10-11 08:00:52.923 16 INFO nova.api.openstack.requestlog [req-53208dc7-ecfa-4513-ab32-45dfbca11606 da7b75a2835b4ac4b96601359670a922 83d7d5557c61458b8f95322d95305a41 - default default] 172.16.2.4 "OPTIONS /" status: 200 len: 431 microversion: - time: 0.000312 \ No newline at end of file
diff --git a/oslogmerger/tests/functional/data/02-var-log-messages/in/var_log_messages b/oslogmerger/tests/functional/data/02-var-log-messages/in/var_log_messages
new file mode 100644
index 0000000..ef081b1
--- /dev/null
+++ b/oslogmerger/tests/functional/data/02-var-log-messages/in/var_log_messages
@@ -0,0 +1,9 @@
1Oct 11 07:49:20 overcloud-controller-1 systemd: Starting Serial Getty on ttyS0...
2Oct 11 07:49:20 overcloud-controller-1 systemd: Reached target Login Prompts.
3Oct 11 07:49:20 overcloud-controller-1 systemd: Starting Login Prompts.
4Oct 11 07:49:21 overcloud-controller-1 kernel: ip6_tables: (C) 2000-2006 Netfilter Core Team
5Oct 11 07:49:21 overcloud-controller-1 sshd-keygen: Generating SSH2 RSA host key: [ OK ]
6Oct 11 08:00:50 overcloud-controller-1 test: entry 2
7Oct 11 08:00:51 overcloud-controller-1 test: entry 3
8Oct 11 08:00:52 overcloud-controller-1 test: entry 4
9Oct 11 08:00:53 overcloud-controller-1 test: entry 5
diff --git a/oslogmerger/tests/functional/data/02-var-log-messages/in/var_log_messages_ms b/oslogmerger/tests/functional/data/02-var-log-messages/in/var_log_messages_ms
new file mode 100644
index 0000000..c94587b
--- /dev/null
+++ b/oslogmerger/tests/functional/data/02-var-log-messages/in/var_log_messages_ms
@@ -0,0 +1,9 @@
1Oct 11 07:49:20.347281 overcloud-controller-1 test: ms 1
2Oct 11 07:49:20.575312 overcloud-controller-1 test: ms 2
3Oct 11 07:49:20.986673 overcloud-controller-1 test: ms 3
4Oct 11 07:49:21.296738 overcloud-controller-1 test: ms 4
5Oct 11 07:49:21.583617 overcloud-controller-1 test: ms 5
6Oct 11 08:00:50.193729 overcloud-controller-1 test: ms 6
7Oct 11 08:00:51.017367 overcloud-controller-1 test: ms 7
8Oct 11 08:00:52.373661 overcloud-controller-1 test: ms 8
9Oct 11 08:00:53.293771 overcloud-controller-1 test: ms 9
diff --git a/oslogmerger/tests/functional/data/02-var-log-messages/out/mixed.log b/oslogmerger/tests/functional/data/02-var-log-messages/out/mixed.log
new file mode 100644
index 0000000..d635bcf
--- /dev/null
+++ b/oslogmerger/tests/functional/data/02-var-log-messages/out/mixed.log
@@ -0,0 +1,18 @@
1Oct 11 07:49:20 [messages] overcloud-controller-1 systemd: Starting Serial Getty on ttyS0...
2Oct 11 07:49:20 [messages] overcloud-controller-1 systemd: Reached target Login Prompts.
3Oct 11 07:49:20 [messages] overcloud-controller-1 systemd: Starting Login Prompts.
4Oct 11 07:49:21 [messages] overcloud-controller-1 kernel: ip6_tables: (C) 2000-2006 Netfilter Core Team
5Oct 11 07:49:21 [messages] overcloud-controller-1 sshd-keygen: Generating SSH2 RSA host key: [ OK ]
62018-10-11 08:00:49.397 [napi] 16 INFO nova.api.openstack.requestlog [req-53208dc7-ecfa-4513-ab32-45dfbca11606 da7b75a2835b4ac4b96601359670a922 83d7d5557c61458b8f95322d95305a41 - default default] 172.16.2.13 "OPTIONS /" status: 200 len: 431 microversion: - time: 0.001817
7Oct 11 08:00:50 [messages] overcloud-controller-1 test: entry 2
82018-10-11 08:00:50.902 [napi] 16 INFO nova.api.openstack.requestlog [req-53208dc7-ecfa-4513-ab32-45dfbca11606 da7b75a2835b4ac4b96601359670a922 83d7d5557c61458b8f95322d95305a41 - default default] 172.16.2.4 "OPTIONS /" status: 200 len: 431 microversion: - time: 0.000306
9 multiline part 1
10 multiline part 2
11Oct 11 08:00:51 [messages] overcloud-controller-1 test: entry 3
122018-10-11 08:00:51.091 [napi] 16 INFO nova.api.openstack.requestlog [req-53208dc7-ecfa-4513-ab32-45dfbca11606 da7b75a2835b4ac4b96601359670a922 83d7d5557c61458b8f95322d95305a41 - default default] 172.16.2.29 "OPTIONS /" status: 200 len: 431 microversion: - time: 0.000300
13 more multiline
14 and more multiline...
152018-10-11 08:00:51.404 [napi] 16 INFO nova.api.openstack.requestlog [req-53208dc7-ecfa-4513-ab32-45dfbca11606 da7b75a2835b4ac4b96601359670a922 83d7d5557c61458b8f95322d95305a41 - default default] 172.16.2.13 "OPTIONS /" status: 200 len: 431 microversion: - time: 0.000322
16Oct 11 08:00:52 [messages] overcloud-controller-1 test: entry 4
172018-10-11 08:00:52.923 [napi] 16 INFO nova.api.openstack.requestlog [req-53208dc7-ecfa-4513-ab32-45dfbca11606 da7b75a2835b4ac4b96601359670a922 83d7d5557c61458b8f95322d95305a41 - default default] 172.16.2.4 "OPTIONS /" status: 200 len: 431 microversion: - time: 0.000312
18Oct 11 08:00:53 [messages] overcloud-controller-1 test: entry 5
diff --git a/oslogmerger/tests/functional/data/02-var-log-messages/out/mixed_ms.log b/oslogmerger/tests/functional/data/02-var-log-messages/out/mixed_ms.log
new file mode 100644
index 0000000..56893b0
--- /dev/null
+++ b/oslogmerger/tests/functional/data/02-var-log-messages/out/mixed_ms.log
@@ -0,0 +1,27 @@
1Oct 11 07:49:20 [messages] overcloud-controller-1 systemd: Starting Serial Getty on ttyS0...
2Oct 11 07:49:20 [messages] overcloud-controller-1 systemd: Reached target Login Prompts.
3Oct 11 07:49:20 [messages] overcloud-controller-1 systemd: Starting Login Prompts.
4Oct 11 07:49:20.347281 [messages2] overcloud-controller-1 test: ms 1
5Oct 11 07:49:20.575312 [messages2] overcloud-controller-1 test: ms 2
6Oct 11 07:49:20.986673 [messages2] overcloud-controller-1 test: ms 3
7Oct 11 07:49:21 [messages] overcloud-controller-1 kernel: ip6_tables: (C) 2000-2006 Netfilter Core Team
8Oct 11 07:49:21 [messages] overcloud-controller-1 sshd-keygen: Generating SSH2 RSA host key: [ OK ]
9Oct 11 07:49:21.296738 [messages2] overcloud-controller-1 test: ms 4
10Oct 11 07:49:21.583617 [messages2] overcloud-controller-1 test: ms 5
112018-10-11 08:00:49.397 [napi] 16 INFO nova.api.openstack.requestlog [req-53208dc7-ecfa-4513-ab32-45dfbca11606 da7b75a2835b4ac4b96601359670a922 83d7d5557c61458b8f95322d95305a41 - default default] 172.16.2.13 "OPTIONS /" status: 200 len: 431 microversion: - time: 0.001817
12Oct 11 08:00:50 [messages] overcloud-controller-1 test: entry 2
13Oct 11 08:00:50.193729 [messages2] overcloud-controller-1 test: ms 6
142018-10-11 08:00:50.902 [napi] 16 INFO nova.api.openstack.requestlog [req-53208dc7-ecfa-4513-ab32-45dfbca11606 da7b75a2835b4ac4b96601359670a922 83d7d5557c61458b8f95322d95305a41 - default default] 172.16.2.4 "OPTIONS /" status: 200 len: 431 microversion: - time: 0.000306
15 multiline part 1
16 multiline part 2
17Oct 11 08:00:51 [messages] overcloud-controller-1 test: entry 3
18Oct 11 08:00:51.017367 [messages2] overcloud-controller-1 test: ms 7
192018-10-11 08:00:51.091 [napi] 16 INFO nova.api.openstack.requestlog [req-53208dc7-ecfa-4513-ab32-45dfbca11606 da7b75a2835b4ac4b96601359670a922 83d7d5557c61458b8f95322d95305a41 - default default] 172.16.2.29 "OPTIONS /" status: 200 len: 431 microversion: - time: 0.000300
20 more multiline
21 and more multiline...
222018-10-11 08:00:51.404 [napi] 16 INFO nova.api.openstack.requestlog [req-53208dc7-ecfa-4513-ab32-45dfbca11606 da7b75a2835b4ac4b96601359670a922 83d7d5557c61458b8f95322d95305a41 - default default] 172.16.2.13 "OPTIONS /" status: 200 len: 431 microversion: - time: 0.000322
23Oct 11 08:00:52 [messages] overcloud-controller-1 test: entry 4
24Oct 11 08:00:52.373661 [messages2] overcloud-controller-1 test: ms 8
252018-10-11 08:00:52.923 [napi] 16 INFO nova.api.openstack.requestlog [req-53208dc7-ecfa-4513-ab32-45dfbca11606 da7b75a2835b4ac4b96601359670a922 83d7d5557c61458b8f95322d95305a41 - default default] 172.16.2.4 "OPTIONS /" status: 200 len: 431 microversion: - time: 0.000312
26Oct 11 08:00:53 [messages] overcloud-controller-1 test: entry 5
27Oct 11 08:00:53.293771 [messages2] overcloud-controller-1 test: ms 9
diff --git a/oslogmerger/tests/functional/functional.sh b/oslogmerger/tests/functional/functional.sh
index fd7e02b..779cc42 100644
--- a/oslogmerger/tests/functional/functional.sh
+++ b/oslogmerger/tests/functional/functional.sh
@@ -1,9 +1,15 @@
1#!/bin/sh 1#!/bin/sh
2 2
3RED='\033[0;31m'
4GREEN='\033[0;32m'
5NC='\033[0m'
6
3DATA=oslogmerger/tests/functional/data 7DATA=oslogmerger/tests/functional/data
4 8
5fail_func() { 9fail_func() {
6 echo FAILED test case $1 with output file $2 10 echo ${RED}FAILED${NC} test case $1 with output file $2
11 cp $3/out.log $4/$2.failed_output
12 echo $4/$2.failed_output created as reference
7 rm -rf $3 13 rm -rf $3
8 exit 1 14 exit 1
9} 15}
@@ -19,14 +25,23 @@ run_test() {
19 shift 2 25 shift 2
20 26
21 # replace TDATA with the "in" directory for the test 27 # replace TDATA with the "in" directory for the test
22 PARAMS=$(echo $* | sed --expression=s%TDATA%${IN}%g) 28 PARAMS=$(echo $* | sed -e s%TDATA%${IN}%g)
23 29
24 # run os-log-merger capturing the output, then compare to what we expected 30 # run os-log-merger capturing the output, then compare to what we expected
25 os-log-merger $PARAMS >$TMP/out.log 31 os-log-merger $PARAMS >$TMP/out.log
26 32
27 diff -u $OUT/$OUT_FILE $TMP/out.log || fail_func $TEST $OUT_FILE $TMP 33 if [ ! -f $OUT/$OUT_FILE ]; then
34 echo $RED
35 echo output file $OUT/$OUT_FILE does not exist, creating an example file:
36 echo ${OUT}/${OUT_FILE}.sample
37 echo $NC
38 cp $TMP/out.log ${OUT}/${OUT_FILE}.sample
39 fail_func $TEST $OUT_FILE $TMP
40 fi
41
42 diff -u $OUT/$OUT_FILE $TMP/out.log || fail_func $TEST $OUT_FILE $TMP $OUT
28 43
29 echo PASSED test case $TEST / $OUT_FILE 44 echo ${GREEN}PASSED${NC} test case $TEST / $OUT_FILE
30 rm -rf $TMP 45 rm -rf $TMP
31 46
32} 47}
@@ -34,6 +49,12 @@ run_test() {
34run_test 01-simple no-alias.log TDATA/metadata-agent.log TDATA/l3-agent.log 49run_test 01-simple no-alias.log TDATA/metadata-agent.log TDATA/l3-agent.log
35run_test 01-simple alias.log TDATA/metadata-agent.log:META TDATA/l3-agent.log:L3 50run_test 01-simple alias.log TDATA/metadata-agent.log:META TDATA/l3-agent.log:L3
36 51
52run_test 02-var-log-messages mixed.log TDATA/var_log_messages:messages \
53 TDATA/nova-api.log:napi
54run_test 02-var-log-messages mixed_ms.log TDATA/var_log_messages:messages \
55 TDATA/var_log_messages_ms:messages2 \
56 TDATA/nova-api.log:napi
57
37 58
38 59
39 60