Skip to content

Commit 9116f9d

Browse files
committed
f
1 parent d0fc72b commit 9116f9d

File tree

2 files changed

+96
-35
lines changed

2 files changed

+96
-35
lines changed

.github/workflows/v3-e2e.yaml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -198,32 +198,32 @@ jobs:
198198
--license-file ./e2e/licenses/ci-v3.yaml \
199199
--cmx-token=env://CMX_REPLICATED_API_TOKEN \
200200
--ssh-key=env://CMX_SSH_PRIVATE_KEY \
201-
export --path=./e2e-results-online
201+
export --path=./e2e-results
202202
203203
# Read result.json to extract test result
204-
if [ -f ./e2e-results-online/result.json ]; then
205-
success=$(jq -r '.Success' ./e2e-results-online/result.json)
204+
if [ -f ./e2e-results/result.json ]; then
205+
success=$(jq -r '.Success' ./e2e-results/result.json)
206206
echo "Test success: $success"
207207
208208
# Exit with test result
209209
if [ "$success" = "true" ]; then
210210
exit 0
211211
else
212-
error=$(jq -r '.Error' ./e2e-results-online/result.json)
212+
error=$(jq -r '.Error' ./e2e-results/result.json)
213213
echo "::error::E2E test failed: $error"
214214
exit 1
215215
fi
216216
else
217-
echo "::error::result.json not found in e2e-results-online directory"
217+
echo "::error::result.json not found in e2e-results directory"
218218
exit 1
219219
fi
220220
221221
- name: Upload test results
222-
if: ${{ !cancelled() && hashFiles('./e2e-results-online/**') != '' }}
222+
if: ${{ !cancelled() && hashFiles('./e2e-results/**') != '' }}
223223
uses: actions/upload-artifact@v4
224224
with:
225-
name: e2e-results-online
226-
path: ./e2e-results-online/
225+
name: e2e-results-headless-online
226+
path: ./e2e-results/
227227

228228
e2e-headless-airgap:
229229
name: E2E headless airgap
@@ -256,29 +256,29 @@ jobs:
256256
--license-file ./e2e/licenses/ci-v3.yaml \
257257
--cmx-token=env://CMX_REPLICATED_API_TOKEN \
258258
--ssh-key=env://CMX_SSH_PRIVATE_KEY \
259-
export --path=./e2e-results-airgap
259+
export --path=./e2e-results
260260
261261
# Read result.json to extract test result
262-
if [ -f ./e2e-results-airgap/result.json ]; then
263-
success=$(jq -r '.Success' ./e2e-results-airgap/result.json)
262+
if [ -f ./e2e-results/result.json ]; then
263+
success=$(jq -r '.Success' ./e2e-results/result.json)
264264
echo "Test success: $success"
265265
266266
# Exit with test result
267267
if [ "$success" = "true" ]; then
268268
exit 0
269269
else
270-
error=$(jq -r '.Error' ./e2e-results-airgap/result.json)
270+
error=$(jq -r '.Error' ./e2e-results/result.json)
271271
echo "::error::E2E test failed: $error"
272272
exit 1
273273
fi
274274
else
275-
echo "::error::result.json not found in e2e-results-airgap directory"
275+
echo "::error::result.json not found in e2e-results directory"
276276
exit 1
277277
fi
278278
279279
- name: Upload test results
280-
if: ${{ !cancelled() && hashFiles('./e2e-results-airgap/**') != '' }}
280+
if: ${{ !cancelled() && hashFiles('./e2e-results/**') != '' }}
281281
uses: actions/upload-artifact@v4
282282
with:
283-
name: e2e-results-airgap
284-
path: ./e2e-results-airgap/
283+
name: e2e-results-headless-airgap
284+
path: ./e2e-results/

dagger/e2e.go

