Skip to content

Commit

Permalink
integration test
Browse files Browse the repository at this point in the history
Signed-off-by: haoqing0110 <[email protected]>
  • Loading branch information
haoqing0110 committed Sep 24, 2024
1 parent 5a898f1 commit 77dd048
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 55 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module open-cluster-management.io/ocm

go 1.22.5

replace open-cluster-management.io/api => github.com/haoqing0110/api v0.0.0-20240920101950-b79b23b51797

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/evanphx/json-patch v5.9.0+incompatible
Expand Down Expand Up @@ -98,6 +96,7 @@ require (
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/sys/sequential v0.6.0 // indirect
github.com/moby/sys/user v0.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k=
github.com/haoqing0110/api v0.0.0-20240920101950-b79b23b51797 h1:tD02gj6DoUFS9FfGMloQjBrrQ3UTZz3Ey2oD9qAkf/4=
github.com/haoqing0110/api v0.0.0-20240920101950-b79b23b51797/go.mod h1:9erZEWEn4bEqh0nIX2wA7f/s3KCuFycQdBrPrRzi0QM=
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU=
github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
Expand Down Expand Up @@ -180,8 +178,8 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc=
github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo=
github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7zgvCU=
github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiTWd+lL+7b/Ko=
github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg=
github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU=
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
Expand Down Expand Up @@ -445,6 +443,8 @@ k8s.io/utils v0.0.0-20240310230437-4693a0247e57 h1:gbqbevonBh57eILzModw6mrkbwM0g
k8s.io/utils v0.0.0-20240310230437-4693a0247e57/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
open-cluster-management.io/addon-framework v0.10.1-0.20240703130731-ba7fd000a03a h1:La1cYE3xkPFS2OJnsPQbkkahKE7yabuPcIISRfb4qsg=
open-cluster-management.io/addon-framework v0.10.1-0.20240703130731-ba7fd000a03a/go.mod h1:C1VETu/CIQKYfMiVAgNzPEUHjCpL9P1Z/KsGhHa4kl4=
open-cluster-management.io/api v0.14.1-0.20240923014927-17751e4cfddb h1:waqo8IxjYIz5dQ71pDM2Qn7jcPYWrTwd6BC1xB0VWKE=
open-cluster-management.io/api v0.14.1-0.20240923014927-17751e4cfddb/go.mod h1:9erZEWEn4bEqh0nIX2wA7f/s3KCuFycQdBrPrRzi0QM=
open-cluster-management.io/sdk-go v0.14.1-0.20240918072645-225dcf1b6866 h1:nxYrSsYwl9Mq8DuaJ0K98PCpuGsai+AvXbggMfZDCGI=
open-cluster-management.io/sdk-go v0.14.1-0.20240918072645-225dcf1b6866/go.mod h1:jCyXPY900UK1n4xwUBWSz27s7lcXN/fhIDF6xu3jIHw=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.29.0 h1:/U5vjBbQn3RChhv7P11uhYvCSm5G2GaIi5AIGBS6r4c=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ func TestSyncDeploy(t *testing.T) {
}
}
// Check if resources are created as expected
testingcommon.AssertEqualNumber(t, len(createCRDObjects), 12)
testingcommon.AssertEqualNumber(t, len(createCRDObjects), 13)
}

func TestSyncDeployNoWebhook(t *testing.T) {
Expand Down Expand Up @@ -507,7 +507,7 @@ func TestSyncDeployNoWebhook(t *testing.T) {
}
}
// Check if resources are created as expected
testingcommon.AssertEqualNumber(t, len(createCRDObjects), 12)
testingcommon.AssertEqualNumber(t, len(createCRDObjects), 13)
}

// TestSyncDelete test cleanup hub deploy
Expand Down Expand Up @@ -546,7 +546,7 @@ func TestSyncDelete(t *testing.T) {
}
}
// Check if resources are created as expected
testingcommon.AssertEqualNumber(t, len(deleteCRDActions), 16)
testingcommon.AssertEqualNumber(t, len(deleteCRDActions), 17)

