Skip to content

Commit

Permalink
Merge pull request #3688 from Azure/tsatam/hotfix-add-cpms-e2e-test
Browse files Browse the repository at this point in the history
Add cpms e2e test
  • Loading branch information
mociarain authored Jul 17, 2024
2 parents eec4b7a + 5058657 commit 28ced68
Show file tree
Hide file tree
Showing 575 changed files with 50,175 additions and 117 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ require (
github.com/open-policy-agent/frameworks/constraint v0.0.0-20221109005544-7de84dff5081
github.com/opencontainers/runtime-spec v1.1.1-0.20230922153023-c0e90434df2a
github.com/openshift/api v0.0.0-20240103200955-7ca3a4634e46
github.com/openshift/client-go v0.0.0-20220525160904-9e1acff93e4a
github.com/openshift/client-go v0.0.0-20221019143426-16aed247da5c
github.com/openshift/cloud-credential-operator v0.0.0-00010101000000-000000000000
github.com/openshift/hive/apis v0.0.0-20240627073933-b1ac27b24815
github.com/openshift/library-go v0.0.0-20220525173854-9b950a41acdc
Expand Down Expand Up @@ -1589,7 +1589,7 @@ replace (
replace (
github.com/googleapis/gnostic => github.com/google/gnostic v0.5.5
github.com/openshift/api => github.com/openshift/api v0.0.0-20240103200955-7ca3a4634e46
github.com/openshift/client-go => github.com/openshift/client-go v0.0.0-20220603133046-984ee5ebedcf
github.com/openshift/client-go => github.com/openshift/client-go v0.0.0-20221019143426-16aed247da5c
github.com/openshift/cloud-credential-operator => github.com/openshift/cloud-credential-operator v0.0.0-20200316201045-d10080b52c9e
github.com/openshift/hive/apis => github.com/openshift/hive/apis v0.0.0-20231116161336-9dd47f8bfa1f
github.com/openshift/library-go => github.com/openshift/library-go v0.0.0-20230222114049-eac44a078a6e
Expand Down
12 changes: 2 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,6 @@ github.com/cyberphone/json-canonicalization v0.0.0-20231011164504-785e29786b46 h
github.com/cyberphone/json-canonicalization v0.0.0-20231011164504-785e29786b46/go.mod h1:uzvlm1mxhHkdfqitSA92i7Se+S9ksOn3a3qmv/kyOCw=
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
github.com/dave/dst v0.26.2/go.mod h1:UMDJuIRPfyUCC78eFuB+SV/WI8oDeyFDvM/JR6NI3IU=
github.com/dave/gopackages v0.0.0-20170318123100-46e7023ec56e/go.mod h1:i00+b/gKdIDIxuLDFob7ustLAVqhsZRk2qVZrArELGQ=
github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg=
github.com/dave/kerr v0.0.0-20170318121727-bc25dd6abe8e/go.mod h1:qZqlPyPvfsDJt+3wHJ1EvSXDuVjFTK0j2p/ca+gtsb8=
github.com/dave/rebecca v0.9.1/go.mod h1:N6XYdMD/OKw3lkF3ywh8Z6wPGuwNFDNtWYEMFWEmXBA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -352,7 +347,6 @@ github.com/honeycombio/beeline-go v1.10.0 h1:cUDe555oqvw8oD76BQJ8alk7FP0JZ/M/zXp
github.com/honeycombio/libhoney-go v1.16.0 h1:kPpqoz6vbOzgp7jC6SR7SkNj7rua7rgxvznI6M3KdHc=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
Expand Down Expand Up @@ -512,8 +506,8 @@ github.com/opencontainers/selinux v1.11.0 h1:+5Zbo97w3Lbmb3PeqQtpmTkMwsW5nRI3YaL
github.com/opencontainers/selinux v1.11.0/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec=
github.com/openshift/api v0.0.0-20240103200955-7ca3a4634e46 h1:mnrBzHjjqYKw2uinOVXL9Eplj3+QaQwJ3SaWAs8l6cc=
github.com/openshift/api v0.0.0-20240103200955-7ca3a4634e46/go.mod h1:aQ6LDasvHMvHZXqLHnX2GRmnfTWCF/iIwz8EMTTIE9A=
github.com/openshift/client-go v0.0.0-20220603133046-984ee5ebedcf h1:gAYYPWVduONFJ6yuczLleApk0nEH3W0GgxDX2+O+B9E=
github.com/openshift/client-go v0.0.0-20220603133046-984ee5ebedcf/go.mod h1:eDO5QeVi2IiXmDwB0e2z1DpAznWroZKe978pzZwFBzg=
github.com/openshift/client-go v0.0.0-20221019143426-16aed247da5c h1:CV76yFOTXmq9VciBR3Bve5ZWzSxdft7gaMVB3kS0rwg=
github.com/openshift/client-go v0.0.0-20221019143426-16aed247da5c/go.mod h1:lFMO8mLHXWFzSdYvGNo8ivF9SfF6zInA8ZGw4phRnUE=
github.com/openshift/cloud-credential-operator v0.0.0-20200316201045-d10080b52c9e h1:2gyl9UVyjHSWzdS56KUXxQwIhENbq2x2olqoMQSA/C8=
github.com/openshift/cloud-credential-operator v0.0.0-20200316201045-d10080b52c9e/go.mod h1:iPn+uhIe7nkP5BMHe2QnbLtg5m/AIQ1xvz9s3cig5ss=
github.com/openshift/custom-resource-status v1.1.3-0.20220503160415-f2fdb4999d87 h1:cHyxR+Y8rAMT6m1jQCaYGRwikqahI0OjjUDhFNf3ySQ=
Expand Down Expand Up @@ -574,7 +568,6 @@ github.com/secure-systems-lab/go-securesystemslib v0.7.0 h1:OwvJ5jQf9LnIAS83waAj
github.com/secure-systems-lab/go-securesystemslib v0.7.0/go.mod h1:/2gYnlnHVQ6xeGtfIqFy7Do03K4cdCY0A/GlJLDKLHI=
github.com/serge1peshcoff/selenium-go-conditions v0.0.0-20170824121757-5afbdb74596b h1:jLwzNAxsHzKw5sHju7bUk0iQSynZxWAOtnXD5d37Vto=
github.com/serge1peshcoff/selenium-go-conditions v0.0.0-20170824121757-5afbdb74596b/go.mod h1:noHZFMVoy0oY+ICCojiGUgv+/ecK+1M6huoUVWAIJoU=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sigstore/fulcio v1.4.3 h1:9JcUCZjjVhRF9fmhVuz6i1RyhCc/EGCD7MOl+iqCJLQ=
Expand Down Expand Up @@ -709,7 +702,6 @@ gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI=
gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/src-d/go-billy.v4 v4.3.0/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
Expand Down
57 changes: 44 additions & 13 deletions pkg/util/mocks/samples/samples.go

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

54 changes: 54 additions & 0 deletions test/e2e/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ import (
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/to"
configv1 "github.com/openshift/api/config/v1"
machinev1 "github.com/openshift/api/machine/v1"
machinev1beta1 "github.com/openshift/api/machine/v1beta1"
cov1Helpers "github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers"
mcv1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1"
"github.com/ugorji/go/codec"
corev1 "k8s.io/api/core/v1"
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/discovery"
"k8s.io/client-go/util/retry"
"sigs.k8s.io/yaml"

Expand Down Expand Up @@ -719,3 +721,55 @@ var _ = Describe("ARO Operator - Cloud Provider Config ConfigMap", func() {
}).WithContext(ctx).WithTimeout(DefaultEventuallyTimeout).Should(Succeed())
})
})

