diff --git a/e2e/channel/crud_lifecycle.go b/e2e/channel/crud_lifecycle.go index d929476..f09bac4 100644 --- a/e2e/channel/crud_lifecycle.go +++ b/e2e/channel/crud_lifecycle.go @@ -12,7 +12,7 @@ import ( ) var _ = ginkgo.Describe("[Suite: channel][crud] Channel CRUD Lifecycle", - ginkgo.Label(labels.Tier1), + ginkgo.Label(labels.Tier0), func() { var h *helper.Helper var channelID string @@ -87,6 +87,23 @@ var _ = ginkgo.Describe("[Suite: channel][crud] Channel CRUD Lifecycle", Expect(fetched.Spec["is_default"]).To(Equal(true)) }) + ginkgo.It("should update channel labels via PATCH", func(ctx context.Context) { + ginkgo.By("patching channel labels") + patched, err := h.Client.PatchChannel(ctx, channelID, client.ResourcePatchRequest{ + Labels: map[string]string{ + "crud": channelID, + }, + }) + Expect(err).NotTo(HaveOccurred(), "failed to patch channel") + Expect(patched.Generation).To(Equal(int32(2)), "generation should increment after PATCH") + + ginkgo.By("verifying patched labels via GET") + fetched, err := h.Client.ListChannels(ctx, "labels.crud='"+channelID+"'") + Expect(err).NotTo(HaveOccurred()) + Expect(fetched.Items).To(HaveLen(1), "should have 1 channel") + Expect(fetched.Items[0].Id).To(HaveValue(Equal(channelID))) + }) + ginkgo.It("should delete channel", func(ctx context.Context) { ginkgo.By("deleting channel") deleted, err := h.Client.DeleteChannel(ctx, channelID) diff --git a/e2e/version/crud_lifecycle.go b/e2e/version/crud_lifecycle.go index 5bbf9b5..4ffa7c3 100644 --- a/e2e/version/crud_lifecycle.go +++ b/e2e/version/crud_lifecycle.go @@ -12,7 +12,7 @@ import ( ) var _ = ginkgo.Describe("[Suite: version][crud] Version CRUD Lifecycle", - ginkgo.Label(labels.Tier1), + ginkgo.Label(labels.Tier0), func() { var h *helper.Helper var channelID string @@ -98,6 +98,23 @@ var _ = ginkgo.Describe("[Suite: version][crud] Version CRUD Lifecycle", Expect(fetched.Spec["raw_version"]).To(Equal("4.18.0")) }) + ginkgo.It("should update version labels via PATCH", func(ctx context.Context) { + ginkgo.By("patching version labels") + patched, err := h.Client.PatchVersion(ctx, channelID, versionID, client.ResourcePatchRequest{ + Labels: map[string]string{ + "crud": versionID, + }, + }) + Expect(err).NotTo(HaveOccurred(), "failed to patch version") + Expect(patched.Generation).To(Equal(int32(2)), "generation should increment after PATCH") + + ginkgo.By("verifying patched labels via LIST") + fetched, err := h.Client.ListVersions(ctx, channelID, "labels.crud='"+versionID+"'") + Expect(err).NotTo(HaveOccurred()) + Expect(fetched.Items).To(HaveLen(1), "should have 1 version") + Expect(fetched.Items[0].Id).To(HaveValue(Equal(versionID))) + }) + ginkgo.It("should delete version", func(ctx context.Context) { ginkgo.By("deleting version") deleted, err := h.Client.DeleteVersion(ctx, channelID, versionID) diff --git a/e2e/version/filtering.go b/e2e/version/filtering.go deleted file mode 100644 index 426236b..0000000 --- a/e2e/version/filtering.go +++ /dev/null @@ -1,110 +0,0 @@ -package version - -import ( - "context" - - "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" //nolint:staticcheck // dot import for test readability - - "github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/client" - "github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/helper" - "github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/labels" -) - -var _ = ginkgo.Describe("[Suite: version][filtering] Version Spec Filtering", - ginkgo.Label(labels.Tier1), - func() { - var h *helper.Helper - var channelID string - var versionDefault *client.Resource - var versionEnabled *client.Resource - var versionDisabled *client.Resource - - ginkgo.BeforeEach(func(ctx context.Context) { - h = helper.New() - - ginkgo.By("creating parent channel") - ch, err := h.Client.CreateChannelFromPayload(ctx, h.TestDataPath("payloads/channels/channel-request.json")) - Expect(err).NotTo(HaveOccurred(), "failed to create channel") - Expect(ch.Id).NotTo(BeNil(), "channel ID should not be nil") - channelID = *ch.Id - - ginkgo.DeferCleanup(func(ctx context.Context) { - if err := h.CleanupTestChannel(ctx, channelID); err != nil { - ginkgo.GinkgoWriter.Printf("Warning: failed to cleanup channel %s: %v\n", channelID, err) - } - }) - - ginkgo.By("creating version with is_default=true, enabled=true") - versionDefault, err = h.Client.CreateVersion(ctx, channelID, client.ResourceCreateRequest{ - Kind: "Version", - Name: "ver-default-true", - Spec: map[string]any{ - "is_default": true, - "enabled": true, - "raw_version": "4.17.0", - "release_image": "quay.io/openshift-release-dev/ocp-release:4.17.0", - }, - }) - Expect(err).NotTo(HaveOccurred()) - - ginkgo.By("creating version with is_default=false, enabled=true") - versionEnabled, err = h.Client.CreateVersion(ctx, channelID, client.ResourceCreateRequest{ - Kind: "Version", - Name: "ver-enabled-only", - Spec: map[string]any{ - "is_default": false, - "enabled": true, - "raw_version": "4.17.1", - "release_image": "quay.io/openshift-release-dev/ocp-release:4.17.1", - }, - }) - Expect(err).NotTo(HaveOccurred()) - - ginkgo.By("creating version with is_default=false, enabled=false") - versionDisabled, err = h.Client.CreateVersion(ctx, channelID, client.ResourceCreateRequest{ - Kind: "Version", - Name: "ver-disabled", - Spec: map[string]any{ - "is_default": false, - "enabled": false, - "raw_version": "4.16.0", - "release_image": "quay.io/openshift-release-dev/ocp-release:4.16.0", - }, - }) - Expect(err).NotTo(HaveOccurred()) - }) - - ginkgo.It("should filter versions by spec.is_default='true'", func(ctx context.Context) { - ginkgo.By("listing versions with spec.is_default filter") - list, err := h.Client.ListVersions(ctx, channelID, "spec.is_default='true'") - Expect(err).NotTo(HaveOccurred(), "failed to list filtered versions") - - ids := extractResourceIDs(list.Items) - Expect(ids).To(ContainElement(*versionDefault.Id), "is_default=true version should be in results") - Expect(ids).NotTo(ContainElement(*versionEnabled.Id), "is_default=false version should not be in results") - Expect(ids).NotTo(ContainElement(*versionDisabled.Id), "disabled version should not be in results") - }) - - ginkgo.It("should filter versions by spec.enabled='true'", func(ctx context.Context) { - ginkgo.By("listing versions with spec.enabled filter") - list, err := h.Client.ListVersions(ctx, channelID, "spec.enabled='true'") - Expect(err).NotTo(HaveOccurred(), "failed to list filtered versions") - - ids := extractResourceIDs(list.Items) - Expect(ids).To(ContainElement(*versionDefault.Id), "default version should be in results") - Expect(ids).To(ContainElement(*versionEnabled.Id), "enabled version should be in results") - Expect(ids).NotTo(ContainElement(*versionDisabled.Id), "disabled version should not be in results") - }) - }, -) - -func extractResourceIDs(resources []client.Resource) []string { - ids := make([]string, 0, len(resources)) - for _, r := range resources { - if r.Id != nil { - ids = append(ids, *r.Id) - } - } - return ids -} diff --git a/e2e/version/uniqueness.go b/e2e/version/uniqueness.go deleted file mode 100644 index 1b460cd..0000000 --- a/e2e/version/uniqueness.go +++ /dev/null @@ -1,100 +0,0 @@ -package version - -import ( - "context" - "errors" - "net/http" - - "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" //nolint:staticcheck // dot import for test readability - - "github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/client" - "github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/helper" - "github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/labels" -) - -var _ = ginkgo.Describe("[Suite: version][uniqueness] Version Name Uniqueness Per Channel", - ginkgo.Label(labels.Tier1, labels.Negative), - func() { - var h *helper.Helper - var channelAID string - var channelBID string - - ginkgo.BeforeEach(func(ctx context.Context) { - h = helper.New() - - ginkgo.By("creating channel A") - chA, err := h.Client.CreateChannelFromPayload(ctx, h.TestDataPath("payloads/channels/channel-request.json")) - Expect(err).NotTo(HaveOccurred(), "failed to create channel A") - Expect(chA.Id).NotTo(BeNil(), "channel A ID should not be nil") - channelAID = *chA.Id - - ginkgo.By("creating channel B") - chB, err := h.Client.CreateChannelFromPayload(ctx, h.TestDataPath("payloads/channels/channel-request.json")) - Expect(err).NotTo(HaveOccurred(), "failed to create channel B") - Expect(chB.Id).NotTo(BeNil(), "channel B ID should not be nil") - channelBID = *chB.Id - - ginkgo.DeferCleanup(func(ctx context.Context) { - for _, id := range []string{channelAID, channelBID} { - if err := h.CleanupTestChannel(ctx, id); err != nil { - ginkgo.GinkgoWriter.Printf("Warning: failed to cleanup channel %s: %v\n", id, err) - } - } - }) - }) - - ginkgo.It("should allow same version name in different channels", func(ctx context.Context) { - sharedName := "shared-version-name" - spec := map[string]any{ - "enabled": true, - "raw_version": "4.17.0", - "release_image": "quay.io/openshift-release-dev/ocp-release:4.17.0", - } - - ginkgo.By("creating version with shared name in channel A") - _, err := h.Client.CreateVersion(ctx, channelAID, client.ResourceCreateRequest{ - Kind: "Version", - Name: sharedName, - Spec: spec, - }) - Expect(err).NotTo(HaveOccurred(), "version in channel A should succeed") - - ginkgo.By("creating version with same name in channel B") - _, err = h.Client.CreateVersion(ctx, channelBID, client.ResourceCreateRequest{ - Kind: "Version", - Name: sharedName, - Spec: spec, - }) - Expect(err).NotTo(HaveOccurred(), "version with same name in different channel should succeed") - }) - - ginkgo.It("should reject duplicate version name in same channel", func(ctx context.Context) { - duplicateName := "duplicate-version" - spec := map[string]any{ - "enabled": true, - "raw_version": "4.17.0", - "release_image": "quay.io/openshift-release-dev/ocp-release:4.17.0", - } - - ginkgo.By("creating first version") - _, err := h.Client.CreateVersion(ctx, channelAID, client.ResourceCreateRequest{ - Kind: "Version", - Name: duplicateName, - Spec: spec, - }) - Expect(err).NotTo(HaveOccurred(), "first version should succeed") - - ginkgo.By("attempting to create second version with same name in same channel") - _, err = h.Client.CreateVersion(ctx, channelAID, client.ResourceCreateRequest{ - Kind: "Version", - Name: duplicateName, - Spec: spec, - }) - var httpErr *client.HTTPError - Expect(errors.As(err, &httpErr)).To(BeTrue(), "error should be HTTPError") - Expect(httpErr.StatusCode).To(Equal(http.StatusConflict), - "duplicate version name in same channel should return 409") - }) - }, -)