for _, action := range deleteKubeActions {
switch action.Resource.Resource {
Expand Down
21 changes: 11 additions & 10 deletions test/integration/operator/clustermanager_hosted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ var _ = ginkgo.Describe("ClusterManager Hosted Mode", func() {
if err != nil {
return err
}
if len(actual.Status.RelatedResources) != 41 {
return fmt.Errorf("should get 41 relatedResources, actual got %v, %v",
if len(actual.Status.RelatedResources) != 42 {
return fmt.Errorf("should get 42 relatedResources, actual got %v, %v",
len(actual.Status.RelatedResources), actual.Status.RelatedResources)
}
return nil
Expand Down Expand Up @@ -480,8 +480,8 @@ var _ = ginkgo.Describe("ClusterManager Hosted Mode", func() {
if err != nil {
return err
}
if len(actual.Status.RelatedResources) != 45 {
return fmt.Errorf("should get 45 relatedResources, actual got %v, %v",
if len(actual.Status.RelatedResources) != 46 {
return fmt.Errorf("should get 46 relatedResources, actual got %v, %v",
len(actual.Status.RelatedResources), actual.Status.RelatedResources)
}
return nil
Expand Down Expand Up @@ -694,8 +694,8 @@ var _ = ginkgo.Describe("ClusterManager Hosted Mode", func() {
if err != nil {
return err
}
if len(actual.Status.RelatedResources) != 40 {
return fmt.Errorf("should get 40 relatedResources, actual got %v, %v",
if len(actual.Status.RelatedResources) != 41 {
return fmt.Errorf("should get 41 relatedResources, actual got %v, %v",
len(actual.Status.RelatedResources), actual.Status.RelatedResources)
}
return nil
Expand Down Expand Up @@ -755,8 +755,8 @@ var _ = ginkgo.Describe("ClusterManager Hosted Mode", func() {
if err != nil {
return err
}
if len(actual.Status.RelatedResources) != 45 {
return fmt.Errorf("should get 45 relatedResources, actual got %v, %v", len(actual.Status.RelatedResources), actual.Status.RelatedResources)
if len(actual.Status.RelatedResources) != 46 {
return fmt.Errorf("should get 46 relatedResources, actual got %v, %v", len(actual.Status.RelatedResources), actual.Status.RelatedResources)
}
return nil
}, eventuallyTimeout, eventuallyInterval).ShouldNot(gomega.HaveOccurred())
Expand Down Expand Up @@ -830,8 +830,8 @@ var _ = ginkgo.Describe("ClusterManager Hosted Mode", func() {
if err != nil {
return err
}
if len(actual.Status.RelatedResources) != 45 {
return fmt.Errorf("should get 45 relatedResources, actual got %v", len(actual.Status.RelatedResources))
if len(actual.Status.RelatedResources) != 46 {
return fmt.Errorf("should get 46 relatedResources, actual got %v", len(actual.Status.RelatedResources))
}
return nil
}, eventuallyTimeout, eventuallyInterval).ShouldNot(gomega.HaveOccurred())
Expand Down Expand Up @@ -885,6 +885,7 @@ var _ = ginkgo.Describe("ClusterManager Hosted Mode", func() {
hubRegistrationDeployment, hubPlacementDeployment, hubRegistrationWebhookDeployment,
hubWorkWebhookDeployment, hubWorkControllerDeployment, hubAddonManagerDeployment)
})

ginkgo.It("Deployment should be reconciled when manually updated", func() {
gomega.Eventually(func() error {
registrationDeployment, err := hostedKubeClient.AppsV1().Deployments(hubNamespaceHosted).Get(hostedCtx, hubRegistrationDeployment, metav1.GetOptions{})
Expand Down
20 changes: 10 additions & 10 deletions test/integration/operator/clustermanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ var _ = ginkgo.Describe("ClusterManager Default Mode", func() {
if err != nil {
return err
}
if len(actual.Status.RelatedResources) != 41 {
return fmt.Errorf("should get 41 relatedResources, actual got %v, %v",
if len(actual.Status.RelatedResources) != 42 {
return fmt.Errorf("should get 42 relatedResources, actual got %v, %v",
len(actual.Status.RelatedResources), actual.Status.RelatedResources)
}
return nil
Expand Down Expand Up @@ -455,8 +455,8 @@ var _ = ginkgo.Describe("ClusterManager Default Mode", func() {
if err != nil {
return err
}
if len(actual.Status.RelatedResources) != 45 {
return fmt.Errorf("should get 45 relatedResources, actual got %v, %v",
if len(actual.Status.RelatedResources) != 46 {
return fmt.Errorf("should get 46 relatedResources, actual got %v, %v",
len(actual.Status.RelatedResources), actual.Status.RelatedResources)
}
return nil
Expand Down Expand Up @@ -667,8 +667,8 @@ var _ = ginkgo.Describe("ClusterManager Default Mode", func() {
if err != nil {
return err
}
if len(actual.Status.RelatedResources) != 40 {
return fmt.Errorf("should get 40 relatedResources, actual got %v", len(actual.Status.RelatedResources))
if len(actual.Status.RelatedResources) != 41 {
return fmt.Errorf("should get 41 relatedResources, actual got %v", len(actual.Status.RelatedResources))
}
return nil
}, eventuallyTimeout, eventuallyInterval).ShouldNot(gomega.HaveOccurred())
Expand Down Expand Up @@ -723,8 +723,8 @@ var _ = ginkgo.Describe("ClusterManager Default Mode", func() {
if err != nil {
return err
}
if len(actual.Status.RelatedResources) != 45 {
return fmt.Errorf("should get 45 relatedResources, actual got %v", len(actual.Status.RelatedResources))
if len(actual.Status.RelatedResources) != 46 {
return fmt.Errorf("should get 46 relatedResources, actual got %v", len(actual.Status.RelatedResources))
}
return nil
}, eventuallyTimeout, eventuallyInterval).ShouldNot(gomega.HaveOccurred())
Expand Down Expand Up @@ -794,8 +794,8 @@ var _ = ginkgo.Describe("ClusterManager Default Mode", func() {
if err != nil {
return err
}
if len(actual.Status.RelatedResources) != 45 {
return fmt.Errorf("should get 45 relatedResources, actual got %v", len(actual.Status.RelatedResources))
if len(actual.Status.RelatedResources) != 46 {
return fmt.Errorf("should get 46 relatedResources, actual got %v", len(actual.Status.RelatedResources))
}
return nil
}, eventuallyTimeout, eventuallyInterval).ShouldNot(gomega.HaveOccurred())
Expand Down
3 changes: 3 additions & 0 deletions test/integration/operator/klusterlet_mutiplehubs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ var _ = Describe("Deploy Klusterlet with Multiplehubs enabled", func() {
},
},
},
RegistrationDriver: operatorapiv1.RegistrationDriver{
AuthType: "csr",
},
},
DeployOption: operatorapiv1.KlusterletDeployOption{
Mode: operatorapiv1.InstallModeSingleton,
Expand Down
47 changes: 23 additions & 24 deletions test/integration/operator/klusterlet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ var _ = ginkgo.Describe("Klusterlet", func() {
},
ClusterName: "testcluster",
Namespace: klusterletNamespace,
RegistrationConfiguration: &operatorapiv1.RegistrationConfiguration{
RegistrationDriver: operatorapiv1.RegistrationDriver{
AuthType: "csr",
},
},
},
}

Expand Down Expand Up @@ -602,7 +607,7 @@ var _ = ginkgo.Describe("Klusterlet", func() {
return false
}
gomega.Expect(len(actual.Spec.Template.Spec.Containers)).Should(gomega.Equal(1))
gomega.Expect(len(actual.Spec.Template.Spec.Containers[0].Args)).Should(gomega.Equal(6))
gomega.Expect(len(actual.Spec.Template.Spec.Containers[0].Args)).Should(gomega.Equal(8))
return actual.Spec.Template.Spec.Containers[0].Args[2] == "--spoke-cluster-name=cluster2"
}, eventuallyTimeout, eventuallyInterval).Should(gomega.BeTrue())

Expand Down Expand Up @@ -978,9 +983,7 @@ var _ = ginkgo.Describe("Klusterlet", func() {
})

ginkgo.It("should set certDurationSeconds correctly", func() {
klusterlet.Spec.RegistrationConfiguration = &operatorapiv1.RegistrationConfiguration{
ClientCertExpirationSeconds: 120,
}
klusterlet.Spec.RegistrationConfiguration.ClientCertExpirationSeconds = 120

ginkgo.By("Create the klusterlet with valid RegistrationConfiguration")
_, err := operatorClient.OperatorV1().Klusterlets().Create(context.Background(),
Expand Down Expand Up @@ -1029,18 +1032,16 @@ var _ = ginkgo.Describe("Klusterlet", func() {
})

ginkgo.It("should be set correctly", func() {
klusterlet.Spec.RegistrationConfiguration = &operatorapiv1.RegistrationConfiguration{
FeatureGates: []operatorapiv1.FeatureGate{
{
Feature: string(ocmfeature.ClusterClaim),
Mode: operatorapiv1.FeatureGateModeTypeDisable,
},
},
ClusterAnnotations: map[string]string{
"foo": "bar", // should be ignored
"agent.open-cluster-management.io/foo": "bar",
klusterlet.Spec.RegistrationConfiguration.FeatureGates = []operatorapiv1.FeatureGate{
{
Feature: string(ocmfeature.ClusterClaim),
Mode: operatorapiv1.FeatureGateModeTypeDisable,
},
}
klusterlet.Spec.RegistrationConfiguration.ClusterAnnotations = map[string]string{
"foo": "bar", // should be ignored
"agent.open-cluster-management.io/foo": "bar",
}
klusterlet.Spec.WorkConfiguration = &operatorapiv1.WorkAgentConfiguration{
FeatureGates: []operatorapiv1.FeatureGate{
{
Expand Down Expand Up @@ -1111,16 +1112,14 @@ var _ = ginkgo.Describe("Klusterlet", func() {
})

ginkgo.It("has invalid feature gates", func() {
klusterlet.Spec.RegistrationConfiguration = &operatorapiv1.RegistrationConfiguration{
FeatureGates: []operatorapiv1.FeatureGate{
{
Feature: "Foo",
Mode: operatorapiv1.FeatureGateModeTypeDisable,
},
{
Feature: string(ocmfeature.ClusterClaim),
Mode: operatorapiv1.FeatureGateModeTypeDisable,
},
klusterlet.Spec.RegistrationConfiguration.FeatureGates = []operatorapiv1.FeatureGate{
{
Feature: "Foo",
Mode: operatorapiv1.FeatureGateModeTypeDisable,
},
{
Feature: string(ocmfeature.ClusterClaim),
Mode: operatorapiv1.FeatureGateModeTypeDisable,
},
}
klusterlet.Spec.WorkConfiguration = &operatorapiv1.WorkAgentConfiguration{
Expand Down
5 changes: 3 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ github.com/mitchellh/copystructure
# github.com/mitchellh/reflectwalk v1.0.2
## explicit
github.com/mitchellh/reflectwalk
# github.com/moby/sys/sequential v0.6.0
## explicit; go 1.17
# github.com/moby/sys/user v0.1.0
## explicit; go 1.17
# github.com/mochi-mqtt/server/v2 v2.6.5
Expand Down Expand Up @@ -1528,7 +1530,7 @@ open-cluster-management.io/addon-framework/pkg/agent
open-cluster-management.io/addon-framework/pkg/assets
open-cluster-management.io/addon-framework/pkg/index
open-cluster-management.io/addon-framework/pkg/utils
# open-cluster-management.io/api v0.14.1-0.20240923014927-17751e4cfddb => github.com/haoqing0110/api v0.0.0-20240920101950-b79b23b51797
# open-cluster-management.io/api v0.14.1-0.20240923014927-17751e4cfddb
## explicit; go 1.22.0
open-cluster-management.io/api/addon/v1alpha1
open-cluster-management.io/api/client/addon/clientset/versioned
Expand Down Expand Up @@ -1728,4 +1730,3 @@ sigs.k8s.io/structured-merge-diff/v4/value
## explicit; go 1.12
sigs.k8s.io/yaml
sigs.k8s.io/yaml/goyaml.v2
# open-cluster-management.io/api => github.com/haoqing0110/api v0.0.0-20240920101950-b79b23b51797

0 comments on commit 77dd048

Please sign in to comment.