Skip to content

Commit 7eec2f2

Browse files
committed
Refactor HCP test configuration to use external cluster mode
- Replace HC_BACKUP_RESTORE_MODE with TEST_HCP_EXTERNAL flag - Rename "existing" mode to "external" for clarity - Move HCP external test args to separate HCP_EXTERNAL_ARGS variable - Rename hcp_full_backup_restore_suite_test.go to hcp_external_cluster_backup_restore_suite_test.go - Update test labels from "hcp" to "hcp_external" for external cluster tests - Simplify Makefile by removing unused HC mode variables from main test-e2e target - Update documentation to reflect new external cluster test configuration
1 parent 5cf83f9 commit 7eec2f2

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

Makefile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,11 @@ TTL_DURATION ?= 1h
6464
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
6565
ENVTEST_K8S_VERSION = 1.32 # Kubernetes version from OpenShift 4.19.x https://openshift-release.apps.ci.l2s4.p1.openshiftapps.com/#4-stable
6666

67-
# HC_BACKUP_RESTORE_MODE is used to run HCP tests against existing HostedControlPlane.
68-
# Possible values are: create, existing.
69-
HC_BACKUP_RESTORE_MODE ?= create
70-
# HC_NAME is the name of the HostedCluster to use for HCP tests when HC_BACKUP_RESTORE_MODE is set to existing.
71-
# Otherwise, HC_NAME is ignored.
67+
# HC_NAME is the name of the HostedCluster to use for HCP tests when
68+
# hc_backup_restore_mode is set to external. Otherwise, HC_NAME is ignored.
7269
HC_NAME ?= ""
73-
# HC_KUBECONFIG is the path to the kubeconfig file for the HostedCluster to use for HCP tests when HC_BACKUP_RESTORE_MODE is set to existing.
70+
# HC_KUBECONFIG is the path to the kubeconfig file for the HostedCluster
71+
# to use for HCP tests when hc_backup_restore_mode is set to external.
7472
# Otherwise, HC_KUBECONFIG is ignored.
7573
HC_KUBECONFIG ?= ""
7674

@@ -741,6 +739,8 @@ ARTIFACT_DIR ?= /tmp
741739
HCO_UPSTREAM ?= false
742740
TEST_VIRT ?= false
743741
TEST_HCP ?= false
742+
TEST_HCP_EXTERNAL ?= false
743+
HCP_EXTERNAL_ARGS ?= ""
744744
TEST_CLI ?= false
745745
SKIP_MUST_GATHER ?= false
746746
TEST_UPGRADE ?= false
@@ -762,6 +762,12 @@ ifeq ($(TEST_HCP),true)
762762
else
763763
TEST_FILTER += && (! hcp)
764764
endif
765+
ifeq ($(TEST_HCP_EXTERNAL),true)
766+
TEST_FILTER += && (hcp_external)
767+
HCP_EXTERNAL_ARGS = -hc_backup_restore_mode=external -hc_name=$(HC_NAME) -hc_kubeconfig=$(HC_KUBECONFIG)
768+
else
769+
TEST_FILTER += && (! hcp_external)
770+
endif
765771
ifeq ($(TEST_CLI),true)
766772
TEST_FILTER += && (cli)
767773
else
@@ -779,16 +785,14 @@ test-e2e: test-e2e-setup install-ginkgo ## Run E2E tests against OADP operator i
779785
-velero_instance_name=$(VELERO_INSTANCE_NAME) \
780786
-artifact_dir=$(ARTIFACT_DIR) \
781787
-kvm_emulation=$(KVM_EMULATION) \
782-
-hc_backup_restore_mode=$(HC_BACKUP_RESTORE_MODE) \
783-
-hc_name=$(HC_NAME) \
784-
-hc_kubeconfig=$(HC_KUBECONFIG) \
785788
-hco_upstream=$(HCO_UPSTREAM) \
786789
-skipMustGather=$(SKIP_MUST_GATHER) \
787790
--ginkgo.vv \
788791
--ginkgo.no-color=$(OPENSHIFT_CI) \
789792
--ginkgo.label-filter="$(TEST_FILTER)" \
790793
--ginkgo.junit-report="$(ARTIFACT_DIR)/junit_report.xml" \
791794
--ginkgo.timeout=2h \
795+
$(HCP_EXTERNAL_ARGS) \
792796
$(GINKGO_ARGS)
793797

794798
.PHONY: test-e2e-cleanup

docs/developer/testing/TESTING.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,12 @@ You can also execute make test-e2e with a $GINKGO_ARGS variable set. Example:
100100
make test-e2e GINKGO_ARGS="--ginkgo.focus='MySQL application DATAMOVER'"
101101
```
102102

103-
### Run selected test for HCP against existing HostedControlPlane
103+
### Run selected test for HCP against external HostedControlPlane
104104

105105
Set common env variables as mentioned above, then run:
106106

107107
```bash
108-
TEST_HCP=true \
109-
HC_BACKUP_RESTORE_MODE=existing \
108+
TEST_HCP_EXTERNAL=true \
110109
HC_NAME=hc1 \
111110
HC_KUBECONFIG=/path/to/kubeconfig/for/hosted/cluster \
112111
make test-e2e

tests/e2e/hcp_backup_restore_suite_test.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ type HCBackupRestoreMode string
1818

