-
Notifications
You must be signed in to change notification settings - Fork 13
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
ROX-21867: e2e tests #1661
base: main
Are you sure you want to change the base?
ROX-21867: e2e tests #1661
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,102 @@ | ||||||
package e2e | ||||||
|
||||||
import ( | ||||||
"context" | ||||||
"net/http" | ||||||
"os" | ||||||
"time" | ||||||
|
||||||
. "github.com/onsi/ginkgo/v2" | ||||||
. "github.com/onsi/gomega" | ||||||
|
||||||
"github.com/stackrox/acs-fleet-manager/internal/dinosaur/pkg/api/admin/private" | ||||||
"github.com/stackrox/acs-fleet-manager/pkg/client/fleetmanager" | ||||||
fmImpl "github.com/stackrox/acs-fleet-manager/pkg/client/fleetmanager/impl" | ||||||
) | ||||||
|
||||||
var _ = Describe("central traits", Ordered, func() { | ||||||
|
||||||
var client *fleetmanager.Client | ||||||
var adminAPI fleetmanager.AdminAPI | ||||||
var notes []string | ||||||
var ctx = context.Background() | ||||||
|
||||||
BeforeEach(func() { | ||||||
SkipIf(!runCentralTests, "Skipping Central tests") | ||||||
Expect(restoreDefaultGitopsConfig()).To(Succeed()) | ||||||
|
||||||
option := fmImpl.OptionFromEnv() | ||||||
auth, err := fmImpl.NewStaticAuth(context.Background(), fmImpl.StaticOption{StaticToken: option.Static.StaticToken}) | ||||||
Expect(err).ToNot(HaveOccurred()) | ||||||
client, err = fmImpl.NewClient(fleetManagerEndpoint, auth) | ||||||
Expect(err).ToNot(HaveOccurred()) | ||||||
|
||||||
adminStaticToken := os.Getenv("STATIC_TOKEN_ADMIN") | ||||||
adminAuth, err := fmImpl.NewStaticAuth(context.Background(), fmImpl.StaticOption{StaticToken: adminStaticToken}) | ||||||
Expect(err).ToNot(HaveOccurred()) | ||||||
adminClient, err := fmImpl.NewClient(fleetManagerEndpoint, adminAuth) | ||||||
Expect(err).ToNot(HaveOccurred()) | ||||||
adminAPI = adminClient.AdminAPI() | ||||||
|
||||||
GinkgoWriter.Printf("Current time: %s\n", time.Now().String()) | ||||||
printNotes(notes) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like |
||||||
}) | ||||||
|
||||||
It("should manage traits", func() { | ||||||
central, _, err := adminAPI.CreateCentral(ctx, true, private.CentralRequestPayload{ | ||||||
CloudProvider: dpCloudProvider, | ||||||
MultiAz: true, | ||||||
Name: newCentralName(), | ||||||
Region: dpRegion, | ||||||
}) | ||||||
Expect(err).Should(Succeed()) | ||||||
id := central.Id | ||||||
|
||||||
Eventually(assertCentralRequestProvisioning(ctx, client, id)). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does it matter to us in this test whether central will be provisioned or not? |
||||||
WithTimeout(waitTimeout). | ||||||
WithPolling(defaultPolling). | ||||||
Should(Succeed()) | ||||||
|
||||||
defer adminAPI.DeleteDbCentralById(ctx, id) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we test whether it is possible to add trait to deleted central? |
||||||
|
||||||
traits, _, err := adminAPI.GetCentralTraits(ctx, id) | ||||||
Expect(err).ToNot(HaveOccurred(), "no error on no traits") | ||||||
Expect(traits).To(BeEmpty(), "no traits yet") | ||||||
|
||||||
_, err = adminAPI.PutCentralTrait(ctx, id, "test-trait") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: let's rename to |
||||||
Expect(err).ToNot(HaveOccurred(), "no error on adding test-trait") | ||||||
|
||||||
traits, _, err = adminAPI.GetCentralTraits(ctx, id) | ||||||
Expect(err).ToNot(HaveOccurred(), "no error on having traits") | ||||||
Expect(traits).To(BeEquivalentTo([]string{"test-trait"}), "test-trait should be found") | ||||||
|
||||||
_, err = adminAPI.PutCentralTrait(ctx, id, "test-trait-1") | ||||||
Expect(err).ToNot(HaveOccurred(), "no error on adding test-trait-1") | ||||||
|
||||||
_, err = adminAPI.PutCentralTrait(ctx, id, "test-trait-1") | ||||||
Expect(err).ToNot(HaveOccurred(), "no error on adding test-trait-1 twice") | ||||||
|
||||||
traits, _, err = adminAPI.GetCentralTraits(ctx, id) | ||||||
Expect(err).ToNot(HaveOccurred(), "no error on having multiple traits") | ||||||
Expect(traits).To(BeEquivalentTo([]string{"test-trait", "test-trait-1"}), "should have only two traits") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
_, err = adminAPI.GetCentralTrait(ctx, id, "test-trait") | ||||||
Expect(err).ToNot(HaveOccurred(), "no error on checking for existing trait") | ||||||
|
||||||
resp, err := adminAPI.GetCentralTrait(ctx, id, "test-trait-2") | ||||||
Expect(err).To(HaveOccurred(), "error on checking for non-existing trait") | ||||||
if Expect(resp).NotTo(BeNil()) { | ||||||
Expect(resp.StatusCode == http.StatusNotFound).To(BeTrue()) | ||||||
} | ||||||
|
||||||
_, err = adminAPI.DeleteCentralTrait(ctx, id, "test-trait") | ||||||
Expect(err).ToNot(HaveOccurred(), "no error on deleting test-trait") | ||||||
|
||||||
_, err = adminAPI.DeleteCentralTrait(ctx, id, "test-trait") | ||||||
Expect(err).ToNot(HaveOccurred(), "no error on deleting non-existing trait") | ||||||
|
||||||
traits, _, err = adminAPI.GetCentralTraits(ctx, id) | ||||||
Expect(err).ToNot(HaveOccurred(), "no error on retreiving traits") | ||||||
Expect(traits).To(BeEquivalentTo([]string{"test-trait-1"}), "should have only one trait now") | ||||||
}) | ||||||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: let's align with `e2e_test.go