var _ = Describe("ARO Operator - Control Plane MachineSets", func() {
const (
cpmsEnabled = operator.CPMSEnabled
)

getCpmsOrNil := func(ctx context.Context, name string, options metav1.GetOptions) (*machinev1.ControlPlaneMachineSet, error) {
cpms, err := clients.MachineAPI.MachineV1().ControlPlaneMachineSets("openshift-machine-api").Get(ctx, name, options)
if err != nil && !kerrors.IsNotFound(err) {
return nil, err
}
return cpms, nil
}

BeforeEach(func(ctx context.Context) {
if err := discovery.ServerSupportsVersion(clients.Kubernetes.Discovery(), machinev1.GroupVersion); err != nil {
Skip("Cluster does not support machinev1 API, CPMS controller not present")
}
})

It("should ensure CPMS is Inactive", func(ctx context.Context) {
By("checking whether CPMS is disabled in ARO operator config")
instance, err := clients.AROClusters.AroV1alpha1().Clusters().Get(ctx, "cluster", metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())

if instance.Spec.OperatorFlags.GetSimpleBoolean(cpmsEnabled) {
Skip("CPMS is enabled (controller disabled), skipping test")
}

By("checking whether CPMS is set to Inactive")

cpms := GetK8sObjectWithRetry(ctx, getCpmsOrNil, "cluster", metav1.GetOptions{})
Expect(cpms).To(Or(
BeNil(),
HaveField("Spec.State", Equal(machinev1.ControlPlaneMachineSetStateInactive)),
))

if cpms != nil {
By("ensuring CPMS is reset to Inactive if enabled")
cpms.Spec.State = machinev1.ControlPlaneMachineSetStateActive
Eventually(func(g Gomega, ctx context.Context) {
_, err := clients.MachineAPI.MachineV1().ControlPlaneMachineSets("openshift-machine-api").Update(ctx, cpms, metav1.UpdateOptions{})
g.Expect(err).NotTo(HaveOccurred())
}).WithContext(ctx).WithTimeout(DefaultEventuallyTimeout).Should(Succeed())

Eventually(func(g Gomega, ctx context.Context) {
cpms := GetK8sObjectWithRetry(ctx, getCpmsOrNil, "cluster", metav1.GetOptions{})
g.Expect(cpms).To(HaveField("Spec.State", Equal(machinev1.ControlPlaneMachineSetStateInactive)))
}).WithContext(ctx).WithTimeout(DefaultEventuallyTimeout).Should(Succeed())
}
})
})

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

3 changes: 3 additions & 0 deletions vendor/github.com/openshift/api/config/v1alpha1/Makefile

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

8 changes: 8 additions & 0 deletions vendor/github.com/openshift/api/config/v1alpha1/doc.go

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

Loading

0 comments on commit 28ced68

Please sign in to comment.