Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖 Sync from open-cluster-management-io/config-policy-controller: #141 #510

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions test/e2e/case18_discovery_refresh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
. "github.com/onsi/gomega"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"

"open-cluster-management.io/config-policy-controller/test/utils"
Expand Down Expand Up @@ -61,21 +62,38 @@ var _ = Describe("Test discovery info refresh", Ordered, func() {

By("Checking that the API causes an error during API discovery")
Eventually(
func() error {
cmd := exec.Command("kubectl", "api-resources")

err := cmd.Start()
if err != nil {
return nil // Just retry. If this consistently has an error, the test should fail.
func(g Gomega) {
apiService := utils.GetWithTimeout(
clientManagedDynamic,
gvrAPIService,
"v1beta1.pizza.example.com",
"",
true,
defaultTimeoutSeconds,
)

apiStatus, _, err := unstructured.NestedSlice(apiService.Object, "status", "conditions")
g.Expect(err).ToNot(HaveOccurred())
g.Expect(apiStatus).ToNot(BeEmpty())

statusFound := false
for _, status := range apiStatus {
if status, ok := status.(map[string]interface{}); ok {
if status["type"] == "Available" {
g.Expect(status["status"]).To(Equal("False"))
g.Expect(status["reason"]).To(Equal("ServiceNotFound"))
statusFound = true
}
}
}

err = cmd.Wait()

return err
if !statusFound {
Fail("Failed to find 'Available' status for APIService")
}
},
defaultTimeoutSeconds,
1,
).ShouldNot(BeNil())
).Should(Succeed())

By("Creating the prerequisites on managed")
// This needs to be wrapped in an eventually since the object can't be created immediately after the CRD
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
kubeconfigManaged string
clientManaged kubernetes.Interface
clientManagedDynamic dynamic.Interface
gvrAPIService schema.GroupVersionResource
gvrConfigPolicy schema.GroupVersionResource
gvrCRD schema.GroupVersionResource
gvrPod schema.GroupVersionResource
Expand Down Expand Up @@ -71,6 +72,11 @@ var _ = BeforeSuite(func() {
Version: "v1",
Resource: "configurationpolicies",
}
gvrAPIService = schema.GroupVersionResource{
Group: "apiregistration.k8s.io",
Version: "v1",
Resource: "apiservices",
}
gvrCRD = schema.GroupVersionResource{
Group: "apiextensions.k8s.io",
Version: "v1",
Expand Down