@@ -28,6 +28,32 @@ failed_version() {
28
28
return " $result "
29
29
}
30
30
31
+ # run_test_and_analyze_failed_logs
32
+ # ------------------------------------------
33
+ # Function calls specific test suite and in case of failure
34
+ # it sends the failed logs to logdetective and prints report
35
+ # generated by logdetective AI
36
+ # Argument: test_run - what kind of test that will be executed. Like 'test/run'
37
+ run_test_and_analyze_failed_logs () {
38
+ local test_run=" $1 "
39
+ set -o pipefail
40
+ tmp_file=$( mktemp " /tmp/${OS} -${dir} .XXXXXX" )
41
+ VERSION=$dir $test_run 2>&1 | tee " $tmp_file "
42
+ ret_code=$?
43
+ set +o pipefail
44
+ cat " ${tmp_file} "
45
+ if [[ " $ret_code " != " 0" ]]; then
46
+ if [[ " ${OS} " == " rhel8" ]] || [[ " ${OS} " == " rhel9" ]] || [[ " ${OS} " == " rhel10" ]]; then
47
+ set +e
48
+ analyze_logs_by_logdetective " $tmp_file "
49
+ # Let's switch it back
50
+ set -e
51
+ fi
52
+ fi
53
+ failed_version " $ret_code " " $dir "
54
+ rm -f " $tmp_file "
55
+
56
+ }
31
57
# This adds backwards compatibility if only single version needs to be testing
32
58
# In CI we would like to test single version but VERSIONS= means, that nothing is tested
33
59
# make test TARGET=<OS> VERSIONS=<something> ... checks single version for CLI
@@ -51,22 +77,7 @@ for dir in ${VERSIONS}; do
51
77
fi
52
78
53
79
if [ -n " ${TEST_MODE} " ]; then
54
- set -o pipefail
55
- tmp_file=$( mktemp " /tmp/${OS} -${dir} .XXXXXX" )
56
- VERSION=$dir test/run 2>&1 | tee " $tmp_file "
57
- ret_code=$?
58
- set +o pipefail
59
- cat " ${tmp_file} "
60
- if [[ " $ret_code " != " 0" ]]; then
61
- if [[ " ${OS} " == " rhel8" ]] || [[ " ${OS} " == " rhel9" ]] || [[ " ${OS} " == " rhel10" ]]; then
62
- set +e
63
- analyze_logs_by_logdetective " $tmp_file "
64
- # Let's switch it back
65
- set -e
66
- fi
67
- fi
68
- failed_version " $ret_code " " $dir "
69
- rm -f " $tmp_file "
80
+ run_test_and_analyze_failed_logs " test/run"
70
81
fi
71
82
72
83
if [ -n " ${TEST_OPENSHIFT_4} " ]; then
@@ -76,8 +87,7 @@ for dir in ${VERSIONS}; do
76
87
echo " -> .exclude-openshift file exists for version $dir , skipping OpenShift-4 tests."
77
88
else
78
89
if [ -x test/run-openshift-remote-cluster ]; then
79
- VERSION=$dir test/run-openshift-remote-cluster
80
- failed_version " $? " " $dir "
90
+ run_test_and_analyze_failed_logs " test/run-openshift-remote-cluster"
81
91
else
82
92
echo " -> Tests for OpenShift 4 are not present. Add run-openshift-remote-cluster script, skipping"
83
93
fi
@@ -87,40 +97,23 @@ for dir in ${VERSIONS}; do
87
97
88
98
if [ -n " ${TEST_UPSTREAM} " ]; then
89
99
if [ -x test/run-upstream ]; then
90
- set -o pipefail
91
- tmp_file=$( mktemp " /tmp/${OS} -${dir} .XXXXXX" )
92
- VERSION=$dir test/run-upstream 2>&1 | tee " $tmp_file "
93
- ret_code=$?
94
- set +o pipefail
95
- cat " ${tmp_file} "
96
- if [[ " $ret_code " != " 0" ]]; then
97
- if [[ " ${OS} " == " rhel8" ]] || [[ " ${OS} " == " rhel9" ]] || [[ " ${OS} " == " rhel10" ]]; then
98
- set +e
99
- analyze_logs_by_logdetective " $tmp_file "
100
- # Let's switch it back
101
- set -e
102
- fi
103
- fi
104
- failed_version " $ret_code " " $dir "
105
- rm -f " $tmp_file "
100
+ run_test_and_analyze_failed_logs " test/run-upstream"
106
101
else
107
102
echo " -> Upstream tests are not present, skipping"
108
103
fi
109
104
fi
110
105
111
106
if [ -n " ${TEST_OPENSHIFT_PYTEST} " ]; then
112
107
if [ -x test/run-openshift-pytest ]; then
113
- VERSION=$dir test/run-openshift-pytest
114
- failed_version " $? " " $dir "
108
+ run_test_and_analyze_failed_logs " test/run-openshift-pytest"
115
109
else
116
110
echo " -> OpenShift PyTest tests are not present, skipping"
117
111
fi
118
112
fi
119
113
120
114
if [ -n " ${TEST_PYTEST} " ]; then
121
115
if [ -x test/run-pytest ]; then
122
- VERSION=$dir test/run-pytest
123
- failed_version " $? " " $dir "
116
+ run_test_and_analyze_failed_logs " test/run-pytest"
124
117
else
125
118
echo " -> PyTest tests are not present, skipping"
126
119
fi
0 commit comments