1919
const (
2020
HCModeCreate HCBackupRestoreMode = "create" // Create new HostedCluster for test
21-
HCModeExisting HCBackupRestoreMode = "existing" // Get existing HostedCluster
22-
// TODO: Add HCModeExistingROSA for ROSA where DPA and some other resources are already installed
21+
HCModeExternal HCBackupRestoreMode = "external" // Get external HostedCluster
22+
// TODO: Add HCModeExternalROSA for ROSA where DPA and some other resources are already installed
2323
)
2424

25-
// runHCPBackupAndRestore is the unified function that handles both create and existing HC modes
25+
// runHCPBackupAndRestore is the unified function that handles both create and external HC modes
2626
func runHCPBackupAndRestore(
2727
brCase HCPBackupRestoreCase,
2828
updateLastBRcase func(HCPBackupRestoreCase),
@@ -50,8 +50,8 @@ func runHCPBackupAndRestore(
5050
// Create new HostedCluster for test
5151
h.HostedCluster, err = h.DeployHCManifest(brCase.Template, brCase.Provider, brCase.BackupRestoreCase.Name)
5252
gomega.Expect(err).ToNot(gomega.HaveOccurred())
53-
case HCModeExisting:
54-
// Get existing HostedCluster
53+
case HCModeExternal:
54+
// Get external HostedCluster
5555
h.HostedCluster, err = h.GetHostedCluster(brCase.BackupRestoreCase.Name, libhcp.ClustersNamespace)
5656
gomega.Expect(err).ToNot(gomega.HaveOccurred())
5757
default:
@@ -65,7 +65,7 @@ func runHCPBackupAndRestore(
6565
gomega.Expect(err).ToNot(gomega.HaveOccurred(), "failed to run HCP pre-backup verification: %v", err)
6666
}
6767

68-
if brCase.Mode == HCModeExisting {
68+
if brCase.Mode == HCModeExternal {
6969
// Pre-backup verification for guest cluster
7070
if brCase.PreBackupVerifyGuest != nil {
7171
log.Printf("Validating guest cluster pre-backup")
@@ -98,7 +98,7 @@ func runHCPBackupAndRestore(
9898
gomega.Expect(err).ToNot(gomega.HaveOccurred(), "failed to run HCP post-restore verification: %v", err)
9999
}
100100

101-
if brCase.Mode == HCModeExisting {
101+
if brCase.Mode == HCModeExternal {
102102
// Post-restore verification for guest cluster
103103
if brCase.PostRestoreVerifyGuest != nil {
104104
log.Printf("Validating guest cluster post-restore")
@@ -137,9 +137,6 @@ var _ = ginkgo.Describe("HCP Backup and Restore tests", ginkgo.Ordered, func() {
137137

138138
// Before All
139139
var _ = ginkgo.BeforeAll(func() {
140-
if hcBackupRestoreMode == string(HCModeExisting) {
141-
ginkgo.Skip("Skipping HCP backup and restore test for existing HCP")
142-
}
143140
// Wait for CatalogSource to be ready
144141
err := libhcp.WaitForCatalogSourceReady(
145142
ctx,

tests/e2e/hcp_full_backup_restore_suite_test.go renamed to tests/e2e/hcp_external_cluster_backup_restore_suite_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import (
1313
libhcp "github.com/openshift/oadp-operator/tests/e2e/lib/hcp"
1414
)
1515

16-
// Full cluster backup and restore tests will skip creating HostedCluster resource. They expect the cluster
16+
// External cluster backup and restore tests will skip creating HostedCluster resource. They expect the cluster
1717
// to already have HostedCluster with a data plane.
1818
// The tests are skipped unless hc_backup_restore_mode flag is properly configured.
19-
var _ = ginkgo.Describe("HCP full Backup and Restore tests", ginkgo.Ordered, func() {
19+
var _ = ginkgo.Describe("HCP external cluster Backup and Restore tests", ginkgo.Ordered, func() {
2020
var (
2121
lastInstallTime time.Time
2222
lastBRCase HCPBackupRestoreCase
@@ -32,7 +32,7 @@ var _ = ginkgo.Describe("HCP full Backup and Restore tests", ginkgo.Ordered, fun
3232
}
3333

3434
var _ = ginkgo.BeforeAll(func() {
35-
if hcBackupRestoreMode != string(HCModeExisting) {
35+
if hcBackupRestoreMode != string(HCModeExternal) {
3636
ginkgo.Skip("Skipping HCP full backup and restore test for non-existent HCP")
3737
}
3838

@@ -50,13 +50,13 @@ var _ = ginkgo.Describe("HCP full Backup and Restore tests", ginkgo.Ordered, fun
5050
tearDownDPAResources(lastBRCase.BackupRestoreCase)
5151
})
5252

53-
ginkgo.It("HCP full backup and restore test", ginkgo.Label("hcp"), func() {
53+
ginkgo.It("HCP external cluster backup and restore test", ginkgo.Label("hcp_external"), func() {
5454
if ginkgo.CurrentSpecReport().NumAttempts > 1 && !knownFlake {
5555
ginkgo.Fail("No known FLAKE found in a previous run, marking test as failed.")
5656
}
5757

5858
runHCPBackupAndRestore(HCPBackupRestoreCase{
59-
Mode: HCModeExisting,
59+
Mode: HCModeExternal,
6060
PreBackupVerifyGuest: preBackupVerifyGuest(),
6161
PostRestoreVerifyGuest: postBackupVerifyGuest(),
6262
BackupRestoreCase: BackupRestoreCase{

0 commit comments

Comments
 (0)