diff --git a/api-tests/tests/database-cluster-restores.spec.ts b/api-tests/tests/database-cluster-restores.spec.ts index f80ff21f..250a92ce 100644 --- a/api-tests/tests/database-cluster-restores.spec.ts +++ b/api-tests/tests/database-cluster-restores.spec.ts @@ -55,25 +55,43 @@ test('create/update/delete database cluster restore', async ({request, page}) => }) expect(response.ok()).toBeTruthy() - const restore = await response.json() + let restore = await response.json() expect(restore.spec).toMatchObject(payloadRestore.spec) await page.waitForTimeout(2000) + response = await request.get(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`) + expect(response.ok()).toBeTruthy() + + if (! response.ok()) { + console.log("!2") + console.log(await response.json()) + } + restore = await response.json() + // update restore restore.spec.dbClusterName = clName2 response = await request.put(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`, { data: restore, }) + + if (! response.ok()) { + console.log("!3") + console.log(await response.json()) + } expect(response.ok()).toBeTruthy() - const result = await response.json() + let result = await response.json() expect(result.spec).toMatchObject(restore.spec) + response = await request.get(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`) + expect(response.ok()).toBeTruthy() + result = await response.json() + // update restore with not existing dbClusterName - restore.spec.dbClusterName = 'not-existing-cluster' + result.spec.dbClusterName = 'not-existing-cluster' response = await request.put(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`, { - data: restore, + data: result, }) expect(response.status()).toBe(400) expect(await response.text()).toContain('{"message":"DatabaseCluster \'not-existing-cluster\' is not found"}') diff --git a/api-tests/tests/helpers.ts b/api-tests/tests/helpers.ts index 282417d4..3327d1a0 100644 --- a/api-tests/tests/helpers.ts +++ b/api-tests/tests/helpers.ts @@ -2,7 +2,7 @@ import {APIRequestContext, expect} from '@playwright/test' // testPrefix is used to differentiate between several workers // running this test to avoid conflicts in instance names -const testSuffix = () => `${(Math.random() + 1).toString(36).substring(10)}` +const testSuffix = () => `${(Math.random() + 1).toString(36).substring(8)}` export const randomName = (prefix = "rnd") => { return `${prefix}-${testSuffix()}` diff --git a/api-tests/tests/psmdb-clusters.spec.ts b/api-tests/tests/psmdb-clusters.spec.ts index 37b84e37..ccc8620d 100644 --- a/api-tests/tests/psmdb-clusters.spec.ts +++ b/api-tests/tests/psmdb-clusters.spec.ts @@ -68,6 +68,7 @@ test('create/edit/delete single node psmdb cluster', async ({ request, page }) = await request.post(`/v1/kubernetes/${kubernetesId}/database-clusters`, { data: psmdbPayload, }) + let result for (let i = 0; i < 15; i++) { await page.waitForTimeout(1000) @@ -75,7 +76,7 @@ test('create/edit/delete single node psmdb cluster', async ({ request, page }) = expect(psmdbCluster.ok()).toBeTruthy() - const result = (await psmdbCluster.json()) + result = (await psmdbCluster.json()) if (typeof result.status === 'undefined' || typeof result.status.size === 'undefined') { continue @@ -85,23 +86,22 @@ test('create/edit/delete single node psmdb cluster', async ({ request, page }) = expect(result.spec).toMatchObject(psmdbPayload.spec) expect(result.status.size).toBe(1) - // psmdbPayload should be overriden because kubernetes adds data into metadata field - // and uses metadata.generation during updation. It returns 422 HTTP status code if this field is not present - // - // kubectl under the hood merges everything hence the UX is seemless - psmdbPayload.spec = result.spec - psmdbPayload.metadata = result.metadata break } + psmdbPayload.metadata.resourceVersion = result.metadata.resourceVersion psmdbPayload.spec.engine.config = 'operationProfiling:\nmode: slowOp' // Update PSMDB cluster - const updatedPSMDBCluster = await request.put(`/v1/kubernetes/${kubernetesId}/database-clusters/${clusterName}`, { data: psmdbPayload, }) + if (! updatedPSMDBCluster.ok()) { + console.log("!3") + console.log(await updatedPSMDBCluster.json()) + } + expect(updatedPSMDBCluster.ok()).toBeTruthy() let psmdbCluster = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clusterName}`) @@ -151,6 +151,7 @@ test('expose psmdb cluster after creation', async ({ request, page }) => { data: psmdbPayload, }) + let result for (let i = 0; i < 15; i++) { await page.waitForTimeout(1000) @@ -158,7 +159,7 @@ test('expose psmdb cluster after creation', async ({ request, page }) => { expect(psmdbCluster.ok()).toBeTruthy() - const result = (await psmdbCluster.json()) + result = (await psmdbCluster.json()) if (typeof result.status === 'undefined' || typeof result.status.size === 'undefined') { continue @@ -167,12 +168,10 @@ test('expose psmdb cluster after creation', async ({ request, page }) => { expect(result.metadata.name).toBe(clusterName) expect(result.spec).toMatchObject(psmdbPayload.spec) expect(result.status.size).toBe(3) - - psmdbPayload.spec = result.spec - psmdbPayload.metadata = result.metadata break } + psmdbPayload.metadata.resourceVersion = result.metadata.resourceVersion psmdbPayload.spec.proxy.expose.type = 'external' // Update PSMDB cluster @@ -181,6 +180,11 @@ test('expose psmdb cluster after creation', async ({ request, page }) => { data: psmdbPayload, }) + if (! updatedPSMDBCluster.ok()) { + console.log("!1") + console.log(await updatedPSMDBCluster.json()) + } + expect(updatedPSMDBCluster.ok()).toBeTruthy() let psmdbCluster = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clusterName}`) @@ -230,7 +234,7 @@ test('expose psmdb cluster on EKS to the public internet and scale up', async ({ data: psmdbPayload, }) for (let i = 0; i < 15; i++) { - await page.waitForTimeout(2000) + await page.waitForTimeout(3000) const psmdbCluster = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clusterName}`)