Lines changed: 80 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,7 @@ func (m *EmbeddedCluster) E2eRunHeadless(
106106
// Collect support bundle before cleanup
107107
if vm != nil && !skipSupportBundleCollection {
108108
fmt.Printf("Collecting support bundle from VM %s...\n", vm.VmID)
109-
supportBundle, bundleErr := vm.CollectClusterSupportBundle(ctx)
110-
if bundleErr != nil {
111-
fmt.Printf("Warning: failed to collect support bundle: %v\n", bundleErr)
112-
resultsDir = resultsDir.WithNewFile("support-bundle-error.txt", fmt.Sprintf("Failed to collect support bundle: %v", bundleErr))
113-
} else {
114-
resultsDir = resultsDir.WithFile("support-bundle.tar.gz", supportBundle)
115-
}
116-
117-
hostSupportBundle, hostBundleErr := vm.CollectHostSupportBundle(ctx)
118-
if hostBundleErr != nil {
119-
fmt.Printf("Warning: failed to collect host support bundle: %v\n", hostBundleErr)
120-
resultsDir = resultsDir.WithNewFile("host-support-bundle-error.txt", fmt.Sprintf("Failed to collect host support bundle: %v", hostBundleErr))
121-
} else {
122-
resultsDir = resultsDir.WithFile("host-support-bundle.tar.gz", hostSupportBundle)
123-
}
109+
resultsDir = collectSupportBundles(ctx, vm, resultsDir)
124110
}
125111

126112
// Marshal final test result to JSON
@@ -187,17 +173,92 @@ func (m *EmbeddedCluster) E2eRunHeadless(
187173
// Update final test result
188174
testResult.Success = validationResult.Success
189175
testResult.ValidationResults = validationResult
190-
191176
if !validationResult.Success {
192177
testResult.Error = "validation checks failed"
193-
fmt.Printf("Test FAILED: %s %s test validation failed\n", scenario, mode)
194-
} else {
195-
fmt.Printf("Test PASSED: %s %s test completed successfully\n", scenario, mode)
196178
}
197179

180+
// Print formatted test results
181+
printResults(validationResult, scenario, mode, appVersion, kubeVersion, vm)
182+
198183
return
199184
}
200185

186+
func collectSupportBundles(ctx context.Context, vm *CmxInstance, resultsDir *dagger.Directory) *dagger.Directory {
187+
fmt.Printf("Collecting support bundle from VM %s...\n", vm.VmID)
188+
supportBundle, bundleErr := vm.CollectClusterSupportBundle(ctx)
189+
if bundleErr != nil {
190+
fmt.Printf("Warning: failed to collect support bundle: %v\n", bundleErr)
191+
resultsDir = resultsDir.WithNewFile("support-bundle-error.txt", fmt.Sprintf("Failed to collect support bundle: %v", bundleErr))
192+
} else {
193+
resultsDir = resultsDir.WithFile("support-bundle.tar.gz", supportBundle)
194+
}
195+
196+
hostSupportBundle, hostBundleErr := vm.CollectHostSupportBundle(ctx)
197+
if hostBundleErr != nil {
198+
fmt.Printf("Warning: failed to collect host support bundle: %v\n", hostBundleErr)
199+
resultsDir = resultsDir.WithNewFile("host-support-bundle-error.txt", fmt.Sprintf("Failed to collect host support bundle: %v", hostBundleErr))
200+
} else {
201+
resultsDir = resultsDir.WithFile("host-support-bundle.tar.gz", hostSupportBundle)
202+
}
203+
204+
return resultsDir
205+
}
206+
207+
func printResults(validationResult *ValidationResult, scenario string, mode string, appVersion string, kubeVersion string, vm *CmxInstance) {
208+
fmt.Printf("\n")
209+
fmt.Printf("================================\n")
210+
if validationResult.Success {
211+
fmt.Printf("✓ E2E TEST PASSED\n")
212+
} else {
213+
fmt.Printf("✗ E2E TEST FAILED\n")
214+
}
215+
fmt.Printf("================================\n")
216+
fmt.Printf("Scenario: %s\n", scenario)
217+
fmt.Printf("Mode: %s\n", mode)
218+
fmt.Printf("App Version: %s\n", appVersion)
219+
fmt.Printf("Kube Version: %s\n", kubeVersion)
220+
fmt.Printf("VM ID: %s\n", vm.VmID)
221+
fmt.Printf("\n")
222+
fmt.Printf("Validation Results:\n")
223+
fmt.Printf(" Cluster Health: %s\n", formatCheckResult(validationResult.ClusterHealth))
224+
fmt.Printf(" Installation CRD: %s\n", formatCheckResult(validationResult.InstallationCRD))
225+
fmt.Printf(" App Deployment: %s\n", formatCheckResult(validationResult.AppDeployment))
226+
fmt.Printf(" Admin Console: %s\n", formatCheckResult(validationResult.AdminConsole))
227+
fmt.Printf(" Data Directories: %s\n", formatCheckResult(validationResult.DataDirectories))
228+
fmt.Printf(" Pods and Jobs: %s\n", formatCheckResult(validationResult.PodsAndJobs))
229+
230+
if !validationResult.Success {
231+
fmt.Printf("\n")
232+
fmt.Printf("Failed Checks:\n")
233+
if !validationResult.ClusterHealth.Passed {
234+
fmt.Printf(" • Cluster Health: %s\n", validationResult.ClusterHealth.ErrorMessage)
235+
}
236+
if !validationResult.InstallationCRD.Passed {
237+
fmt.Printf(" • Installation CRD: %s\n", validationResult.InstallationCRD.ErrorMessage)
238+
}
239+
if !validationResult.AppDeployment.Passed {
240+
fmt.Printf(" • App Deployment: %s\n", validationResult.AppDeployment.ErrorMessage)
241+
}
242+
if !validationResult.AdminConsole.Passed {
243+
fmt.Printf(" • Admin Console: %s\n", validationResult.AdminConsole.ErrorMessage)
244+
}
245+
if !validationResult.DataDirectories.Passed {
246+
fmt.Printf(" • Data Directories: %s\n", validationResult.DataDirectories.ErrorMessage)
247+
}
248+
if !validationResult.PodsAndJobs.Passed {
249+
fmt.Printf(" • Pods and Jobs: %s\n", validationResult.PodsAndJobs.ErrorMessage)
250+
}
251+
}
252+
fmt.Printf("================================\n\n")
253+
}
254+
255+
func formatCheckResult(check *CheckResult) string {
256+
if check.Passed {
257+
return "✓ PASSED"
258+
}
259+
return "✗ FAILED"
260+
}
261+
201262
func parseLicense(ctx context.Context, licenseFile *dagger.File) (contents string, licenseID string, channelID string, err error) {
202263
contents, err = licenseFile.Contents(ctx)
203264
if err != nil {

0 commit comments

Comments
 (0)