This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: move all patch generator unit tests to their own packages (#23)
* test: unit test for individual patch generator * test: package level unit test for HTTPProxy * test: move region and httpproxy patch generator unit test invocation * fix: linting errors * test: move all AWS patch unit tests to their own packages (#24) * test: move instanceprofile tests to its own package * test: move instancetype unit tests to its own package * test: move ami unit tests to its own package * test: move aws network tests to its own package * test: move controlplaneloadbalancer unit tests to its own package * test: move aws cni unit tests to its own package * test: fix linting errors * test: unit tests for AWS security groups * test: move customimage unit tests to their own package (#30) * test: move all Nutanix patch handler unit tests (#32) * test: move controlplane endpoint unit tests * test: move PC endpoint unit tests * test: nove machinedetails unit tests * test: move generic patch unit tests to own packages (#31) * test: move audit policy tests to their own package * test: move etcd unit tests to their own package * test: move extra api server cert sans to its own package * test: move image registry unit tests to its own package * test: move kubernetes image repository unit tests * test: move mirror unit tests * test: move users unit tests * test: remove gereric unit tests from nutanix meta patch handler * test: cleaned up meta level unit test suites
- Loading branch information
1 parent
5e7fe95
commit c6cdfba
Showing
46 changed files
with
1,775 additions
and
1,791 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
pkg/handlers/aws/mutation/ami/inject_control_plane_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Copyright 2023 D2iQ, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package ami | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
"github.com/onsi/gomega" | ||
runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1" | ||
|
||
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/api/v1alpha1" | ||
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation" | ||
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" | ||
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest/request" | ||
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" | ||
) | ||
|
||
var _ = Describe("Generate AMI patches for ControlPlane", func() { | ||
patchGenerator := func() mutation.GeneratePatches { | ||
return mutation.NewMetaGeneratePatchesHandler("", NewControlPlanePatch()).(mutation.GeneratePatches) | ||
} | ||
|
||
testDefs := []capitest.PatchTestDef{ | ||
{ | ||
Name: "AMI set for control plane", | ||
Vars: []runtimehooksv1.Variable{ | ||
capitest.VariableWithValue( | ||
clusterconfig.MetaVariableName, | ||
v1alpha1.AMISpec{ID: "ami-controlplane"}, | ||
clusterconfig.MetaControlPlaneConfigName, | ||
v1alpha1.AWSVariableName, | ||
VariableName, | ||
), | ||
}, | ||
RequestItem: request.NewCPAWSMachineTemplateRequestItem("1234"), | ||
ExpectedPatchMatchers: []capitest.JSONPatchMatcher{ | ||
{ | ||
Operation: "add", | ||
Path: "/spec/template/spec/ami/id", | ||
ValueMatcher: gomega.Equal("ami-controlplane"), | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "AMI lookup format set for control plane", | ||
Vars: []runtimehooksv1.Variable{ | ||
capitest.VariableWithValue( | ||
clusterconfig.MetaVariableName, | ||
v1alpha1.AMISpec{ | ||
Lookup: &v1alpha1.AMILookup{ | ||
Format: "test-{{.kubernetesVersion}}-format", | ||
Org: "1234", | ||
BaseOS: "testOS", | ||
}, | ||
}, | ||
clusterconfig.MetaControlPlaneConfigName, | ||
v1alpha1.AWSVariableName, | ||
VariableName, | ||
), | ||
}, | ||
RequestItem: request.NewCPAWSMachineTemplateRequestItem("1234"), | ||
ExpectedPatchMatchers: []capitest.JSONPatchMatcher{ | ||
{ | ||
Operation: "add", | ||
Path: "/spec/template/spec/imageLookupFormat", | ||
ValueMatcher: gomega.Equal("test-{{.kubernetesVersion}}-format"), | ||
}, | ||
{ | ||
Operation: "add", | ||
Path: "/spec/template/spec/imageLookupOrg", | ||
ValueMatcher: gomega.Equal("1234"), | ||
}, | ||
{ | ||
Operation: "add", | ||
Path: "/spec/template/spec/imageLookupBaseOS", | ||
ValueMatcher: gomega.Equal("testOS"), | ||
}, | ||
}, | ||
UnexpectedPatchMatchers: []capitest.JSONPatchMatcher{ | ||
{ | ||
Operation: "add", | ||
Path: "/spec/template/spec/ami/id", | ||
ValueMatcher: gomega.Equal(""), | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
// create test node for each case | ||
for testIdx := range testDefs { | ||
tt := testDefs[testIdx] | ||
It(tt.Name, func() { | ||
capitest.AssertGeneratePatches( | ||
GinkgoT(), | ||
patchGenerator, | ||
&tt, | ||
) | ||
}) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2023 D2iQ, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package ami | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestAMIPatch(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "AMI patches for ControlPlane and Workers suite") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.