diff --git a/api-tests/tests/backup-storages.spec.ts b/api-tests/tests/backup-storages.spec.ts index 58adf3e4..84008c59 100644 --- a/api-tests/tests/backup-storages.spec.ts +++ b/api-tests/tests/backup-storages.spec.ts @@ -13,14 +13,14 @@ // 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 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', @@ -37,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) @@ -88,13 +86,10 @@ test('add/list/get/delete backup storage success', async ({ request }) => { // delete const deleted = await request.delete(`/v1/backup-storages/${name}`) - expect(deleted.ok()).toBeTruthy() }) test('create backup storage failures', async ({ request }) => { - req = request - const testCases = [ { payload: {}, @@ -157,10 +152,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 +166,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 +193,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 +205,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 +213,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..23408244 100644 --- a/api-tests/tests/database-cluster-restores.spec.ts +++ b/api-tests/tests/database-cluster-restores.spec.ts @@ -12,223 +12,233 @@ // 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.suffixedName('storage') - const clName = th.suffixedName('cluster') - const clName2 = th.suffixedName('cluster2') - const backupName = th.suffixedName('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 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.suffixedName('storage') - const clName1 = th.suffixedName('cluster1') - const clName2 = th.suffixedName('cluster2') - const backupName = th.suffixedName('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 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() - } + let 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) + 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() + let result = await response.json() + + expect(result.spec).toMatchObject(restore.spec) - response = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clName2}/restores`) - result = await response.json() + response = await request.get(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`) + expect(response.ok()).toBeTruthy() + result = await response.json() - expect(result.items).toHaveLength(1) + // update restore with not existing dbClusterName + result.spec.dbClusterName = 'not-existing-cluster' + response = await request.put(`/v1/kubernetes/${kubernetesId}/database-cluster-restores/${restoreName}`, { + data: result, + }) + 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('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.suffixedName('storage') - const backupName = th.suffixedName('backup') - const clName = th.suffixedName('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 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('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) }) 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/helpers.ts b/api-tests/tests/helpers.ts index acf5e9ff..3327d1a0 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)}` +const testSuffix = () => `${(Math.random() + 1).toString(36).substring(8)}` -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..8cb9c0a0 100644 --- a/api-tests/tests/kubernetes.spec.ts +++ b/api-tests/tests/kubernetes.spec.ts @@ -12,72 +12,72 @@ // 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' - -// 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)}` +import {expect, test} from '@fixtures' +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('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..972433f2 100644 --- a/api-tests/tests/monitoring-instances.spec.ts +++ b/api-tests/tests/monitoring-instances.spec.ts @@ -13,72 +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' -// 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}`) - } -}) - -test('create monitoring instance with api key', async ({ request }) => { - const data = { - type: 'pmm', - name: `${testPrefix}-key`, - 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) -}) - -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: `${testPrefix}-pass`, - 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() @@ -86,292 +36,314 @@ 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) - } finally { - server.closeAllConnections() - await new Promise((resolve) => server.close(() => resolve())) - } + + await th.deleteMonitoringInstance(request, name) }) -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: {}, - } - - const response = await request.post('/v1/monitoring-instances', { data }) +test('list monitoring instances', async ({request}) => { + const testPrefix = th.randomName() - expect(response.status()).toBe(400) -}) + const names = await th.createMonitoringInstances(request, testPrefix) -test('list monitoring instances', async ({ request }) => { - const namePrefix = 'list-' + const response = await request.get('/v1/monitoring-instances') - await createInstances(request, namePrefix) + expect(response.ok()).toBeTruthy() + const list = await response.json() - const response = await request.get('/v1/monitoring-instances') + expect(list.filter((i) => i.name.startsWith(`${testPrefix}`)).length).toBe(3) - expect(response.ok()).toBeTruthy() - const list = await response.json() - expect(list.filter((i) => i.name.startsWith(`${namePrefix}${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] +test('get monitoring instance', async ({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() + const response = await request.get(`/v1/monitoring-instances/${name}`) + expect(response.ok()).toBeTruthy() + const i = await response.json() - expect(i.name).toBe(name) + 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] +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] - let response = await request.get('/v1/monitoring-instances') + let response = await request.get('/v1/monitoring-instances') + let list = await response.json() - expect(response.ok()).toBeTruthy() - let list = await response.json() + expect(list.filter((i) => i.name.startsWith(`${testPrefix}`)).length).toBe(3) - 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/${name}`) + expect(response.status()).toBe(404) - response = await request.delete(`/v1/monitoring-instances/${name}`) - expect(response.ok()).toBeTruthy() + response = await request.get('/v1/monitoring-instances') + list = await response.json() - response = await request.get('/v1/monitoring-instances') - expect(response.ok()).toBeTruthy() - list = await response.json() + expect(list.filter((i) => i.name.startsWith(`${testPrefix}`)).length).toBe(2) - expect(list.filter((i) => i.name.startsWith(`${namePrefix}${testPrefix}`)).length).toBe(2) + await th.deleteMonitoringInstances(request, names.filter((n) => n != name)) }) -test('patch monitoring instance', async ({ request }) => { - const names = await createInstances(request, 'patch-monitoring-') - const name = names[1] +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) + 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] +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() - const created = await response.json() + 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) + 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] +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() - const getJson = await updated.json() + expect(updated.ok()).toBeTruthy() + 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] +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() + const getJson = await updated.json() + expect(getJson.message).toMatch('Pmm key is required') - expect(getJson.message).toMatch('Pmm key is required') + 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 data = { - type: 'pmm', - name: `${testPrefix}-fail`, - url: 'http://monitoring', - pmm: { - apiKey: '123', - }, - } - const response = await request.post('/v1/monitoring-instances', { data }) - - expect(response.ok()).toBeTruthy() - const created = await response.json() - - const name = created.name - - 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.status()).toBe(400) - expect((await response.json()).message).toMatch(testCase.errorText) - } -}) + expect(response.ok()).toBeTruthy() -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' } }) + 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) + } - expect(response.status()).toBe(404) + await th.deleteMonitoringInstance(request, name) }) -test('delete: monitoring instance not found', async ({ request }) => { - const name = 'non-existent' - const response = await request.delete(`/v1/monitoring-instances/${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'}}) - 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('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) }) -async function createInstances(request: APIRequestContext, namePrefix: string, count = 3): Promise { - const data = { - type: 'pmm', - name: '', - url: 'http://monitoring-instance', - pmm: { - apiKey: '123', - }, - } - - const res = [] +test('get: monitoring instance not found', async ({request}) => { + const name = 'non-existent' + const response = await request.get(`/v1/monitoring-instances/${name}`) - 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() - } + expect(response.status()).toBe(404) +}) - return res -} 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..5b221f52 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', @@ -230,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}`) 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',