Skip to content

Commit

Permalink
add spec documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvindthiru committed Oct 16, 2023
1 parent cb578ea commit 7039eff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/e2e/fleet_guard_rail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var _ = Describe("fleet guard rail tests for deny MC CREATE operations", func()
},
}

By("expecting denial of operation CREATE of member cluster")
By(fmt.Sprintf("expecting denial of operation CREATE of member cluster %s", mc.Name))
err := impersonateHubClient.Create(ctx, mc)
var statusErr *k8sErrors.StatusError
Expect(errors.As(err, &statusErr)).To(BeTrue(), fmt.Sprintf("Create member cluster call produced error %s. Error type wanted is %s.", reflect.TypeOf(err), reflect.TypeOf(&k8sErrors.StatusError{})))
Expand All @@ -67,10 +67,10 @@ var _ = Describe("fleet guard rail tests for allow/deny MC UPDATE, DELETE operat
var mc clusterv1beta1.MemberCluster
g.Expect(hubClient.Get(ctx, types.NamespacedName{Name: mcName}, &mc)).Should(Succeed())

By("update member cluster spec")
By(fmt.Sprintf("update member cluster spec for MC %s", mc.Name))
mc.Spec.HeartbeatPeriodSeconds = 30

By("expecting denial of operation UPDATE of member cluster")
By(fmt.Sprintf("expecting denial of operation UPDATE of member cluster %s", mc.Name))
err := impersonateHubClient.Update(ctx, &mc)
if k8sErrors.IsConflict(err) {
return err
Expand All @@ -89,7 +89,7 @@ var _ = Describe("fleet guard rail tests for allow/deny MC UPDATE, DELETE operat
},
}

By("expecting denial of operation DELETE of member cluster")
By(fmt.Sprintf("expecting denial of operation DELETE of member cluster %s", mc.Name))
err := impersonateHubClient.Delete(ctx, &mc)
var statusErr *k8sErrors.StatusError
Expect(errors.As(err, &statusErr)).To(BeTrue(), fmt.Sprintf("Delete member cluster call produced error %s. Error type wanted is %s.", reflect.TypeOf(err), reflect.TypeOf(&k8sErrors.StatusError{})))
Expand All @@ -98,7 +98,7 @@ var _ = Describe("fleet guard rail tests for allow/deny MC UPDATE, DELETE operat

It("should allow update operation on member cluster CR labels for any user", func() {
var mc clusterv1beta1.MemberCluster
By("update labels in member cluster, expecting successful UPDATE of member cluster")
By(fmt.Sprintf("update labels in member cluster %s, expecting successful UPDATE of member cluster", mcName))
Eventually(func(g Gomega) error {
g.Expect(hubClient.Get(ctx, types.NamespacedName{Name: mcName}, &mc)).Should(Succeed())
labels := make(map[string]string)
Expand All @@ -110,7 +110,7 @@ var _ = Describe("fleet guard rail tests for allow/deny MC UPDATE, DELETE operat

It("should allow update operation on member cluster CR annotations for any user", func() {
var mc clusterv1beta1.MemberCluster
By("update annotations in member cluster, expecting successful UPDATE of member cluster")
By(fmt.Sprintf("update annotations in member cluster %s, expecting successful UPDATE of member cluster", mcName))
Eventually(func(g Gomega) error {
g.Expect(hubClient.Get(ctx, types.NamespacedName{Name: mcName}, &mc)).Should(Succeed())
annotations := make(map[string]string)
Expand All @@ -122,7 +122,7 @@ var _ = Describe("fleet guard rail tests for allow/deny MC UPDATE, DELETE operat

It("should allow update operation on member cluster CR spec for user in system:masters group", func() {
var mc clusterv1beta1.MemberCluster
By("update spec of member cluster, expecting successful UPDATE of member cluster")
By(fmt.Sprintf("update spec of member cluster %s, expecting successful UPDATE of member cluster", mcName))
Eventually(func(g Gomega) error {
g.Expect(hubClient.Get(ctx, types.NamespacedName{Name: mcName}, &mc)).Should(Succeed())
mc.Spec.HeartbeatPeriodSeconds = 31
Expand All @@ -132,7 +132,7 @@ var _ = Describe("fleet guard rail tests for allow/deny MC UPDATE, DELETE operat

It("should allow update operation on member cluster CR status for user in system:masters group", func() {
var mc clusterv1beta1.MemberCluster
By("update status of member cluster, expecting successful UPDATE of member cluster")
By(fmt.Sprintf("update status of member cluster %s, expecting successful UPDATE of member cluster", mcName))
Eventually(func(g Gomega) error {
g.Expect(hubClient.Get(ctx, types.NamespacedName{Name: mcName}, &mc)).Should(Succeed())
g.Expect(mc.Status.Conditions).ToNot(BeEmpty())
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
rbacv1 "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -147,6 +148,7 @@ func deleteResourcesForFleetGuardRail() {

func createMemberClusterResource(name string) {
// Create the MC.
By(fmt.Sprintf("In MC BeforeAll %s", name))
mc := &clusterv1beta1.MemberCluster{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand All @@ -164,6 +166,7 @@ func createMemberClusterResource(name string) {
}

func deleteMemberClusterResource(name string) {
By(fmt.Sprintf("In MC AfterAll %s", name))
Eventually(func(g Gomega) error {
var mc clusterv1beta1.MemberCluster
err := hubClient.Get(ctx, types.NamespacedName{Name: name}, &mc)
Expand Down

0 comments on commit 7039eff

Please sign in to comment.