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 <carlos.salas@suse.com>
  • Loading branch information
salasberryfin committed Nov 7, 2024
1 parent 0226d17 commit 49070ee
Show file tree
Hide file tree
Showing 5 changed files with 98 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
4 changes: 4 additions & 0 deletions test/e2e/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ var (
//go:embed data/cluster-templates/aws-eks-mmp.yaml
CAPIAwsEKSMMP []byte

//go:embed data/cluster-templates/gcp-gke.yaml
CAPIGCPGKE []byte

//go:embed data/cluster-templates/azure-aks-topology.yaml
CAPIAzureAKSTopology []byte

Expand Down Expand Up @@ -162,6 +165,7 @@ const (

CapaEncodedCredentialsVar = "CAPA_ENCODED_CREDS"
CapgEncodedCredentialsVar = "CAPG_ENCODED_CREDS"
GCPProjectVar = "GCP_PROJECT"
AzureSubIDVar = "AZURE_SUBSCRIPTION_ID"
AzureClientIDVar = "AZURE_CLIENT_ID"
AzureClientSecretVar = "AZURE_CLIENT_SECRET"
Expand Down
59 changes: 59 additions & 0 deletions test/e2e/data/cluster-templates/gcp-gke.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
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"
controlPlaneVersion: "${KUBERNETES_VERSION}"
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachinePool
metadata:
name: "${CLUSTER_NAME}-mp-0"
spec:
clusterName: "${CLUSTER_NAME}"
replicas: 3 # regional cluster means we need to use a multiple of 3
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: {}
1 change: 1 addition & 0 deletions test/e2e/specs/import_gitops_mgmtv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ func CreateMgmtV3UsingGitOpsSpec(ctx context.Context, inputGetter func() CreateM
"CLUSTER_CLASS_NAME": fmt.Sprintf("%s-class", input.ClusterName),
"WORKER_MACHINE_COUNT": strconv.Itoa(workerMachineCount),
"CONTROL_PLANE_MACHINE_COUNT": strconv.Itoa(controlPlaneMachineCount),
"GCP_PROJECT": input.E2EConfig.GetVariable(e2e.GCPProjectVar),
}
for k, v := range input.AdditionalTemplateVariables {
additionalVars[k] = v
Expand Down
32 changes: 32 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,35 @@ 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,
}
})
})

0 comments on commit 49070ee

Please sign in to comment.