Browse Source

Add functional test for var log messages and enhance functional script

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
Miguel Angel Ajo 6 months ago
parent
commit
6b87af03cd

+ 9
- 0
oslogmerger/tests/functional/data/02-var-log-messages/in/nova-api.log View File

@@ -0,0 +1,9 @@
1
+2018-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
2
+2018-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
5
+2018-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
7
+and more multiline...
8
+2018-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
9
+2018-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

+ 9
- 0
oslogmerger/tests/functional/data/02-var-log-messages/in/var_log_messages View File

@@ -0,0 +1,9 @@
1
+Oct 11 07:49:20 overcloud-controller-1 systemd: Starting Serial Getty on ttyS0...
2
+Oct 11 07:49:20 overcloud-controller-1 systemd: Reached target Login Prompts.
3
+Oct 11 07:49:20 overcloud-controller-1 systemd: Starting Login Prompts.
4
+Oct 11 07:49:21 overcloud-controller-1 kernel: ip6_tables: (C) 2000-2006 Netfilter Core Team
5
+Oct 11 07:49:21 overcloud-controller-1 sshd-keygen: Generating SSH2 RSA host key: [  OK  ]
6
+Oct 11 08:00:50 overcloud-controller-1 test: entry 2
7
+Oct 11 08:00:51 overcloud-controller-1 test: entry 3
8
+Oct 11 08:00:52 overcloud-controller-1 test: entry 4
9
+Oct 11 08:00:53 overcloud-controller-1 test: entry 5

+ 9
- 0
oslogmerger/tests/functional/data/02-var-log-messages/in/var_log_messages_ms View File

@@ -0,0 +1,9 @@
1
+Oct 11 07:49:20.347281 overcloud-controller-1 test: ms 1
2
+Oct 11 07:49:20.575312 overcloud-controller-1 test: ms 2
3
+Oct 11 07:49:20.986673 overcloud-controller-1 test: ms 3
4
+Oct 11 07:49:21.296738 overcloud-controller-1 test: ms 4
5
+Oct 11 07:49:21.583617 overcloud-controller-1 test: ms 5
6
+Oct 11 08:00:50.193729 overcloud-controller-1 test: ms 6
7
+Oct 11 08:00:51.017367 overcloud-controller-1 test: ms 7
8
+Oct 11 08:00:52.373661 overcloud-controller-1 test: ms 8
9
+Oct 11 08:00:53.293771 overcloud-controller-1 test: ms 9

+ 18
- 0
oslogmerger/tests/functional/data/02-var-log-messages/out/mixed.log View File

@@ -0,0 +1,18 @@
1
+Oct 11 07:49:20 [messages] overcloud-controller-1 systemd: Starting Serial Getty on ttyS0...
2
+Oct 11 07:49:20 [messages] overcloud-controller-1 systemd: Reached target Login Prompts.
3
+Oct 11 07:49:20 [messages] overcloud-controller-1 systemd: Starting Login Prompts.
4
+Oct 11 07:49:21 [messages] overcloud-controller-1 kernel: ip6_tables: (C) 2000-2006 Netfilter Core Team
5
+Oct 11 07:49:21 [messages] overcloud-controller-1 sshd-keygen: Generating SSH2 RSA host key: [  OK  ]
6
+2018-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
7
+Oct 11 08:00:50 [messages] overcloud-controller-1 test: entry 2
8
+2018-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
11
+Oct 11 08:00:51 [messages] overcloud-controller-1 test: entry 3
12
+2018-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...
15
+2018-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
16
+Oct 11 08:00:52 [messages] overcloud-controller-1 test: entry 4
17
+2018-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
18
+Oct 11 08:00:53 [messages] overcloud-controller-1 test: entry 5

+ 27
- 0
oslogmerger/tests/functional/data/02-var-log-messages/out/mixed_ms.log View File

@@ -0,0 +1,27 @@
1
+Oct 11 07:49:20 [messages] overcloud-controller-1 systemd: Starting Serial Getty on ttyS0...
2
+Oct 11 07:49:20 [messages] overcloud-controller-1 systemd: Reached target Login Prompts.
3
+Oct 11 07:49:20 [messages] overcloud-controller-1 systemd: Starting Login Prompts.
4
+Oct 11 07:49:20.347281 [messages2] overcloud-controller-1 test: ms 1
5
+Oct 11 07:49:20.575312 [messages2] overcloud-controller-1 test: ms 2
6
+Oct 11 07:49:20.986673 [messages2] overcloud-controller-1 test: ms 3
7
+Oct 11 07:49:21 [messages] overcloud-controller-1 kernel: ip6_tables: (C) 2000-2006 Netfilter Core Team
8
+Oct 11 07:49:21 [messages] overcloud-controller-1 sshd-keygen: Generating SSH2 RSA host key: [  OK  ]
9
+Oct 11 07:49:21.296738 [messages2] overcloud-controller-1 test: ms 4
10
+Oct 11 07:49:21.583617 [messages2] overcloud-controller-1 test: ms 5
11
+2018-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
12
+Oct 11 08:00:50 [messages] overcloud-controller-1 test: entry 2
13
+Oct 11 08:00:50.193729 [messages2] overcloud-controller-1 test: ms 6
14
+2018-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
17
+Oct 11 08:00:51 [messages] overcloud-controller-1 test: entry 3
18
+Oct 11 08:00:51.017367 [messages2] overcloud-controller-1 test: ms 7
19
+2018-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...
22
+2018-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
23
+Oct 11 08:00:52 [messages] overcloud-controller-1 test: entry 4
24
+Oct 11 08:00:52.373661 [messages2] overcloud-controller-1 test: ms 8
25
+2018-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
26
+Oct 11 08:00:53 [messages] overcloud-controller-1 test: entry 5
27
+Oct 11 08:00:53.293771 [messages2] overcloud-controller-1 test: ms 9

+ 25
- 4
oslogmerger/tests/functional/functional.sh View File

@@ -1,9 +1,15 @@
1 1
 #!/bin/sh
2 2
 
3
+RED='\033[0;31m'
4
+GREEN='\033[0;32m'
5
+NC='\033[0m'
6
+
3 7
 DATA=oslogmerger/tests/functional/data
4 8
 
5 9
 fail_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 13
    rm -rf $3
8 14
    exit 1
9 15
 }
@@ -19,14 +25,23 @@ run_test() {
19 25
    shift 2
20 26
 
21 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 30
    # run os-log-merger capturing the output, then compare to what we expected
25 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 45
    rm -rf $TMP
31 46
 
32 47
 }
@@ -34,6 +49,12 @@ run_test() {
34 49
 run_test 01-simple no-alias.log TDATA/metadata-agent.log TDATA/l3-agent.log
35 50
 run_test 01-simple alias.log  TDATA/metadata-agent.log:META TDATA/l3-agent.log:L3
36 51
 
52
+run_test 02-var-log-messages mixed.log TDATA/var_log_messages:messages \
53
+                                       TDATA/nova-api.log:napi
54
+run_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
 

Loading…
Cancel
Save