Skip to content

Commit

Permalink
test: provision gke cluster in full e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Salas <[email protected]>
  • Loading branch information
salasberryfin committed Nov 11, 2024
1 parent 772fee9 commit 4584039
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/e2e/config/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ intervals:
default/wait-v2prov-create: ["25m", "30s"]
default/wait-capa-create-cluster: ["30m", "30s"]
default/wait-capz-create-cluster: ["35m", "30s"]
default/wait-capg-create-cluster: ["30m", "30s"]
default/wait-capv-create-cluster: ["30m", "30s"]
default/wait-gitea: ["3m", "10s"]
default/wait-gitpush: ["3m", "10s"]
default/wait-consistently: ["30s", "5s"]
default/wait-getservice: ["5m", "30s"]
default/wait-eks-delete: ["35m", "30s"]
default/wait-aks-delete: ["30m", "30s"]
default/wait-gke-delete: ["35m", "30s"]
default/wait-azure-delete: ["15m", "30s"]
default/wait-azure: ["30m", "30s"]
default/wait-vsphere-delete: ["20m", "30s"]
Expand Down
60 changes: 60 additions & 0 deletions test/e2e/data/cluster-templates/gcp-gke.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: "${CLUSTER_NAME}"
spec:
clusterNetwork:
pods:
cidrBlocks: ["192.168.0.0/16"]
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPManagedCluster
name: "${CLUSTER_NAME}"
controlPlaneRef:
kind: GCPManagedControlPlane
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
name: "${CLUSTER_NAME}-control-plane"
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPManagedCluster
metadata:
name: "${CLUSTER_NAME}"
spec:
project: "${GCP_PROJECT}"
region: "europe-west2"
network:
name: "highlander-ci"
---
kind: GCPManagedControlPlane
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
metadata:
name: "${CLUSTER_NAME}-control-plane"
spec:
project: "${GCP_PROJECT}"
location: "europe-west2"
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachinePool
metadata:
name: "${CLUSTER_NAME}-mp-0"
spec:
clusterName: "${CLUSTER_NAME}"
replicas: 1
template:
spec:
bootstrap:
dataSecretName: ""
clusterName: "${CLUSTER_NAME}"
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPManagedMachinePool
name: "${CLUSTER_NAME}-mp-0"
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPManagedMachinePool
metadata:
name: "${CLUSTER_NAME}-mp-0"
spec:
nodeLocations:
- "europe-west2-a"
9 changes: 9 additions & 0 deletions test/e2e/specs/import_gitops_mgmtv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ type CreateMgmtV3UsingGitOpsSpecInput struct {
CapiClusterOwnerLabel string
CapiClusterOwnerNamespaceLabel string
OwnedLabelName string

// IsGCPCluster is used to substitute GCP-specific values from secrets
IsGCPCluster bool
}

// CreateMgmtV3UsingGitOpsSpec implements a spec that will create a cluster via Fleet and test that it
Expand Down Expand Up @@ -233,6 +236,12 @@ func CreateMgmtV3UsingGitOpsSpec(ctx context.Context, inputGetter func() CreateM
"WORKER_MACHINE_COUNT": strconv.Itoa(workerMachineCount),
"CONTROL_PLANE_MACHINE_COUNT": strconv.Itoa(controlPlaneMachineCount),
}

// These variables (secrets) are not accessible when using the pr webhook (aka `ShortTestLabel`)
if input.IsGCPCluster {
additionalVars["GCP_PROJECT"] = input.E2EConfig.GetVariable(e2e.GCPProjectVar)
}

for k, v := range input.AdditionalTemplateVariables {
additionalVars[k] = v
}
Expand Down
33 changes: 33 additions & 0 deletions test/e2e/suites/import-gitops-v3/import_gitops_v3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,36 @@ var _ = Describe("[AWS] [EKS] - [management.cattle.io/v3] Create and delete CAPI
}
})
})

var _ = Describe("[GCP] [GKE] - [management.cattle.io/v3] Create and delete CAPI cluster functionality should work with namespace auto-import", Label(e2e.FullTestLabel), func() {
BeforeEach(func() {
komega.SetClient(setupClusterResult.BootstrapClusterProxy.GetClient())
komega.SetContext(ctx)
})

specs.CreateMgmtV3UsingGitOpsSpec(ctx, func() specs.CreateMgmtV3UsingGitOpsSpecInput {
return specs.CreateMgmtV3UsingGitOpsSpecInput{
E2EConfig: e2eConfig,
BootstrapClusterProxy: setupClusterResult.BootstrapClusterProxy,
ClusterctlConfigPath: flagVals.ConfigPath,
ClusterctlBinaryPath: e2eConfig.GetVariable(e2e.ClusterctlBinaryPathVar),
ArtifactFolder: artifactsFolder,
ClusterTemplate: e2e.CAPIGCPGKE,
ClusterName: "clusterv3-gke",
ControlPlaneMachineCount: ptr.To[int](1),
WorkerMachineCount: ptr.To[int](1),
GitAddr: giteaResult.GitAddress,
GitAuthSecretName: e2e.AuthSecretName,
SkipCleanup: false,
SkipDeletionTest: false,
LabelNamespace: true,
RancherServerURL: hostName,
CAPIClusterCreateWaitName: "wait-capg-create-cluster",
DeleteClusterWaitName: "wait-gke-delete",
CapiClusterOwnerLabel: e2e.CapiClusterOwnerLabel,
CapiClusterOwnerNamespaceLabel: e2e.CapiClusterOwnerNamespaceLabel,
OwnedLabelName: e2e.OwnedLabelName,
IsGCPCluster: true,
}
})
})

0 comments on commit 4584039

Please sign in to comment.