Skip to content

Commit

Permalink
Add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
joekr committed Jan 24, 2023
1 parent dbdec76 commit d8e7ec8
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 6 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ generate-e2e-templates: $(KUSTOMIZE)
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta1/cluster-template-remote-vcn-peering --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta1/cluster-template-remote-vcn-peering.yaml
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta1/cluster-template-externally-managed-vcn --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta1/cluster-template-externally-managed-vcn.yaml
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta1/cluster-template-machine-pool --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta1/cluster-template-machine-pool.yaml
$(KUSTOMIZE) build $(OCI_TEMPLATES)/v1beta1/cluster-template-windows-calico --load-restrictor LoadRestrictionsNone > $(OCI_TEMPLATES)/v1beta1/cluster-template-windows-calico.yaml

.PHONY: test-e2e-run
test-e2e-run: generate-e2e-templates $(GINKGO) $(ENVSUBST) ## Run e2e tests
Expand Down
1 change: 0 additions & 1 deletion cloud/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,6 @@ func (m *MachineScope) getGetControlPlaneMachineNSGs() []string {
// and returns the subnet ID if the name matches
func (m *MachineScope) getMachineSubnet(name string) (*string, error) {
for _, subnet := range m.OCICluster.Spec.NetworkSpec.Vcn.Subnets {
// if a subnet name is defined, use the correct subnet
if subnet.Name == name {
return subnet.ID, nil
}
Expand Down
4 changes: 1 addition & 3 deletions cloud/scope/vnic_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func (m *MachineScope) ReconcileVnicAttachments(ctx context.Context) error {
for index, vnicAttachment := range m.OCIMachine.Spec.VnicAttachments {
if m.vnicAttachmentExists(ctx, vnicAttachment) {
m.Logger.Info("vnicAttachment", vnicAttachment.DisplayName, " already exists")
// TODO: update vs create https://docs.oracle.com/en-us/iaas/api/#/en/iaas/20160918/Vnic/UpdateVnic
m.updateVnicAttachment(ctx, vnicAttachment)
continue
}
Expand All @@ -31,9 +30,8 @@ func (m *MachineScope) ReconcileVnicAttachments(ctx context.Context) error {
m.Logger.Error(err, msg)
return err
}
// TODO: kick off the "flush" so ids are stored as soon as they are attached

m.OCIMachine.Spec.VnicAttachments[index].VnicAttachmentId = vnicId
vnicAttachment.VnicAttachmentId = common.String("TESTING")
}

return nil
Expand Down
15 changes: 15 additions & 0 deletions cloud/services/compute/mock_compute/client_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions cloud/services/vcn/mock_vcn/client_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions templates/cluster-template-windows-calico.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Cluster
metadata:
labels:
cluster.x-k8s.io/cluster-name: "${CLUSTER_NAME}"
cni: flannel
cni: calico
csi-proxy: enabled
windows: enabled
name: "${CLUSTER_NAME}"
Expand Down Expand Up @@ -58,7 +58,6 @@ spec:
certSANs: [localhost, 127.0.0.1]
extraArgs:
cloud-provider: oci
feature-gates: WindowsHostProcessContainers=true
dns: {}
etcd: {}
networking: {}
Expand Down
50 changes: 50 additions & 0 deletions test/e2e/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,29 @@ var _ = Describe("Workload cluster creation", func() {
validateOLImage(namespace.Name, clusterName)
})

It("Windows - With 1 Linux control-plane nodes and with 1 Windows worker nodes", func() {
clusterName = getClusterName(clusterNamePrefix, "windows-calico")
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
ClusterProxy: bootstrapClusterProxy,
ConfigCluster: clusterctl.ConfigClusterInput{
LogFolder: filepath.Join(artifactFolder, "clusters", bootstrapClusterProxy.GetName()),
ClusterctlConfigPath: clusterctlConfigPath,
KubeconfigPath: bootstrapClusterProxy.GetKubeconfigPath(),
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
Flavor: "windows-calico",
Namespace: namespace.Name,
ClusterName: clusterName,
KubernetesVersion: e2eConfig.GetVariable(capi_e2e.KubernetesVersion),
ControlPlaneMachineCount: pointer.Int64Ptr(1),
WorkerMachineCount: pointer.Int64Ptr(1),
},
WaitForClusterIntervals: e2eConfig.GetIntervals(specName, "wait-cluster"),
WaitForControlPlaneIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"),
WaitForMachineDeployments: e2eConfig.GetIntervals(specName, "wait-windows-worker-nodes"),
}, result)
validateWindowsImage(namespace.Name, clusterName)
})

It("Cloud Provider OCI testing [PRBlocking]", func() {
clusterName = getClusterName(clusterNamePrefix, "ccm-testing")
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
Expand Down Expand Up @@ -960,6 +983,33 @@ func validateOLImage(nameSpace string, clusterName string) {
}
}

func validateWindowsImage(nameSpace string, clusterName string) {
lister := bootstrapClusterProxy.GetClient()
inClustersNamespaceListOption := client.InNamespace(nameSpace)
matchClusterListOption := client.MatchingLabels{
clusterv1.ClusterLabelName: clusterName,
}

machineList := &clusterv1.MachineList{}
Expect(lister.List(context.Background(), machineList, inClustersNamespaceListOption, matchClusterListOption)).
To(Succeed(), "Couldn't list machines for the cluster %q", clusterName)

Expect(len(machineList.Items)).To(Equal(2))
for _, machine := range machineList.Items {
if machine.Labels["os"] == "windows" {
instanceOcid := strings.Split(*machine.Spec.ProviderID, "//")[1]
Log(fmt.Sprintf("Instance OCID is %s", instanceOcid))
resp, err := computeClient.GetInstance(context.Background(), core.GetInstanceRequest{
InstanceId: common.String(instanceOcid),
})
Expect(err).NotTo(HaveOccurred())
instanceSourceDetails, ok := resp.SourceDetails.(core.InstanceSourceViaImageDetails)
Expect(ok).To(BeTrue())
Expect(*instanceSourceDetails.ImageId).To(Equal(os.Getenv("OCI_WINDOWS_IMAGE_ID")))
}
}
}

func getClusterName(prefix, specName string) string {
clusterName := os.Getenv("CLUSTER_NAME")
if clusterName == "" {
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/config/e2e_conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ providers:
- sourcePath: "../data/infrastructure-oci/v1beta1/cluster-template-remote-vcn-peering.yaml"
- sourcePath: "../data/infrastructure-oci/v1beta1/cluster-template-externally-managed-vcn.yaml"
- sourcePath: "../data/infrastructure-oci/v1beta1/cluster-template-machine-pool.yaml"
- sourcePath: "../data/infrastructure-oci/v1beta1/cluster-template-windows-calico.yaml"
- sourcePath: "../data/infrastructure-oci/v1beta1/metadata.yaml"

variables:
Expand Down Expand Up @@ -106,6 +107,7 @@ intervals:
default/wait-cluster: ["30m", "10s"]
default/wait-control-plane: ["30m", "10s"]
default/wait-worker-nodes: ["30m", "10s"]
default/wait-windows-worker-nodes: ["60m", "30s"]
default/wait-cluster-bare-metal: [ "60m", "10s" ]
default/wait-control-plane-bare-metal: [ "60m", "10s" ]
default/wait-worker-nodes-bare-metal: [ "60m", "10s" ]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bases:
- ../bases/cluster.yaml
- ../bases/md.yaml
- ../bases/crs.yaml
- ../bases/ccm.yaml
patchesStrategicMerge:
- ./md.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: OCIMachineTemplate
metadata:
name: "${CLUSTER_NAME}-md-0"
labels:
os: windows
spec:
template:
spec:
imageId: "${OCI_WINDOWS_IMAGE_ID}"
shape: "BM.Standard.E4.128"
shapeConfig:
ocpus: "128"
vnicAttachments:
- displayName: "CalicoNic"
nicIndex: 1 # second nic must be used for hyper-v
isPvEncryptionInTransitEnabled: ${OCI_NODE_PV_TRANSIT_ENCRYPTION=false}
---
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha4
kind: KubeadmConfigTemplate
metadata:
name: "${CLUSTER_NAME}-md-0"
spec:
template:
spec:
joinConfiguration:
nodeRegistration:
criSocket: npipe:////./pipe/containerd-containerd
kubeletExtraArgs:
provider-id: oci://{{ ds.meta_data["instance_id"] }}
feature-gates: WindowsHostProcessContainers=true
v: "2"
windows-priorityclass: ABOVE_NORMAL_PRIORITY_CLASS
name: '{{ ds.meta_data["local_hostname"] }}'
preKubeadmCommands:
- powershell C:\Windows\Setup\Scripts\enable_second_nic.ps1
- powershell C:\Users\opc\attach_secondary_vnic.ps1 > C:\Users\opc\attach_secondary_vnic_log.txt
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: "${CLUSTER_NAME}-md-0"
spec:
template:
spec:
failureDomain: "2"

0 comments on commit d8e7ec8

Please sign in to comment.