From a7b0eba7449b2c3f551c923921c1c237ba677371 Mon Sep 17 00:00:00 2001 From: Oksana Grishchenko Date: Mon, 2 Oct 2023 13:02:44 +0200 Subject: [PATCH 01/10] fix monitoring & backup storages --- api-tests/tests/backup-storages.spec.ts | 18 +- .../tests/database-cluster-backups.spec.ts | 24 +-- .../tests/database-cluster-restores.spec.ts | 32 +-- api-tests/tests/helpers.ts | 190 +++++++++++------- api-tests/tests/kubernetes.spec.ts | 89 ++++---- api-tests/tests/monitoring-instances.spec.ts | 112 ++++------- 6 files changed, 236 insertions(+), 229 deletions(-) diff --git a/api-tests/tests/backup-storages.spec.ts b/api-tests/tests/backup-storages.spec.ts index e213c41d..67afd57f 100644 --- a/api-tests/tests/backup-storages.spec.ts +++ b/api-tests/tests/backup-storages.spec.ts @@ -13,11 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. import { expect, test } from '@fixtures' +import * as th from './helpers' -let req test('add/list/get/delete backup storage success', async ({ request }) => { - req = request const payload = { type: 's3', name: 'backup-storage-1', @@ -93,8 +92,6 @@ test('add/list/get/delete backup storage success', async ({ request }) => { }) test('create backup storage failures', async ({ request }) => { - req = request - const testCases = [ { payload: {}, @@ -157,10 +154,10 @@ test('create backup storage failures', async ({ request }) => { }) test('update backup storage failures', async ({ request }) => { - req = request + const name = th.randomName() const createPayload = { type: 's3', - name: 'backup-storage-2', + name: name, bucketName: 'percona-test-backup-storage', region: 'us-east-2', accessKey: 'sdfsdfs', @@ -171,9 +168,6 @@ test('update backup storage failures', async ({ request }) => { }) expect(response.ok()).toBeTruthy() - const created = await response.json() - - const name = created.name const testCases = [ { @@ -201,7 +195,7 @@ test('update backup storage failures', async ({ request }) => { }) test('update: backup storage not found', async ({ request }) => { - const name = 'some-storage' + const name = th.randomName() const response = await request.patch(`/v1/backup-storages/${name}`, { data: { @@ -213,7 +207,7 @@ test('update: backup storage not found', async ({ request }) => { }) test('delete: backup storage not found', async ({ request }) => { - const name = 'backup-storage' + const name = th.randomName() const response = await request.delete(`/v1/backup-storages/${name}`) @@ -221,7 +215,7 @@ test('delete: backup storage not found', async ({ request }) => { }) test('get: backup storage not found', async ({ request }) => { - const name = 'backup-storage' + const name = th.randomName() const response = await request.get(`/v1/backup-storages/${name}`) expect(response.status()).toBe(404) diff --git a/api-tests/tests/database-cluster-backups.spec.ts b/api-tests/tests/database-cluster-backups.spec.ts index caeb13f7..9797d3fa 100644 --- a/api-tests/tests/database-cluster-backups.spec.ts +++ b/api-tests/tests/database-cluster-backups.spec.ts @@ -24,13 +24,13 @@ test.beforeAll(async ({ request }) => { }) test('create/delete database cluster backups', async ({ request }) => { - const bsName = th.suffixedName('storage') - const clName = th.suffixedName('cluster') + const bsName = th.randomName('storage') + const clName = th.randomName('cluster') await th.createBackupStorage(request, bsName) await th.createDBCluster(request, kubernetesId, clName) - const backupName = th.suffixedName('backup') + const backupName = th.randomName('backup') const payload = { apiVersion: 'everest.percona.com/v1alpha1', @@ -61,11 +61,11 @@ test('create/delete database cluster backups', async ({ request }) => { }) test('dbcluster not found', async ({ request }) => { - const bsName = th.suffixedName('storage') + const bsName = th.randomName('storage') await th.createBackupStorage(request, bsName) - const backupName = th.suffixedName('backup') + const backupName = th.randomName('backup') const payload = { apiVersion: 'everest.percona.com/v1alpha1', kind: 'DatabaseClusterBackup', @@ -90,18 +90,18 @@ test('dbcluster not found', async ({ request }) => { }) test('list backups', async ({ request, page }) => { - const bsName = th.suffixedName('storage') - const clusterName1 = th.suffixedName('cluster1') - const clusterName2 = th.suffixedName('cluster2') + const bsName = th.randomName('storage') + const clusterName1 = th.randomName('cluster1') + const clusterName2 = th.randomName('cluster2') await th.createBackupStorage(request, bsName) await th.createDBCluster(request, kubernetesId, clusterName1) await th.createDBCluster(request, kubernetesId, clusterName2) - const backupName1 = th.suffixedName('backup1') - const backupName2 = th.suffixedName('backup2') - const backupName3 = th.suffixedName('backup3') - const backupName4 = th.suffixedName('backup4') + const backupName1 = th.randomName('backup1') + const backupName2 = th.randomName('backup2') + const backupName3 = th.randomName('backup3') + const backupName4 = th.randomName('backup4') const payloads = [ { diff --git a/api-tests/tests/database-cluster-restores.spec.ts b/api-tests/tests/database-cluster-restores.spec.ts index 7f8891f9..45126834 100644 --- a/api-tests/tests/database-cluster-restores.spec.ts +++ b/api-tests/tests/database-cluster-restores.spec.ts @@ -24,17 +24,17 @@ test.beforeAll(async ({ request }) => { }) test('create/update/delete database cluster restore', async ({ request }) => { - const bsName = th.suffixedName('storage') - const clName = th.suffixedName('cluster') - const clName2 = th.suffixedName('cluster2') - const backupName = th.suffixedName('backup') + const bsName = th.randomName('storage') + const clName = th.randomName('cluster') + const clName2 = th.randomName('cluster2') + const backupName = th.randomName('backup') await th.createBackupStorage(request, bsName) await th.createDBCluster(request, kubernetesId, clName) await th.createDBCluster(request, kubernetesId, clName2) await th.createBackup(request, kubernetesId, clName, backupName, bsName) - const restoreName = th.suffixedName('restore') + const restoreName = th.randomName('restore') const payloadRestore = { apiVersion: 'everest.percona.com/v1alpha1', @@ -90,19 +90,19 @@ test('create/update/delete database cluster restore', async ({ request }) => { }) test('list restores', async ({ request, page }) => { - const bsName = th.suffixedName('storage') - const clName1 = th.suffixedName('cluster1') - const clName2 = th.suffixedName('cluster2') - const backupName = th.suffixedName('backup') + const bsName = th.randomName('storage') + const clName1 = th.randomName('cluster1') + const clName2 = th.randomName('cluster2') + const backupName = th.randomName('backup') await th.createBackupStorage(request, bsName) await th.createDBCluster(request, kubernetesId, clName1) await th.createDBCluster(request, kubernetesId, clName2) await th.createBackup(request, kubernetesId, clName1, backupName, bsName) - const restoreName1 = th.suffixedName('restore1') - const restoreName2 = th.suffixedName('restore2') - const restoreName3 = th.suffixedName('restore3') + const restoreName1 = th.randomName('restore1') + const restoreName2 = th.randomName('restore2') + const restoreName3 = th.randomName('restore3') const payloads = [ { @@ -181,16 +181,16 @@ test('list restores', async ({ request, page }) => { }) test('create restore: validation errors', async ({ request, page }) => { - const bsName = th.suffixedName('storage') - const backupName = th.suffixedName('backup') - const clName = th.suffixedName('cl') + const bsName = th.randomName('storage') + const backupName = th.randomName('backup') + const clName = th.randomName('cl') await th.createBackupStorage(request, bsName) await th.createDBCluster(request, kubernetesId, clName) await th.createBackup(request, kubernetesId, clName, backupName, bsName) // dbcluster not found - const restoreName = th.suffixedName('restore') + const restoreName = th.randomName('restore') const payloadRestore = { apiVersion: 'everest.percona.com/v1alpha1', kind: 'DatabaseClusterRestore', diff --git a/api-tests/tests/helpers.ts b/api-tests/tests/helpers.ts index acf5e9ff..282417d4 100644 --- a/api-tests/tests/helpers.ts +++ b/api-tests/tests/helpers.ts @@ -1,104 +1,156 @@ -import { expect, test } from '@playwright/test' +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)}` -export const suffixedName = (name) => { - return `${name}-${testSuffix()}` +export const randomName = (prefix = "rnd") => { + return `${prefix}-${testSuffix()}` } export const createDBCluster = async (request, kubernetesId, name) => { - const data = { - apiVersion: 'everest.percona.com/v1alpha1', - kind: 'DatabaseCluster', - metadata: { - name, - }, - spec: { - engine: { - type: 'pxc', - replicas: 1, - storage: { - size: '4G', + const data = { + apiVersion: 'everest.percona.com/v1alpha1', + kind: 'DatabaseCluster', + metadata: { + name, }, - resources: { - cpu: '1', - memory: '1G', + spec: { + engine: { + type: 'pxc', + replicas: 1, + storage: { + size: '4G', + }, + resources: { + cpu: '1', + memory: '1G', + }, + }, + proxy: { + type: 'haproxy', + replicas: 1, + expose: { + type: 'internal', + }, + }, }, - }, - proxy: { - type: 'haproxy', - replicas: 1, - expose: { - type: 'internal', - }, - }, - }, - } + } - const postReq = await request.post(`/v1/kubernetes/${kubernetesId}/database-clusters`, { data }) + const postReq = await request.post(`/v1/kubernetes/${kubernetesId}/database-clusters`, {data}) - expect(postReq.ok()).toBeTruthy() + expect(postReq.ok()).toBeTruthy() } export const deleteDBCluster = async (request, kubernetesId, name) => { - const res = await request.delete(`/v1/kubernetes/${kubernetesId}/database-clusters/${name}`) + const res = await request.delete(`/v1/kubernetes/${kubernetesId}/database-clusters/${name}`) - expect(res.ok()).toBeTruthy() + expect(res.ok()).toBeTruthy() } export const createBackupStorage = async (request, name) => { - const storagePayload = { - type: 's3', - name, - url: 'http://custom-url', - description: 'Dev storage', - bucketName: 'percona-test-backup-storage', - region: 'us-east-2', - accessKey: 'sdfs', - secretKey: 'sdfsdfsd', - } - - const response = await request.post('/v1/backup-storages', { data: storagePayload }) - - expect(response.ok()).toBeTruthy() + const storagePayload = { + type: 's3', + name, + url: 'http://custom-url', + description: 'Dev storage', + bucketName: 'percona-test-backup-storage', + region: 'us-east-2', + accessKey: 'sdfs', + secretKey: 'sdfsdfsd', + } + + const response = await request.post('/v1/backup-storages', {data: storagePayload}) + + expect(response.ok()).toBeTruthy() } export const deleteBackupStorage = async (request, name) => { - const res = await request.delete(`/v1/backup-storages/${name}`) + const res = await request.delete(`/v1/backup-storages/${name}`) - expect(res.ok()).toBeTruthy() + expect(res.ok()).toBeTruthy() } export const createBackup = async (request, kubernetesId, clusterName, backupName, storageName) => { - const payloadBackup = { - apiVersion: 'everest.percona.com/v1alpha1', - kind: 'DatabaseClusterBackup', - metadata: { - name: backupName, - }, - spec: { - dbClusterName: clusterName, - backupStorageName: storageName, - }, - } - - const responseBackup = await request.post(`/v1/kubernetes/${kubernetesId}/database-cluster-backups`, { - data: payloadBackup, - }) - - expect(responseBackup.ok()).toBeTruthy() + const payloadBackup = { + apiVersion: 'everest.percona.com/v1alpha1', + kind: 'DatabaseClusterBackup', + metadata: { + name: backupName, + }, + spec: { + dbClusterName: clusterName, + backupStorageName: storageName, + }, + } + + const responseBackup = await request.post(`/v1/kubernetes/${kubernetesId}/database-cluster-backups`, { + data: payloadBackup, + }) + + expect(responseBackup.ok()).toBeTruthy() } export const deleteBackup = async (request, kubernetesId, backupName) => { - const res = await request.delete(`/v1/kubernetes/${kubernetesId}/database-cluster-backups/${backupName}`) + const res = await request.delete(`/v1/kubernetes/${kubernetesId}/database-cluster-backups/${backupName}`) - expect(res.ok()).toBeTruthy() + expect(res.ok()).toBeTruthy() } export const deleteRestore = async (request, kubernetesId, restoreName) => { - const res = await request.delete(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`) + const res = await request.delete(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`) + + expect(res.ok()).toBeTruthy() +} + +export const deleteMonitoringInstances = async (request, names) => { + for (let i = 0; i < names.length; i++) { + await deleteMonitoringInstance(request, names[i]) + } +} + +export const deleteMonitoringInstance = async (request, name) => { + const res = await request.delete(`/v1/monitoring-instances/${name}`) + expect(res.ok()).toBeTruthy() +} + + +export const createMonitoringInstance = async (request: APIRequestContext): Promise => { + const name = randomName() + const data = { + type: 'pmm', + name: name, + url: 'http://monitoring-instance', + pmm: { + apiKey: '123', + }, + } + + const response = await request.post('/v1/monitoring-instances', {data}) + expect(response.ok()).toBeTruthy() + + return name +} + +export const createMonitoringInstances = async (request: APIRequestContext, prefix: string, count = 3): Promise => { + const data = { + type: 'pmm', + name: '', + url: 'http://monitoring-instance', + pmm: { + apiKey: '123', + }, + } + + const res = [] + + for (let i = 1; i <= count; i++) { + data.name = randomName(prefix) + res.push(data.name) + const response = await request.post('/v1/monitoring-instances', {data}) + + expect(response.ok()).toBeTruthy() + } - expect(res.ok()).toBeTruthy() + return res } diff --git a/api-tests/tests/kubernetes.spec.ts b/api-tests/tests/kubernetes.spec.ts index 70758662..72e49c98 100644 --- a/api-tests/tests/kubernetes.spec.ts +++ b/api-tests/tests/kubernetes.spec.ts @@ -12,7 +12,9 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -import { test, expect } from '@fixtures' +import {expect, test} from '@fixtures' +import * as th from './helpers' + // testPrefix is used to differentiate between several workers // running this test to avoid conflicts in instance names @@ -20,64 +22,67 @@ const testPrefix = `${(Math.random() + 1).toString(36).substring(10)}` let kubernetesId -test.beforeAll(async ({ request }) => { - const kubernetesList = await request.get('/v1/kubernetes') +test.beforeAll(async ({request}) => { + const kubernetesList = await request.get('/v1/kubernetes') - kubernetesId = (await kubernetesList.json())[0].id + kubernetesId = (await kubernetesList.json())[0].id }) -test('get resource usage', async ({ request }) => { - const r = await request.get(`/v1/kubernetes/${kubernetesId}/resources`) - const resources = await r.json() +test('get resource usage', async ({request}) => { + const r = await request.get(`/v1/kubernetes/${kubernetesId}/resources`) + const resources = await r.json() - expect(r.ok()).toBeTruthy() + expect(r.ok()).toBeTruthy() - expect(resources).toBeTruthy() + expect(resources).toBeTruthy() - expect(resources?.capacity).toBeTruthy() - expect(resources?.available).toBeTruthy() + expect(resources?.capacity).toBeTruthy() + expect(resources?.available).toBeTruthy() }) -test('enable/disable cluster-monitoring', async ({ request }) => { - const data = { - type: 'pmm', - name: `${testPrefix}-monit`, - url: 'http://monitoring', - pmm: { - apiKey: '123', - }, - } +test('enable/disable cluster-monitoring', async ({request}) => { + const name = th.randomName() + const data = { + type: 'pmm', + name: name, + url: 'http://monitoring', + pmm: { + apiKey: '123', + }, + } + + const response = await request.post('/v1/monitoring-instances', {data}) - const response = await request.post('/v1/monitoring-instances', { data }) + expect(response.ok()).toBeTruthy() + const created = await response.json() - expect(response.ok()).toBeTruthy() - const created = await response.json() + const rEnable = await request.post(`/v1/kubernetes/${kubernetesId}/cluster-monitoring`, { + data: { + enable: true, + monitoringInstanceName: created.name, + }, + }) - const rEnable = await request.post(`/v1/kubernetes/${kubernetesId}/cluster-monitoring`, { - data: { - enable: true, - monitoringInstanceName: created.name, - }, - }) + expect(rEnable.ok()).toBeTruthy() - expect(rEnable.ok()).toBeTruthy() + const rDisable = await request.post(`/v1/kubernetes/${kubernetesId}/cluster-monitoring`, { + data: {enable: false}, + }) - const rDisable = await request.post(`/v1/kubernetes/${kubernetesId}/cluster-monitoring`, { - data: { enable: false }, - }) + expect(rDisable.ok()).toBeTruthy() - expect(rDisable.ok()).toBeTruthy() + await th.deleteMonitoringInstance(request, name) }) -test('get cluster info', async ({ request }) => { - const r = await request.get(`/v1/kubernetes/${kubernetesId}/cluster-info`) - const info = await r.json() +test('get cluster info', async ({request}) => { + const r = await request.get(`/v1/kubernetes/${kubernetesId}/cluster-info`) + const info = await r.json() - expect(r.ok()).toBeTruthy() + expect(r.ok()).toBeTruthy() - expect(info).toBeTruthy() + expect(info).toBeTruthy() - expect(info?.clusterType).toBeTruthy() - expect(info?.storageClassNames).toBeTruthy() - expect(info?.storageClassNames).toHaveLength(1) + expect(info?.clusterType).toBeTruthy() + expect(info?.storageClassNames).toBeTruthy() + expect(info?.storageClassNames).toHaveLength(1) }) diff --git a/api-tests/tests/monitoring-instances.spec.ts b/api-tests/tests/monitoring-instances.spec.ts index cb8b505d..1b7af4c6 100644 --- a/api-tests/tests/monitoring-instances.spec.ts +++ b/api-tests/tests/monitoring-instances.spec.ts @@ -15,28 +15,14 @@ import http from 'http' import { expect, test } from '@fixtures' import { APIRequestContext } from '@playwright/test' - -// testPrefix is used to differentiate between several workers -// running this test to avoid conflicts in instance names -const testPrefix = `${(Math.random() + 1).toString(36).substring(10)}` - -test.afterEach(async ({ request }, testInfo) => { - const result = await request.get('/v1/monitoring-instances') - const list = await result.json() - - for (const i of list) { - if (!i.name.includes(testPrefix)) { - continue - } - - await request.delete(`/v1/monitoring-instances/${i.name}`) - } -}) +import * as th from './helpers' +import {createMonitoringInstance, createMonitoringInstances} from "./helpers"; test('create monitoring instance with api key', async ({ request }) => { + let name = th.randomName() const data = { type: 'pmm', - name: `${testPrefix}-key`, + name: name, url: 'http://monitoring', pmm: { apiKey: '123', @@ -51,6 +37,8 @@ test('create monitoring instance with api key', async ({ request }) => { expect(created.name).toBe(data.name) expect(created.url).toBe(data.url) expect(created.type).toBe(data.type) + + await th.deleteMonitoringInstance(request, name) }) test('create monitoring instance with user/password', async ({ request }) => { @@ -68,9 +56,10 @@ test('create monitoring instance with user/password', async ({ request }) => { }) const port = s.address()?.port + let name = th.randomName() const data = { type: 'pmm', - name: `${testPrefix}-pass`, + name: name, url: `http://127.0.0.1:${port}`, pmm: { user: 'admin', @@ -86,6 +75,7 @@ test('create monitoring instance with user/password', async ({ request }) => { expect(created.name).toBe(data.name) expect(created.url).toBe(data.url) expect(created.type).toBe(data.type) + await th.deleteMonitoringInstance(request, name) } finally { server.closeAllConnections() await new Promise((resolve) => server.close(() => resolve())) @@ -152,22 +142,23 @@ test('create monitoring instance missing pmm credentials', async ({ request }) = }) test('list monitoring instances', async ({ request }) => { - const namePrefix = 'list-' + const testPrefix = th.randomName() - await createInstances(request, namePrefix) + const names = await th.createMonitoringInstances(request, testPrefix) const response = await request.get('/v1/monitoring-instances') expect(response.ok()).toBeTruthy() const list = await response.json() - expect(list.filter((i) => i.name.startsWith(`${namePrefix}${testPrefix}`)).length).toBe(3) + expect(list.filter((i) => i.name.startsWith(`${testPrefix}`)).length).toBe(3) + + + await th.deleteMonitoringInstances(request, names) }) test('get monitoring instance', async ({ request }) => { - const namePrefix = 'get-' - const names = await createInstances(request, namePrefix) - const name = names[1] + const name = await th.createMonitoringInstance(request) const response = await request.get(`/v1/monitoring-instances/${name}`) @@ -175,33 +166,21 @@ test('get monitoring instance', async ({ request }) => { const i = await response.json() expect(i.name).toBe(name) + await th.deleteMonitoringInstance(request, name) }) test('delete monitoring instance', async ({ request }) => { - const namePrefix = 'delete-' - const names = await createInstances(request, namePrefix) - const name = names[1] - - let response = await request.get('/v1/monitoring-instances') + const name = await createMonitoringInstance(request) + let response = await request.delete(`/v1/monitoring-instances/${name}`) expect(response.ok()).toBeTruthy() - let list = await response.json() - - expect(list.filter((i) => i.name.startsWith(`${namePrefix}${testPrefix}`)).length).toBe(3) - response = await request.delete(`/v1/monitoring-instances/${name}`) - expect(response.ok()).toBeTruthy() - - response = await request.get('/v1/monitoring-instances') - expect(response.ok()).toBeTruthy() - list = await response.json() - - expect(list.filter((i) => i.name.startsWith(`${namePrefix}${testPrefix}`)).length).toBe(2) + response = await request.get(`/v1/monitoring-instances/${name}`) + expect(response.status()).toBe(404) }) test('patch monitoring instance', async ({ request }) => { - const names = await createInstances(request, 'patch-monitoring-') - const name = names[1] + const name = await createMonitoringInstance(request) const response = await request.get(`/v1/monitoring-instances/${name}`) @@ -216,16 +195,15 @@ test('patch monitoring instance', async ({ request }) => { expect(getJson.url).toBe(patchData.url) expect(getJson.apiKeySecretId).toBe(created.apiKeySecretId) + await th.deleteMonitoringInstance(request, name) }) test('patch monitoring instance secret key changes', async ({ request }) => { - const names = await createInstances(request, 'patch-monitoring-') - const name = names[1] + const name = await createMonitoringInstance(request) const response = await request.get(`/v1/monitoring-instances/${name}`) expect(response.ok()).toBeTruthy() - const created = await response.json() const patchData = { url: 'http://monitoring2', @@ -239,11 +217,11 @@ test('patch monitoring instance secret key changes', async ({ request }) => { const getJson = await updated.json() expect(getJson.url).toBe(patchData.url) + await th.deleteMonitoringInstance(request, name) }) test('patch monitoring instance type updates properly', async ({ request }) => { - const names = await createInstances(request, 'patch-monitoring-') - const name = names[1] + const name = await createMonitoringInstance(request) const response = await request.get(`/v1/monitoring-instances/${name}`) @@ -258,12 +236,11 @@ test('patch monitoring instance type updates properly', async ({ request }) => { const updated = await request.patch(`/v1/monitoring-instances/${name}`, { data: patchData }) expect(updated.ok()).toBeTruthy() - const getJson = await updated.json() + await th.deleteMonitoringInstance(request, name) }) test('patch monitoring instance type fails on missing key', async ({ request }) => { - const names = await createInstances(request, 'patch-monitoring-') - const name = names[1] + const name = await createMonitoringInstance(request) const response = await request.get(`/v1/monitoring-instances/${name}`) @@ -277,8 +254,9 @@ test('patch monitoring instance type fails on missing key', async ({ request }) expect(updated.status()).toBe(400) const getJson = await updated.json() - expect(getJson.message).toMatch('Pmm key is required') + + await th.deleteMonitoringInstance(request, name) }) test('create monitoring instance failures', async ({ request }) => { @@ -298,9 +276,10 @@ test('create monitoring instance failures', async ({ request }) => { }) test('update monitoring instances failures', async ({ request }) => { + const name = th.randomName() const data = { type: 'pmm', - name: `${testPrefix}-fail`, + name: name, url: 'http://monitoring', pmm: { apiKey: '123', @@ -309,9 +288,6 @@ test('update monitoring instances failures', async ({ request }) => { const response = await request.post('/v1/monitoring-instances', { data }) expect(response.ok()).toBeTruthy() - const created = await response.json() - - const name = created.name const testCases = [ { @@ -330,6 +306,8 @@ test('update monitoring instances failures', async ({ request }) => { expect(response.status()).toBe(400) expect((await response.json()).message).toMatch(testCase.errorText) } + + await th.deleteMonitoringInstance(request, name) }) test('update: monitoring instance not found', async ({ request }) => { @@ -353,25 +331,3 @@ test('get: monitoring instance not found', async ({ request }) => { expect(response.status()).toBe(404) }) -async function createInstances(request: APIRequestContext, namePrefix: string, count = 3): Promise { - const data = { - type: 'pmm', - name: '', - url: 'http://monitoring-instance', - pmm: { - apiKey: '123', - }, - } - - const res = [] - - for (let i = 1; i <= count; i++) { - data.name = `${namePrefix}${testPrefix}-${i}` - res.push(data.name) - const response = await request.post('/v1/monitoring-instances', { data }) - - expect(response.ok()).toBeTruthy() - } - - return res -} From f4e89a34f111507886533bf04cafc3f8daef1105 Mon Sep 17 00:00:00 2001 From: Oksana Grishchenko Date: Tue, 3 Oct 2023 10:30:24 +0200 Subject: [PATCH 02/10] delete monitoring test update --- api-tests/tests/backup-storages.spec.ts | 6 +- api-tests/tests/monitoring-instances.spec.ts | 460 ++++++++++--------- 2 files changed, 239 insertions(+), 227 deletions(-) diff --git a/api-tests/tests/backup-storages.spec.ts b/api-tests/tests/backup-storages.spec.ts index 67afd57f..45dac41b 100644 --- a/api-tests/tests/backup-storages.spec.ts +++ b/api-tests/tests/backup-storages.spec.ts @@ -17,9 +17,10 @@ import * as th from './helpers' test('add/list/get/delete backup storage success', async ({ request }) => { + const name = th.randomName() const payload = { type: 's3', - name: 'backup-storage-1', + name: name, url: 'http://custom-url', description: 'Dev storage', bucketName: 'percona-test-backup-storage', @@ -36,8 +37,6 @@ test('add/list/get/delete backup storage success', async ({ request }) => { expect(response.ok()).toBeTruthy() const created = await response.json() - const name = created.name - expect(created.name).toBe(payload.name) expect(created.url).toBe(payload.url) expect(created.bucketName).toBe(payload.bucketName) @@ -87,7 +86,6 @@ test('add/list/get/delete backup storage success', async ({ request }) => { // delete const deleted = await request.delete(`/v1/backup-storages/${name}`) - expect(deleted.ok()).toBeTruthy() }) diff --git a/api-tests/tests/monitoring-instances.spec.ts b/api-tests/tests/monitoring-instances.spec.ts index 1b7af4c6..64749c75 100644 --- a/api-tests/tests/monitoring-instances.spec.ts +++ b/api-tests/tests/monitoring-instances.spec.ts @@ -13,61 +13,22 @@ // See the License for the specific language governing permissions and // limitations under the License. import http from 'http' -import { expect, test } from '@fixtures' -import { APIRequestContext } from '@playwright/test' +import {expect, test} from '@fixtures' import * as th from './helpers' -import {createMonitoringInstance, createMonitoringInstances} from "./helpers"; +import {createMonitoringInstance, createMonitoringInstances} from './helpers' -test('create monitoring instance with api key', async ({ request }) => { - let name = th.randomName() - const data = { - type: 'pmm', - name: name, - url: 'http://monitoring', - pmm: { - apiKey: '123', - }, - } - - const response = await request.post('/v1/monitoring-instances', { data }) - - expect(response.ok()).toBeTruthy() - const created = await response.json() - - expect(created.name).toBe(data.name) - expect(created.url).toBe(data.url) - expect(created.type).toBe(data.type) - - await th.deleteMonitoringInstance(request, name) -}) - -test('create monitoring instance with user/password', async ({ request }) => { - const server = http.createServer((_, res) => { - res.statusCode = 200 - res.setHeader('Content-Type', 'application/json') - res.end(JSON.stringify({ key: 'test-api-key' })) - }) - - try { - let s - - await new Promise((resolve) => { - s = server.listen(0, '127.0.0.1', () => resolve()) - }) - - const port = s.address()?.port +test('create monitoring instance with api key', async ({request}) => { let name = th.randomName() const data = { - type: 'pmm', - name: name, - url: `http://127.0.0.1:${port}`, - pmm: { - user: 'admin', - password: 'admin', - }, + type: 'pmm', + name: name, + url: 'http://monitoring', + pmm: { + apiKey: '123', + }, } - const response = await request.post('/v1/monitoring-instances', { data }) + const response = await request.post('/v1/monitoring-instances', {data}) expect(response.ok()).toBeTruthy() const created = await response.json() @@ -75,259 +36,312 @@ test('create monitoring instance with user/password', async ({ request }) => { expect(created.name).toBe(data.name) expect(created.url).toBe(data.url) expect(created.type).toBe(data.type) + await th.deleteMonitoringInstance(request, name) - } finally { - server.closeAllConnections() - await new Promise((resolve) => server.close(() => resolve())) - } }) -test('create monitoring instance with user/password cannot connect to PMM', async ({ request }) => { - const server = http.createServer((_, res) => { - res.statusCode = 404 - res.setHeader('Content-Type', 'application/json') - res.end('{}') - }) +test('create monitoring instance with user/password', async ({request}) => { + const server = http.createServer((_, res) => { + res.statusCode = 200 + res.setHeader('Content-Type', 'application/json') + res.end(JSON.stringify({key: 'test-api-key'})) + }) - try { - let s + try { + let s + + await new Promise((resolve) => { + s = server.listen(0, '127.0.0.1', () => resolve()) + }) + + const port = s.address()?.port + let name = th.randomName() + const data = { + type: 'pmm', + name: name, + url: `http://127.0.0.1:${port}`, + pmm: { + user: 'admin', + password: 'admin', + }, + } + + const response = await request.post('/v1/monitoring-instances', {data}) + + expect(response.ok()).toBeTruthy() + const created = await response.json() + + expect(created.name).toBe(data.name) + expect(created.url).toBe(data.url) + expect(created.type).toBe(data.type) + await th.deleteMonitoringInstance(request, name) + } finally { + server.closeAllConnections() + await new Promise((resolve) => server.close(() => resolve())) + } +}) - await new Promise((resolve) => { - s = server.listen(0, '127.0.0.1', () => resolve()) +test('create monitoring instance with user/password cannot connect to PMM', async ({request}) => { + const server = http.createServer((_, res) => { + res.statusCode = 404 + res.setHeader('Content-Type', 'application/json') + res.end('{}') }) - const port = s.address()?.port + try { + let s + + await new Promise((resolve) => { + s = server.listen(0, '127.0.0.1', () => resolve()) + }) + + const port = s.address()?.port + const data = { + type: 'pmm', + name: 'monitoring-fail', + url: `http://127.0.0.1:${port}`, + pmm: { + user: 'admin', + password: 'admin', + }, + } + + const response = await request.post('/v1/monitoring-instances', {data}) + + expect(response.status()).toBe(400) + } finally { + server.closeAllConnections() + await new Promise((resolve) => server.close(() => resolve())) + } +}) + +test('create monitoring instance missing pmm', async ({request}) => { const data = { - type: 'pmm', - name: 'monitoring-fail', - url: `http://127.0.0.1:${port}`, - pmm: { - user: 'admin', - password: 'admin', - }, + type: 'pmm', + name: 'monitoring-fail', + url: 'http://monitoring-instance', } - const response = await request.post('/v1/monitoring-instances', { data }) + const response = await request.post('/v1/monitoring-instances', {data}) expect(response.status()).toBe(400) - } finally { - server.closeAllConnections() - await new Promise((resolve) => server.close(() => resolve())) - } }) -test('create monitoring instance missing pmm', async ({ request }) => { - const data = { - type: 'pmm', - name: 'monitoring-fail', - url: 'http://monitoring-instance', - } +test('create monitoring instance missing pmm credentials', async ({request}) => { + const data = { + type: 'pmm', + name: 'monitoring-fail', + url: 'http://monitoring-instance', + pmm: {}, + } - const response = await request.post('/v1/monitoring-instances', { data }) + const response = await request.post('/v1/monitoring-instances', {data}) - expect(response.status()).toBe(400) + expect(response.status()).toBe(400) }) -test('create monitoring instance missing pmm credentials', async ({ request }) => { - const data = { - type: 'pmm', - name: 'monitoring-fail', - url: 'http://monitoring-instance', - pmm: {}, - } +test('list monitoring instances', async ({request}) => { + const testPrefix = th.randomName() - const response = await request.post('/v1/monitoring-instances', { data }) + const names = await th.createMonitoringInstances(request, testPrefix) - expect(response.status()).toBe(400) -}) + const response = await request.get('/v1/monitoring-instances') + + expect(response.ok()).toBeTruthy() + const list = await response.json() -test('list monitoring instances', async ({ request }) => { - const testPrefix = th.randomName() + expect(list.filter((i) => i.name.startsWith(`${testPrefix}`)).length).toBe(3) - const names = await th.createMonitoringInstances(request, testPrefix) - const response = await request.get('/v1/monitoring-instances') + await th.deleteMonitoringInstances(request, names) +}) - expect(response.ok()).toBeTruthy() - const list = await response.json() +test('get monitoring instance', async ({request}) => { + const name = await th.createMonitoringInstance(request) - expect(list.filter((i) => i.name.startsWith(`${testPrefix}`)).length).toBe(3) + const response = await request.get(`/v1/monitoring-instances/${name}`) + expect(response.ok()).toBeTruthy() + const i = await response.json() - await th.deleteMonitoringInstances(request, names) + expect(i.name).toBe(name) + await th.deleteMonitoringInstance(request, name) }) -test('get monitoring instance', async ({ request }) => { - const name = await th.createMonitoringInstance(request) +test('delete monitoring instance', async ({request}) => { + const testPrefix = th.randomName() + const names = await createMonitoringInstances(request, testPrefix) + // we had a bug in the implementation where delete would delete the first instance, not the one selected by name + const name = names[1] - const response = await request.get(`/v1/monitoring-instances/${name}`) + let response = await request.get('/v1/monitoring-instances') + let list = await response.json() - expect(response.ok()).toBeTruthy() - const i = await response.json() + expect(list.filter((i) => i.name.startsWith(`${testPrefix}`)).length).toBe(3) - expect(i.name).toBe(name) - await th.deleteMonitoringInstance(request, name) -}) + response = await request.delete(`/v1/monitoring-instances/${name}`) + expect(response.ok()).toBeTruthy() + + response = await request.get(`/v1/monitoring-instances/${name}`) + expect(response.status()).toBe(404) -test('delete monitoring instance', async ({ request }) => { - const name = await createMonitoringInstance(request) + response = await request.get('/v1/monitoring-instances') + list = await response.json() - let response = await request.delete(`/v1/monitoring-instances/${name}`) - expect(response.ok()).toBeTruthy() + expect(list.filter((i) => i.name.startsWith(`${testPrefix}`)).length).toBe(2) - response = await request.get(`/v1/monitoring-instances/${name}`) - expect(response.status()).toBe(404) + await th.deleteMonitoringInstances(request, names.filter((n) => n != name)) }) -test('patch monitoring instance', async ({ request }) => { - const name = await createMonitoringInstance(request) +test('patch monitoring instance', async ({request}) => { + const name = await createMonitoringInstance(request) - const response = await request.get(`/v1/monitoring-instances/${name}`) + const response = await request.get(`/v1/monitoring-instances/${name}`) - expect(response.ok()).toBeTruthy() - const created = await response.json() + expect(response.ok()).toBeTruthy() + const created = await response.json() - const patchData = { url: 'http://monitoring' } - const updated = await request.patch(`/v1/monitoring-instances/${name}`, { data: patchData }) + const patchData = {url: 'http://monitoring'} + const updated = await request.patch(`/v1/monitoring-instances/${name}`, {data: patchData}) - expect(updated.ok()).toBeTruthy() - const getJson = await updated.json() + expect(updated.ok()).toBeTruthy() + const getJson = await updated.json() - expect(getJson.url).toBe(patchData.url) - expect(getJson.apiKeySecretId).toBe(created.apiKeySecretId) - await th.deleteMonitoringInstance(request, name) + expect(getJson.url).toBe(patchData.url) + expect(getJson.apiKeySecretId).toBe(created.apiKeySecretId) + await th.deleteMonitoringInstance(request, name) }) -test('patch monitoring instance secret key changes', async ({ request }) => { - const name = await createMonitoringInstance(request) +test('patch monitoring instance secret key changes', async ({request}) => { + const name = await createMonitoringInstance(request) - const response = await request.get(`/v1/monitoring-instances/${name}`) + const response = await request.get(`/v1/monitoring-instances/${name}`) - expect(response.ok()).toBeTruthy() + expect(response.ok()).toBeTruthy() - const patchData = { - url: 'http://monitoring2', - pmm: { - apiKey: 'asd', - }, - } - const updated = await request.patch(`/v1/monitoring-instances/${name}`, { data: patchData }) + const patchData = { + url: 'http://monitoring2', + pmm: { + apiKey: 'asd', + }, + } + const updated = await request.patch(`/v1/monitoring-instances/${name}`, {data: patchData}) - expect(updated.ok()).toBeTruthy() - const getJson = await updated.json() + expect(updated.ok()).toBeTruthy() + const getJson = await updated.json() - expect(getJson.url).toBe(patchData.url) - await th.deleteMonitoringInstance(request, name) + expect(getJson.url).toBe(patchData.url) + await th.deleteMonitoringInstance(request, name) }) -test('patch monitoring instance type updates properly', async ({ request }) => { - const name = await createMonitoringInstance(request) +test('patch monitoring instance type updates properly', async ({request}) => { + const name = await createMonitoringInstance(request) - const response = await request.get(`/v1/monitoring-instances/${name}`) + const response = await request.get(`/v1/monitoring-instances/${name}`) - expect(response.ok()).toBeTruthy() + expect(response.ok()).toBeTruthy() - const patchData = { - type: 'pmm', - pmm: { - apiKey: 'asd', - }, - } - const updated = await request.patch(`/v1/monitoring-instances/${name}`, { data: patchData }) + const patchData = { + type: 'pmm', + pmm: { + apiKey: 'asd', + }, + } + const updated = await request.patch(`/v1/monitoring-instances/${name}`, {data: patchData}) - expect(updated.ok()).toBeTruthy() - await th.deleteMonitoringInstance(request, name) + expect(updated.ok()).toBeTruthy() + await th.deleteMonitoringInstance(request, name) }) -test('patch monitoring instance type fails on missing key', async ({ request }) => { - const name = await createMonitoringInstance(request) +test('patch monitoring instance type fails on missing key', async ({request}) => { + const name = await createMonitoringInstance(request) - const response = await request.get(`/v1/monitoring-instances/${name}`) + const response = await request.get(`/v1/monitoring-instances/${name}`) - expect(response.ok()).toBeTruthy() + expect(response.ok()).toBeTruthy() - const patchData = { - type: 'pmm', - } - const updated = await request.patch(`/v1/monitoring-instances/${name}`, { data: patchData }) + const patchData = { + type: 'pmm', + } + const updated = await request.patch(`/v1/monitoring-instances/${name}`, {data: patchData}) - expect(updated.status()).toBe(400) + expect(updated.status()).toBe(400) - const getJson = await updated.json() - expect(getJson.message).toMatch('Pmm key is required') + const getJson = await updated.json() + expect(getJson.message).toMatch('Pmm key is required') - await th.deleteMonitoringInstance(request, name) + await th.deleteMonitoringInstance(request, name) }) -test('create monitoring instance failures', async ({ request }) => { - const testCases = [ - { - payload: {}, - errorText: 'doesn\'t match schema', - }, - ] +test('create monitoring instance failures', async ({request}) => { + const testCases = [ + { + payload: {}, + errorText: 'doesn\'t match schema', + }, + ] - for (const testCase of testCases) { - const response = await request.post('/v1/monitoring-instances', { data: testCase.payload }) + for (const testCase of testCases) { + const response = await request.post('/v1/monitoring-instances', {data: testCase.payload}) - expect(response.status()).toBe(400) - expect((await response.json()).message).toMatch(testCase.errorText) - } + expect(response.status()).toBe(400) + expect((await response.json()).message).toMatch(testCase.errorText) + } }) -test('update monitoring instances failures', async ({ request }) => { - const name = th.randomName() - const data = { - type: 'pmm', - name: name, - url: 'http://monitoring', - pmm: { - apiKey: '123', - }, - } - const response = await request.post('/v1/monitoring-instances', { data }) - - expect(response.ok()).toBeTruthy() - - const testCases = [ - { - payload: { url: 'not-url' }, - errorText: '\'url\' is an invalid URL', - }, - { - payload: { pmm: { apiKey: '' } }, - errorText: 'Error at "/pmm/apiKey"', - }, - ] - - for (const testCase of testCases) { - const response = await request.patch(`/v1/monitoring-instances/${name}`, { data: testCase.payload }) +test('update monitoring instances failures', async ({request}) => { + const name = th.randomName() + const data = { + type: 'pmm', + name: name, + url: 'http://monitoring', + pmm: { + apiKey: '123', + }, + } + const response = await request.post('/v1/monitoring-instances', {data}) + + expect(response.ok()).toBeTruthy() - expect(response.status()).toBe(400) - expect((await response.json()).message).toMatch(testCase.errorText) - } + const testCases = [ + { + payload: {url: 'not-url'}, + errorText: '\'url\' is an invalid URL', + }, + { + payload: {pmm: {apiKey: ''}}, + errorText: 'Error at "/pmm/apiKey"', + }, + ] + + for (const testCase of testCases) { + const response = await request.patch(`/v1/monitoring-instances/${name}`, {data: testCase.payload}) + + expect(response.status()).toBe(400) + expect((await response.json()).message).toMatch(testCase.errorText) + } - await th.deleteMonitoringInstance(request, name) + await th.deleteMonitoringInstance(request, name) }) -test('update: monitoring instance not found', async ({ request }) => { - const name = 'non-existent' - const response = await request.patch(`/v1/monitoring-instances/${name}`, { data: { url: 'http://monitoring' } }) +test('update: monitoring instance not found', async ({request}) => { + const name = 'non-existent' + const response = await request.patch(`/v1/monitoring-instances/${name}`, {data: {url: 'http://monitoring'}}) - expect(response.status()).toBe(404) + expect(response.status()).toBe(404) }) -test('delete: monitoring instance not found', async ({ request }) => { - const name = 'non-existent' - const response = await request.delete(`/v1/monitoring-instances/${name}`) +test('delete: monitoring instance not found', async ({request}) => { + const name = 'non-existent' + const response = await request.delete(`/v1/monitoring-instances/${name}`) - expect(response.status()).toBe(404) + expect(response.status()).toBe(404) }) -test('get: monitoring instance not found', async ({ request }) => { - const name = 'non-existent' - const response = await request.get(`/v1/monitoring-instances/${name}`) +test('get: monitoring instance not found', async ({request}) => { + const name = 'non-existent' + const response = await request.get(`/v1/monitoring-instances/${name}`) - expect(response.status()).toBe(404) + expect(response.status()).toBe(404) }) From 1ee7c62b3a671a30841f7be45657c41d29cc68dc Mon Sep 17 00:00:00 2001 From: Oksana Grishchenko Date: Tue, 3 Oct 2023 10:41:51 +0200 Subject: [PATCH 03/10] restores timeout --- .../tests/database-cluster-restores.spec.ts | 395 +++++++++--------- 1 file changed, 198 insertions(+), 197 deletions(-) diff --git a/api-tests/tests/database-cluster-restores.spec.ts b/api-tests/tests/database-cluster-restores.spec.ts index 45126834..f80ff21f 100644 --- a/api-tests/tests/database-cluster-restores.spec.ts +++ b/api-tests/tests/database-cluster-restores.spec.ts @@ -12,223 +12,224 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -import { expect, test } from '@playwright/test' +import {expect, test} from '@playwright/test' import * as th from './helpers' let kubernetesId -test.beforeAll(async ({ request }) => { - const kubernetesList = await request.get('/v1/kubernetes') +test.beforeAll(async ({request}) => { + const kubernetesList = await request.get('/v1/kubernetes') - kubernetesId = (await kubernetesList.json())[0].id + kubernetesId = (await kubernetesList.json())[0].id }) -test('create/update/delete database cluster restore', async ({ request }) => { - const bsName = th.randomName('storage') - const clName = th.randomName('cluster') - const clName2 = th.randomName('cluster2') - const backupName = th.randomName('backup') - - await th.createBackupStorage(request, bsName) - await th.createDBCluster(request, kubernetesId, clName) - await th.createDBCluster(request, kubernetesId, clName2) - await th.createBackup(request, kubernetesId, clName, backupName, bsName) - - const restoreName = th.randomName('restore') - - const payloadRestore = { - apiVersion: 'everest.percona.com/v1alpha1', - kind: 'DatabaseClusterRestore', - metadata: { - name: restoreName, - }, - spec: { - dataSource: { - dbClusterBackupName: backupName, - }, - dbClusterName: clName, - }, - } - - let response = await request.post(`/v1/kubernetes/${kubernetesId}/database-cluster-restores`, { - data: payloadRestore, - }) - - expect(response.ok()).toBeTruthy() - const restore = await response.json() - - expect(restore.spec).toMatchObject(payloadRestore.spec) - - // update restore - restore.spec.dbClusterName = clName2 - response = await request.put(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`, { - data: restore, - }) - expect(response.ok()).toBeTruthy() - const result = await response.json() - - expect(result.spec).toMatchObject(restore.spec) - - // update restore with not existing dbClusterName - restore.spec.dbClusterName = 'not-existing-cluster' - response = await request.put(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`, { - data: restore, - }) - expect(response.status()).toBe(400) - expect(await response.text()).toContain('{"message":"DatabaseCluster \'not-existing-cluster\' is not found"}') - - // delete restore - await request.delete(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`) - // check it couldn't be found anymore - response = await request.get(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`) - expect(response.status()).toBe(404) - - await th.deleteDBCluster(request, kubernetesId, clName) - await th.deleteDBCluster(request, kubernetesId, clName2) - await th.deleteBackup(request, kubernetesId, backupName) - await th.deleteBackupStorage(request, bsName) -}) +test('create/update/delete database cluster restore', async ({request, page}) => { + const bsName = th.randomName('storage') + const clName = th.randomName('cluster') + const clName2 = th.randomName('cluster2') + const backupName = th.randomName('backup') -test('list restores', async ({ request, page }) => { - const bsName = th.randomName('storage') - const clName1 = th.randomName('cluster1') - const clName2 = th.randomName('cluster2') - const backupName = th.randomName('backup') - - await th.createBackupStorage(request, bsName) - await th.createDBCluster(request, kubernetesId, clName1) - await th.createDBCluster(request, kubernetesId, clName2) - await th.createBackup(request, kubernetesId, clName1, backupName, bsName) - - const restoreName1 = th.randomName('restore1') - const restoreName2 = th.randomName('restore2') - const restoreName3 = th.randomName('restore3') - - const payloads = [ - { - apiVersion: 'everest.percona.com/v1alpha1', - kind: 'DatabaseClusterRestore', - metadata: { - name: restoreName1, - }, - spec: { - dataSource: { - dbClusterBackupName: backupName, - }, - dbClusterName: clName1, - }, - }, - { - apiVersion: 'everest.percona.com/v1alpha1', - kind: 'DatabaseClusterRestore', - metadata: { - name: restoreName2, - }, - spec: { - dataSource: { - dbClusterBackupName: backupName, + await th.createBackupStorage(request, bsName) + await th.createDBCluster(request, kubernetesId, clName) + await th.createDBCluster(request, kubernetesId, clName2) + await th.createBackup(request, kubernetesId, clName, backupName, bsName) + + const restoreName = th.randomName('restore') + + const payloadRestore = { + apiVersion: 'everest.percona.com/v1alpha1', + kind: 'DatabaseClusterRestore', + metadata: { + name: restoreName, }, - dbClusterName: clName1, - }, - }, - { - apiVersion: 'everest.percona.com/v1alpha1', - kind: 'DatabaseClusterRestore', - metadata: { - name: restoreName3, - }, - spec: { - dataSource: { - dbClusterBackupName: backupName, + spec: { + dataSource: { + dbClusterBackupName: backupName, + }, + dbClusterName: clName, }, - dbClusterName: clName2, - }, - }, - ] - - for (const payload of payloads) { - const response = await request.post(`/v1/kubernetes/${kubernetesId}/database-cluster-restores`, { - data: payload, + } + + let response = await request.post(`/v1/kubernetes/${kubernetesId}/database-cluster-restores`, { + data: payloadRestore, }) expect(response.ok()).toBeTruthy() - } + const restore = await response.json() - await page.waitForTimeout(6000) + expect(restore.spec).toMatchObject(payloadRestore.spec) + await page.waitForTimeout(2000) - // check if the restores are available when being requested via database-clusters/{cluster-name}/restores path - let response = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clName1}/restores`) - let result = await response.json() - - expect(result.items).toHaveLength(2) + // update restore + restore.spec.dbClusterName = clName2 + response = await request.put(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`, { + data: restore, + }) + expect(response.ok()).toBeTruthy() + const result = await response.json() - response = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clName2}/restores`) - result = await response.json() + expect(result.spec).toMatchObject(restore.spec) - expect(result.items).toHaveLength(1) + // update restore with not existing dbClusterName + restore.spec.dbClusterName = 'not-existing-cluster' + response = await request.put(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`, { + data: restore, + }) + expect(response.status()).toBe(400) + expect(await response.text()).toContain('{"message":"DatabaseCluster \'not-existing-cluster\' is not found"}') - // delete the created restores - for (const payload of payloads) { - await request.delete(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${payload.metadata.name}`) - response = await request.get(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${payload.metadata.name}`) + // delete restore + await request.delete(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`) + // check it couldn't be found anymore + response = await request.get(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`) expect(response.status()).toBe(404) - } - await th.deleteBackup(request, kubernetesId, backupName) - await th.deleteDBCluster(request, kubernetesId, clName1) - await th.deleteDBCluster(request, kubernetesId, clName2) - await th.deleteBackupStorage(request, bsName) + await th.deleteDBCluster(request, kubernetesId, clName) + await th.deleteDBCluster(request, kubernetesId, clName2) + await th.deleteBackup(request, kubernetesId, backupName) + await th.deleteBackupStorage(request, bsName) }) -test('create restore: validation errors', async ({ request, page }) => { - const bsName = th.randomName('storage') - const backupName = th.randomName('backup') - const clName = th.randomName('cl') - - await th.createBackupStorage(request, bsName) - await th.createDBCluster(request, kubernetesId, clName) - await th.createBackup(request, kubernetesId, clName, backupName, bsName) - - // dbcluster not found - const restoreName = th.randomName('restore') - const payloadRestore = { - apiVersion: 'everest.percona.com/v1alpha1', - kind: 'DatabaseClusterRestore', - metadata: { - name: restoreName, - }, - spec: { - dataSource: { - dbClusterBackupName: backupName, - }, - dbClusterName: 'not-existing-cluster', - }, - } - - let response = await request.post(`/v1/kubernetes/${kubernetesId}/database-cluster-restores`, { - data: payloadRestore, - }) - - expect(response.status()).toBe(400) - expect(await response.text()).toContain('{"message":"DatabaseCluster \'not-existing-cluster\' is not found"}') - - // empty spec - const payloadEmptySpec = { - apiVersion: 'everest.percona.com/v1alpha1', - kind: 'DatabaseClusterRestore', - metadata: { - name: restoreName, - }, - } - - response = await request.post(`/v1/kubernetes/${kubernetesId}/database-cluster-restores`, { - data: payloadEmptySpec, - }) - expect(response.status()).toBe(400) - expect(await response.text()).toContain('{"message":"\'Spec\' field should not be empty"}') - - await th.deleteBackup(request, kubernetesId, backupName) - await th.deleteRestore(request, kubernetesId, restoreName) - await th.deleteBackupStorage(request, bsName) - await th.deleteDBCluster(request, kubernetesId, clName) +test('list restores', async ({request, page}) => { + const bsName = th.randomName('storage') + const clName1 = th.randomName('cluster1') + const clName2 = th.randomName('cluster2') + const backupName = th.randomName('backup') + + await th.createBackupStorage(request, bsName) + await th.createDBCluster(request, kubernetesId, clName1) + await th.createDBCluster(request, kubernetesId, clName2) + await th.createBackup(request, kubernetesId, clName1, backupName, bsName) + + const restoreName1 = th.randomName('restore1') + const restoreName2 = th.randomName('restore2') + const restoreName3 = th.randomName('restore3') + + const payloads = [ + { + apiVersion: 'everest.percona.com/v1alpha1', + kind: 'DatabaseClusterRestore', + metadata: { + name: restoreName1, + }, + spec: { + dataSource: { + dbClusterBackupName: backupName, + }, + dbClusterName: clName1, + }, + }, + { + apiVersion: 'everest.percona.com/v1alpha1', + kind: 'DatabaseClusterRestore', + metadata: { + name: restoreName2, + }, + spec: { + dataSource: { + dbClusterBackupName: backupName, + }, + dbClusterName: clName1, + }, + }, + { + apiVersion: 'everest.percona.com/v1alpha1', + kind: 'DatabaseClusterRestore', + metadata: { + name: restoreName3, + }, + spec: { + dataSource: { + dbClusterBackupName: backupName, + }, + dbClusterName: clName2, + }, + }, + ] + + for (const payload of payloads) { + const response = await request.post(`/v1/kubernetes/${kubernetesId}/database-cluster-restores`, { + data: payload, + }) + + expect(response.ok()).toBeTruthy() + } + + await page.waitForTimeout(6000) + + // check if the restores are available when being requested via database-clusters/{cluster-name}/restores path + let response = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clName1}/restores`) + let result = await response.json() + + expect(result.items).toHaveLength(2) + + response = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clName2}/restores`) + result = await response.json() + + expect(result.items).toHaveLength(1) + + // delete the created restores + for (const payload of payloads) { + await request.delete(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${payload.metadata.name}`) + response = await request.get(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${payload.metadata.name}`) + expect(response.status()).toBe(404) + } + + await th.deleteBackup(request, kubernetesId, backupName) + await th.deleteDBCluster(request, kubernetesId, clName1) + await th.deleteDBCluster(request, kubernetesId, clName2) + await th.deleteBackupStorage(request, bsName) +}) + +test('create restore: validation errors', async ({request, page}) => { + const bsName = th.randomName('storage') + const backupName = th.randomName('backup') + const clName = th.randomName('cl') + + await th.createBackupStorage(request, bsName) + await th.createDBCluster(request, kubernetesId, clName) + await th.createBackup(request, kubernetesId, clName, backupName, bsName) + + // dbcluster not found + const restoreName = th.randomName('restore') + const payloadRestore = { + apiVersion: 'everest.percona.com/v1alpha1', + kind: 'DatabaseClusterRestore', + metadata: { + name: restoreName, + }, + spec: { + dataSource: { + dbClusterBackupName: backupName, + }, + dbClusterName: 'not-existing-cluster', + }, + } + + let response = await request.post(`/v1/kubernetes/${kubernetesId}/database-cluster-restores`, { + data: payloadRestore, + }) + + expect(response.status()).toBe(400) + expect(await response.text()).toContain('{"message":"DatabaseCluster \'not-existing-cluster\' is not found"}') + + // empty spec + const payloadEmptySpec = { + apiVersion: 'everest.percona.com/v1alpha1', + kind: 'DatabaseClusterRestore', + metadata: { + name: restoreName, + }, + } + + response = await request.post(`/v1/kubernetes/${kubernetesId}/database-cluster-restores`, { + data: payloadEmptySpec, + }) + expect(response.status()).toBe(400) + expect(await response.text()).toContain('{"message":"\'Spec\' field should not be empty"}') + + await th.deleteBackup(request, kubernetesId, backupName) + await th.deleteRestore(request, kubernetesId, restoreName) + await th.deleteBackupStorage(request, bsName) + await th.deleteDBCluster(request, kubernetesId, clName) }) From 288c519c28c7ffa28fb0a5e88d42fdbbd4125028 Mon Sep 17 00:00:00 2001 From: Oksana Grishchenko Date: Tue, 3 Oct 2023 10:43:14 +0200 Subject: [PATCH 04/10] psmdb timeout --- api-tests/tests/psmdb-clusters.spec.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api-tests/tests/psmdb-clusters.spec.ts b/api-tests/tests/psmdb-clusters.spec.ts index 37b84e37..71df7882 100644 --- a/api-tests/tests/psmdb-clusters.spec.ts +++ b/api-tests/tests/psmdb-clusters.spec.ts @@ -94,6 +94,7 @@ test('create/edit/delete single node psmdb cluster', async ({ request, page }) = break } + await page.waitForTimeout(2000) psmdbPayload.spec.engine.config = 'operationProfiling:\nmode: slowOp' // Update PSMDB cluster @@ -175,6 +176,8 @@ test('expose psmdb cluster after creation', async ({ request, page }) => { psmdbPayload.spec.proxy.expose.type = 'external' + await page.waitForTimeout(2000) + // Update PSMDB cluster const updatedPSMDBCluster = await request.put(`/v1/kubernetes/${kubernetesId}/database-clusters/${clusterName}`, { From 05f00cad8c0e92816d3daed1a08abff8af7e636b Mon Sep 17 00:00:00 2001 From: Oksana Grishchenko Date: Tue, 3 Oct 2023 11:00:19 +0200 Subject: [PATCH 05/10] Revert "psmdb timeout" This reverts commit 288c519c28c7ffa28fb0a5e88d42fdbbd4125028. --- api-tests/tests/psmdb-clusters.spec.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/api-tests/tests/psmdb-clusters.spec.ts b/api-tests/tests/psmdb-clusters.spec.ts index 71df7882..37b84e37 100644 --- a/api-tests/tests/psmdb-clusters.spec.ts +++ b/api-tests/tests/psmdb-clusters.spec.ts @@ -94,7 +94,6 @@ test('create/edit/delete single node psmdb cluster', async ({ request, page }) = break } - await page.waitForTimeout(2000) psmdbPayload.spec.engine.config = 'operationProfiling:\nmode: slowOp' // Update PSMDB cluster @@ -176,8 +175,6 @@ test('expose psmdb cluster after creation', async ({ request, page }) => { psmdbPayload.spec.proxy.expose.type = 'external' - await page.waitForTimeout(2000) - // Update PSMDB cluster const updatedPSMDBCluster = await request.put(`/v1/kubernetes/${kubernetesId}/database-clusters/${clusterName}`, { From 933b686944e9dceea14dec4290c882c7bb91a11d Mon Sep 17 00:00:00 2001 From: Oksana Grishchenko Date: Tue, 3 Oct 2023 11:05:44 +0200 Subject: [PATCH 06/10] update get monitoring test --- api-tests/tests/monitoring-instances.spec.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api-tests/tests/monitoring-instances.spec.ts b/api-tests/tests/monitoring-instances.spec.ts index 64749c75..972433f2 100644 --- a/api-tests/tests/monitoring-instances.spec.ts +++ b/api-tests/tests/monitoring-instances.spec.ts @@ -157,10 +157,12 @@ test('list monitoring instances', async ({request}) => { }) test('get monitoring instance', async ({request}) => { - const name = await th.createMonitoringInstance(request) + const testPrefix = th.randomName() + const names = await th.createMonitoringInstances(request, testPrefix) + // we had a bug in the implementation where delete would delete the first instance, not the one selected by name + const name = names[1] const response = await request.get(`/v1/monitoring-instances/${name}`) - expect(response.ok()).toBeTruthy() const i = await response.json() From 3c1a5c72485d39cfba308bd9ae70bbb03a1acce0 Mon Sep 17 00:00:00 2001 From: Oksana Grishchenko Date: Tue, 3 Oct 2023 11:14:08 +0200 Subject: [PATCH 07/10] restores tests timeout --- api-tests/tests/database-cluster-restores.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api-tests/tests/database-cluster-restores.spec.ts b/api-tests/tests/database-cluster-restores.spec.ts index f80ff21f..b0c0cf39 100644 --- a/api-tests/tests/database-cluster-restores.spec.ts +++ b/api-tests/tests/database-cluster-restores.spec.ts @@ -58,7 +58,7 @@ test('create/update/delete database cluster restore', async ({request, page}) => const restore = await response.json() expect(restore.spec).toMatchObject(payloadRestore.spec) - await page.waitForTimeout(2000) + await page.waitForTimeout(6000) // update restore restore.spec.dbClusterName = clName2 From 213a12363890b52bc79a556a423bffd873727c6c Mon Sep 17 00:00:00 2001 From: Oksana Grishchenko Date: Tue, 3 Oct 2023 12:21:27 +0200 Subject: [PATCH 08/10] Revert "restores tests timeout" This reverts commit 3c1a5c72485d39cfba308bd9ae70bbb03a1acce0. --- api-tests/tests/database-cluster-restores.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api-tests/tests/database-cluster-restores.spec.ts b/api-tests/tests/database-cluster-restores.spec.ts index b0c0cf39..f80ff21f 100644 --- a/api-tests/tests/database-cluster-restores.spec.ts +++ b/api-tests/tests/database-cluster-restores.spec.ts @@ -58,7 +58,7 @@ test('create/update/delete database cluster restore', async ({request, page}) => const restore = await response.json() expect(restore.spec).toMatchObject(payloadRestore.spec) - await page.waitForTimeout(6000) + await page.waitForTimeout(2000) // update restore restore.spec.dbClusterName = clName2 From 2445ab253dbfbbf2014d507dfe19a86d0e56ed4b Mon Sep 17 00:00:00 2001 From: Oksana Grishchenko Date: Wed, 4 Oct 2023 10:52:48 +0200 Subject: [PATCH 09/10] random cluster names --- api-tests/tests/database-cluster.spec.ts | 7 ++++--- api-tests/tests/pg-clusters.spec.ts | 7 ++++--- api-tests/tests/psmdb-clusters.spec.ts | 7 ++++--- api-tests/tests/pxc-clusters.spec.ts | 7 ++++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/api-tests/tests/database-cluster.spec.ts b/api-tests/tests/database-cluster.spec.ts index 8e761055..24b85bf5 100644 --- a/api-tests/tests/database-cluster.spec.ts +++ b/api-tests/tests/database-cluster.spec.ts @@ -13,6 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. import { expect, test } from '@fixtures' +import * as th from "@tests/tests/helpers"; // testPrefix is used to differentiate between several workers // running this test to avoid conflicts in instance names @@ -70,7 +71,7 @@ test.afterAll(async ({ request }) => { }) test('create db cluster with monitoring config', async ({ request }) => { - const clusterName = 'db-monitoring-create' + const clusterName = th.randomName('db-monitoring-create') const data = { apiVersion: 'everest.percona.com/v1alpha1', kind: 'DatabaseCluster', @@ -125,7 +126,7 @@ test('create db cluster with monitoring config', async ({ request }) => { }) test('update db cluster with a new monitoring config', async ({ request }) => { - const clusterName = 'dbc-monitoring-put' + const clusterName = th.randomName('dbc-monitoring-put') const data = { apiVersion: 'everest.percona.com/v1alpha1', kind: 'DatabaseCluster', @@ -194,7 +195,7 @@ test('update db cluster with a new monitoring config', async ({ request }) => { }) test('update db cluster without monitoring config with a new monitoring config', async ({ request }) => { - const clusterName = 'monitoring-put-empty' + const clusterName = th.randomName('monitoring-put-empty') const data = { apiVersion: 'everest.percona.com/v1alpha1', kind: 'DatabaseCluster', diff --git a/api-tests/tests/pg-clusters.spec.ts b/api-tests/tests/pg-clusters.spec.ts index 4b9aef8b..cf15ab86 100644 --- a/api-tests/tests/pg-clusters.spec.ts +++ b/api-tests/tests/pg-clusters.spec.ts @@ -13,6 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. import { test, expect } from '@fixtures' +import * as th from "@tests/tests/helpers"; let kubernetesId let recommendedVersion @@ -35,7 +36,7 @@ test.beforeAll(async ({ request }) => { }) test('create/edit/delete single node pg cluster', async ({ request, page }) => { - const clusterName = 'test-pg-cluster' + const clusterName = th.randomName('test-pg-cluster') const pgPayload = { apiVersion: 'everest.percona.com/v1alpha1', kind: 'DatabaseCluster', @@ -117,7 +118,7 @@ test('create/edit/delete single node pg cluster', async ({ request, page }) => { }) test('expose pg cluster after creation', async ({ request, page }) => { - const clusterName = 'exposed-pg-cluster' + const clusterName = th.randomName('exposed-pg-cluster') const pgPayload = { apiVersion: 'everest.percona.com/v1alpha1', kind: 'DatabaseCluster', @@ -195,7 +196,7 @@ test('expose pg cluster after creation', async ({ request, page }) => { }) test('expose pg cluster on EKS to the public internet and scale up', async ({ request, page }) => { - const clusterName = 'eks-pg-cluster' + const clusterName = th.randomName('eks-pg-cluster') const pgPayload = { apiVersion: 'everest.percona.com/v1alpha1', kind: 'DatabaseCluster', diff --git a/api-tests/tests/psmdb-clusters.spec.ts b/api-tests/tests/psmdb-clusters.spec.ts index 37b84e37..05dc834b 100644 --- a/api-tests/tests/psmdb-clusters.spec.ts +++ b/api-tests/tests/psmdb-clusters.spec.ts @@ -13,6 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. import { test, expect } from '@fixtures' +import * as th from './helpers' let kubernetesId let recommendedVersion @@ -35,7 +36,7 @@ test.beforeAll(async ({ request }) => { }) test('create/edit/delete single node psmdb cluster', async ({ request, page }) => { - const clusterName = 'test-psmdb' + const clusterName = th.randomName('test-psmdb') const psmdbPayload = { apiVersion: 'everest.percona.com/v1alpha1', kind: 'DatabaseCluster', @@ -117,7 +118,7 @@ test('create/edit/delete single node psmdb cluster', async ({ request, page }) = }) test('expose psmdb cluster after creation', async ({ request, page }) => { - const clusterName = 'expose-psmdb' + const clusterName = th.randomName('expose-psmdb') const psmdbPayload = { apiVersion: 'everest.percona.com/v1alpha1', kind: 'DatabaseCluster', @@ -196,7 +197,7 @@ test('expose psmdb cluster after creation', async ({ request, page }) => { }) test('expose psmdb cluster on EKS to the public internet and scale up', async ({ request, page }) => { - const clusterName = 'eks-psmdb' + const clusterName = th.randomName('eks-psmdb') const psmdbPayload = { apiVersion: 'everest.percona.com/v1alpha1', kind: 'DatabaseCluster', diff --git a/api-tests/tests/pxc-clusters.spec.ts b/api-tests/tests/pxc-clusters.spec.ts index 75534f77..e47bbe81 100644 --- a/api-tests/tests/pxc-clusters.spec.ts +++ b/api-tests/tests/pxc-clusters.spec.ts @@ -13,6 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. import { test, expect } from '@fixtures' +import * as th from "@tests/tests/helpers"; let kubernetesId let recommendedVersion @@ -39,7 +40,7 @@ test.beforeAll(async ({ request }) => { }) test('create/edit/delete pxc single node cluster', async ({ request, page }) => { - const clusterName = 'test-pxc-cluster' + const clusterName = th.randomName('test-pxc-cluster') const pxcPayload = { apiVersion: 'everest.percona.com/v1alpha1', kind: 'DatabaseCluster', @@ -121,7 +122,7 @@ test('create/edit/delete pxc single node cluster', async ({ request, page }) => }) test('expose pxc cluster after creation', async ({ request, page }) => { - const clusterName = 'exposed-pxc-cluster' + const clusterName = th.randomName('exposed-pxc-cluster') const pxcPayload = { apiVersion: 'everest.percona.com/v1alpha1', kind: 'DatabaseCluster', @@ -200,7 +201,7 @@ test('expose pxc cluster after creation', async ({ request, page }) => { test('expose pxc cluster on EKS to the public internet and scale up', async ({ request, page }) => { test.setTimeout(60000) - const clusterName = 'eks-pxc-cluster' + const clusterName = th.randomName('eks-pxc-cluster') const pxcPayload = { apiVersion: 'everest.percona.com/v1alpha1', kind: 'DatabaseCluster', From 24fcf0d0ae70a83a100ffaf106e66f9761032ea7 Mon Sep 17 00:00:00 2001 From: Oksana Grishchenko Date: Mon, 9 Oct 2023 11:24:06 +0200 Subject: [PATCH 10/10] timeout & restores fix --- .../tests/database-cluster-restores.spec.ts | 17 +++++++++++++---- api-tests/tests/helpers.ts | 2 +- api-tests/tests/kubernetes.spec.ts | 5 ----- api-tests/tests/psmdb-clusters.spec.ts | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/api-tests/tests/database-cluster-restores.spec.ts b/api-tests/tests/database-cluster-restores.spec.ts index f80ff21f..23408244 100644 --- a/api-tests/tests/database-cluster-restores.spec.ts +++ b/api-tests/tests/database-cluster-restores.spec.ts @@ -55,25 +55,34 @@ 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() + restore = await response.json() + // update restore restore.spec.dbClusterName = clName2 response = await request.put(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`, { data: restore, }) 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/kubernetes.spec.ts b/api-tests/tests/kubernetes.spec.ts index 72e49c98..8cb9c0a0 100644 --- a/api-tests/tests/kubernetes.spec.ts +++ b/api-tests/tests/kubernetes.spec.ts @@ -15,11 +15,6 @@ import {expect, test} from '@fixtures' import * as th from './helpers' - -// testPrefix is used to differentiate between several workers -// running this test to avoid conflicts in instance names -const testPrefix = `${(Math.random() + 1).toString(36).substring(10)}` - let kubernetesId test.beforeAll(async ({request}) => { diff --git a/api-tests/tests/psmdb-clusters.spec.ts b/api-tests/tests/psmdb-clusters.spec.ts index 05dc834b..5b221f52 100644 --- a/api-tests/tests/psmdb-clusters.spec.ts +++ b/api-tests/tests/psmdb-clusters.spec.ts @@ -231,7 +231,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}`)