Skip to content

Commit 52bc265

Browse files
authored
ROX-28980: add tenant restore operation to e2e tests (#2288)
* add restore operation to e2e tests
1 parent f8b1774 commit 52bc265

File tree

7 files changed

+213
-122
lines changed

7 files changed

+213
-122
lines changed

.secrets.baseline

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@
259259
"filename": "e2e/e2e_test.go",
260260
"hashed_secret": "7f38822bc2b03e97325ff310099f457f6f788daf",
261261
"is_verified": false,
262-
"line_number": 293
262+
"line_number": 289
263263
}
264264
],
265265
"internal/dinosaur/pkg/api/public/api/openapi.yaml": [
@@ -312,7 +312,7 @@
312312
"filename": "pkg/client/fleetmanager/mocks/client_moq.go",
313313
"hashed_secret": "44e17306b837162269a410204daaa5ecee4ec22c",
314314
"is_verified": false,
315-
"line_number": 746
315+
"line_number": 760
316316
}
317317
],
318318
"pkg/client/redhatsso/api/api/openapi.yaml": [
@@ -416,5 +416,5 @@
416416
}
417417
]
418418
},
419-
"generated_at": "2025-04-14T16:46:27Z"
419+
"generated_at": "2025-04-15T08:25:28Z"
420420
}

e2e/e2e_test.go

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,6 @@ var _ = Describe("Central", Ordered, func() {
240240
Expect(putGitopsConfig(ctx, cfg)).To(Succeed())
241241
})
242242

243-
// TODO(ROX-11368): Add test to eventually reach ready state
244-
// TODO(ROX-11368): create test to check that Central and Scanner are healthy
245-
// TODO(ROX-11368): Create test to check Central is correctly exposed
246-
247243
It("should restore secrets and deployment on namespace delete", func() {
248244
// Using managedDB false here because e2e don't run with managed postgresql
249245
secretBackup := k8s.NewSecretBackup(k8sClient, false)
@@ -442,6 +438,48 @@ var _ = Describe("Central", Ordered, func() {
442438
WithPolling(defaultPolling).
443439
Should(BeEmpty(), "Started at %s", time.Now())
444440
})
441+
442+
It("should be restorable", func() {
443+
By("calling the admin restore API", func() {
444+
res, err := adminAPI.RestoreCentral(ctx, centralRequestID)
445+
Expect(err).To(Not(HaveOccurred()))
446+
Expect(res.StatusCode).To(Equal(200))
447+
})
448+
449+
By("reaching ready state", func() {
450+
Eventually(testutil.AssertCentralRequestReady(ctx, client, centralRequestID)).
451+
WithTimeout(waitTimeout).
452+
WithPolling(defaultPolling).
453+
Should(Succeed())
454+
})
455+
})
456+
457+
It("should delete restored resources", func() {
458+
459+
By("calling the delete API", func() {
460+
Expect(deleteCentralByID(ctx, client, centralRequestID)).To(Succeed())
461+
})
462+
463+
By("removing central namespace", func() {
464+
Eventually(assertNamespaceDeleted(ctx, namespaceName)).
465+
WithTimeout(waitTimeout).
466+
WithPolling(defaultPolling).
467+
Should(Succeed())
468+
})
469+
470+
By("deleting external DNS entries", func() {
471+
testutil.SkipIf(!dnsEnabled, testutil.SkipDNSMsg)
472+
var centralRequest public.CentralRequest
473+
Expect(testutil.GetCentralRequest(ctx, client, centralRequestID, &centralRequest)).
474+
To(Succeed())
475+
dnsRecordsLoader := dns.NewRecordsLoader(route53Client, centralRequest)
476+
Eventually(dnsRecordsLoader.LoadDNSRecords).
477+
WithTimeout(waitTimeout).
478+
WithPolling(defaultPolling).
479+
Should(BeEmpty(), "Started at %s", time.Now())
480+
})
481+
})
482+
445483
})
446484

447485
Describe("should be deployed and can be force-deleted", Ordered, func() {

internal/dinosaur/pkg/api/admin/private/api/openapi.yaml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/dinosaur/pkg/api/admin/private/api_default.go

Lines changed: 115 additions & 115 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openapi/fleet-manager-private-admin.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ paths:
346346
$ref: 'fleet-manager.yaml#/components/schemas/Error'
347347
'/api/rhacs/v1/admin/centrals/{id}/restore':
348348
post:
349+
operationId: restoreCentral
349350
summary: Restore a central tenant that was already deleted
350351
parameters:
351352
- $ref: "fleet-manager.yaml#/components/parameters/id"

pkg/client/fleetmanager/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type AdminAPI interface {
3737
CentralRotateSecrets(ctx context.Context, id string, centralRotateSecretsRequest admin.CentralRotateSecretsRequest) (*http.Response, error)
3838
UpdateCentralNameById(ctx context.Context, id string, centralUpdateNameRequest admin.CentralUpdateNameRequest) (admin.Central, *http.Response, error)
3939
AssignCentralCluster(ctx context.Context, id string, centralAssignClusterRequest admin.CentralAssignClusterRequest) (*http.Response, error)
40+
RestoreCentral(ctx context.Context, id string) (*http.Response, error)
4041
}
4142

4243
// Client is a helper struct that wraps around the API clients generated from

0 commit comments

Comments
 (0)