@@ -955,7 +955,6 @@ run_tests() {
955
955
fi
956
956
957
957
shift
958
-
959
958
echo " Running tests with $# args" " $@ "
960
959
961
960
if [ ! -d " ${RF_VENV} " ]; then
@@ -1069,6 +1068,187 @@ EOF
1069
1068
fi
1070
1069
}
1071
1070
1071
+ # Build Ginkgo test binary
1072
+ build_ginkgo_binary () {
1073
+ local vmname=" ${1} "
1074
+
1075
+ # Check build dependencies
1076
+ local missing_deps=()
1077
+ for cmd in git go; do
1078
+ command -v " ${cmd} " & > /dev/null || missing_deps+=(" ${cmd} " )
1079
+ done
1080
+
1081
+ if [[ ${# missing_deps[@]} -gt 0 ]]; then
1082
+ error " Missing required dependencies: ${missing_deps[*]} "
1083
+ for dep in " ${missing_deps[@]} " ; do
1084
+ record_junit " ${vmname} " " ${dep} _available" " FAILED"
1085
+ done
1086
+ return 1
1087
+ fi
1088
+
1089
+ # Set up test environment variables
1090
+ local -r tests_repo_dir=" ${SCENARIO_INFO_DIR} /${SCENARIO} /openshift-tests-private"
1091
+ local -r tests_repo_url=" ${OPENSHIFT_TESTS_PRIVATE_REPO:- https:// github.com/ openshift/ openshift-tests-private.git} "
1092
+ local cleanup_needed=false
1093
+
1094
+ # Clone or update repository
1095
+ local release_branch=" release-4.${MINOR_VERSION} "
1096
+ if [[ -d " ${tests_repo_dir} /.git" ]]; then
1097
+ echo " Updating existing test repository..."
1098
+ cd " ${tests_repo_dir} "
1099
+ local current_branch
1100
+ current_branch=" $( git branch --show-current 2> /dev/null || echo " unknown" ) "
1101
+
1102
+ if [[ " ${current_branch} " != " ${release_branch} " ]]; then
1103
+ echo " Current branch '${current_branch} ' differs from target '${release_branch} ', re-cloning..."
1104
+ rm -rf " ${tests_repo_dir} "
1105
+ cleanup_needed=true
1106
+ elif ! git pull --ff-only; then
1107
+ echo " Failed to update repository, re-cloning..."
1108
+ rm -rf " ${tests_repo_dir} "
1109
+ cleanup_needed=true
1110
+ fi
1111
+ else
1112
+ cleanup_needed=true
1113
+ fi
1114
+
1115
+ if ${cleanup_needed} ; then
1116
+ echo " Cloning openshift-tests-private repository..."
1117
+ # Try to clone the release-specific branch first, fallback to default branch
1118
+ if ! git clone --depth 1 --branch " ${release_branch} " " ${tests_repo_url} " " ${tests_repo_dir} " 2> /dev/null; then
1119
+ echo " Branch ${release_branch} not found, cloning default branch..."
1120
+ if ! git clone --depth 1 " ${tests_repo_url} " " ${tests_repo_dir} " ; then
1121
+ record_junit " ${vmname} " " clone_tests_repo" " FAILED"
1122
+ return 1
1123
+ fi
1124
+ else
1125
+ echo " Successfully cloned ${release_branch} branch"
1126
+ fi
1127
+ cd " ${tests_repo_dir} "
1128
+ fi
1129
+ record_junit " ${vmname} " " clone_tests_repo" " OK"
1130
+
1131
+ # Build the test binary
1132
+ echo " Building openshift-tests-private binary..."
1133
+ local test_binary=" ./bin/extended-platform-tests"
1134
+
1135
+ if [[ -f " Makefile" ]]; then
1136
+ if ! make -j" $( nproc) " build; then
1137
+ record_junit " ${vmname} " " build_test_binary" " FAILED"
1138
+ return 1
1139
+ fi
1140
+ elif [[ -f " go.mod" ]]; then
1141
+ if ! go build -o " ${test_binary} " ./cmd/extended-platform-tests; then
1142
+ record_junit " ${vmname} " " build_test_binary" " FAILED"
1143
+ return 1
1144
+ fi
1145
+ else
1146
+ error " Unable to determine build method for tests repository"
1147
+ record_junit " ${vmname} " " build_test_binary" " FAILED"
1148
+ return 1
1149
+ fi
1150
+
1151
+ if [[ ! -f " ${test_binary} " ]]; then
1152
+ error " Test binary not found after build: ${test_binary} "
1153
+ record_junit " ${vmname} " " build_test_binary" " FAILED"
1154
+ return 1
1155
+ fi
1156
+
1157
+ record_junit " ${vmname} " " build_test_binary" " OK"
1158
+
1159
+ # Return the test binary path
1160
+ echo " ${tests_repo_dir} /${test_binary} "
1161
+ }
1162
+
1163
+ # Implementation of Gingko tests
1164
+ run_gingko_tests () {
1165
+ local vmname=" ${1} "
1166
+ shift
1167
+
1168
+ local full_vmname
1169
+ full_vmname=" $( full_vm_name " ${vmname} " ) "
1170
+ if [[ -n " ${RUN_HOST_OVERRIDE} " ]]; then
1171
+ vmname=" ${RUN_HOST_OVERRIDE} "
1172
+ full_vmname=" $( full_vm_name " ${vmname} " ) "
1173
+ ip=$( get_vm_ip " ${full_vmname} " )
1174
+ set_vm_property " ${vmname} " " ip" " ${ip} "
1175
+ set_vm_property " ${vmname} " " ssh_port" " 22"
1176
+ set_vm_property " ${vmname} " " api_port" " 6443"
1177
+ set_vm_property " ${vmname} " " lb_port" " 5678"
1178
+ fi
1179
+
1180
+ local original_dir
1181
+ original_dir=" $( pwd) "
1182
+
1183
+ # Check/install oc
1184
+ if ! command -v oc & > /dev/null; then
1185
+ " ${ROOTDIR} /scripts/fetch_tools.sh" " oc" || {
1186
+ record_junit " ${vmname} " " oc_installed" " FAILED"
1187
+ exit 1
1188
+ }
1189
+ fi
1190
+
1191
+ local test_binary
1192
+ if ! test_binary=" $( build_ginkgo_binary " ${vmname} " ) " ; then
1193
+ cd " ${original_dir} "
1194
+ exit 1
1195
+ fi
1196
+
1197
+ # Set up test environment variables
1198
+ local -r test_results_dir=" ${SCENARIO_INFO_DIR} /${SCENARIO} /gingko-results"
1199
+ mkdir -p " ${test_results_dir} "
1200
+
1201
+ # Set up kubeconfig for tests
1202
+ local -r kubeconfig_file=" ${test_results_dir} /kubeconfig"
1203
+ local -r vm_ip=$( get_vm_property " ${vmname} " " ip" )
1204
+ local -r full_vmname=" $( full_vm_name " ${vmname} " ) "
1205
+ local -r vm_hostname=" ${full_vmname/ ./ -} "
1206
+
1207
+ # Get kubeconfig
1208
+ run_command_on_vm " ${vmname} " " sudo cp /var/lib/microshift/resources/kubeadmin/${vm_hostname} /kubeconfig /home/redhat/kubeconfig-${vm_hostname} " || {
1209
+ error " Failed to copy kubeconfig from /var/lib/microshift/resources/kubeadmin/${vm_hostname} /kubeconfig"
1210
+ record_junit " ${vmname} " " setup_kubeconfig" " FAILED"
1211
+ cd " ${original_dir} "
1212
+ exit 1
1213
+ }
1214
+ run_command_on_vm " ${vmname} " " sudo chown redhat:redhat /home/redhat/kubeconfig-${vm_hostname} "
1215
+
1216
+ # Download kubeconfig to local file
1217
+ copy_file_from_vm " ${vmname} " " /home/redhat/kubeconfig-${vm_hostname} " " ${kubeconfig_file} " || {
1218
+ error " Failed to download kubeconfig from VM"
1219
+ record_junit " ${vmname} " " setup_kubeconfig" " FAILED"
1220
+ cd " ${original_dir} "
1221
+ exit 1
1222
+ }
1223
+ record_junit " ${vmname} " " setup_kubeconfig" " OK"
1224
+
1225
+ export KUBECONFIG=" ${kubeconfig_file} "
1226
+
1227
+ # Run the Gingko tests with MicroShift filter
1228
+ echo " Running Gingko tests with MicroShift filter..."
1229
+ echo " Executing: ${test_binary} run all --dry-run | grep \" MicroShift\" | ${test_binary} run -f - --timeout 60m"
1230
+
1231
+ # Run the tests and capture output
1232
+ if ! ${test_binary} run all --dry-run | grep " MicroShift" | ${test_binary} run -f - --timeout 60m 2>&1 | tee " ${test_results_dir} /test-output.log" ; then
1233
+ echo " Some Gingko tests may have failed. Check results for details."
1234
+ record_junit " ${vmname} " " run_gingko_tests" " FAILED"
1235
+ cd " ${original_dir} "
1236
+ return 1
1237
+ fi
1238
+
1239
+ record_junit " ${vmname} " " run_gingko_tests" " OK"
1240
+
1241
+ # Restore original directory
1242
+ cd " ${original_dir} "
1243
+
1244
+ # Display results summary
1245
+ echo " Gingko test execution completed"
1246
+ echo " Results are available in: ${test_results_dir} "
1247
+ if [[ -f " ${test_results_dir} /test-output.log" ]]; then
1248
+ echo " Test output log: ${test_results_dir} /test-output.log"
1249
+ fi
1250
+ }
1251
+
1072
1252
load_global_settings () {
1073
1253
local filename=" ${TESTDIR} /scenario_settings.sh"
1074
1254
if [ ! -f " ${filename} " ]; then
@@ -1224,11 +1404,10 @@ action_run() {
1224
1404
1225
1405
if [ $# -eq 0 ]; then
1226
1406
RUN_HOST_OVERRIDE=" "
1227
- check_dependencies
1407
+ check_dependencies
1228
1408
else
1229
1409
RUN_HOST_OVERRIDE=" $1 "
1230
1410
fi
1231
-
1232
1411
scenario_run_tests
1233
1412
record_junit " run" " scenario_run_tests" " OK"
1234
1413
}
0 commit comments