Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVEREST-1723 Sharding API test #907

Merged
merged 9 commits into from
Dec 12, 2024
70 changes: 69 additions & 1 deletion api-tests/tests/psmdb-clusters.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { test, expect } from '@fixtures'
import {checkError, deleteDBCluster, testsNs} from "@tests/tests/helpers";


test.setTimeout(120 * 1000)
test.setTimeout(240 * 1000)

test.beforeAll(async ({ request }) => {
const engineResponse = await request.get(`/v1/namespaces/${testsNs}/database-engines/percona-server-mongodb-operator`)
Expand Down Expand Up @@ -264,3 +264,71 @@ test('expose psmdb cluster on EKS to the public internet and scale up', async ({

await deleteDBCluster(request, page, clusterName)
})

test('sharded psmdb cluster', async ({ request, page }) => {
const clusterName = 'sharding-psmdb'
const psmdbPayload = {
apiVersion: 'everest.percona.com/v1alpha1',
kind: 'DatabaseCluster',
metadata: {
name: clusterName,
namespace: testsNs,
},
spec: {
sharding: {
enabled: true,
shards: 2,
configServer: {
replicas: 1,
},
},
engine: {
version: '7.0.14-8',
type: 'psmdb',
replicas: 1,
storage: {
size: '25G',
},
resources: {
cpu: '1',
memory: '1G',
},
},
proxy: {
type: 'mongos', // HAProxy is the default option. However using proxySQL is available
replicas: 1,
expose: {
type: 'internal',
},
},
},
}

const created = await request.post(`/v1/namespaces/${testsNs}/database-clusters`, {
data: psmdbPayload,
})
await checkError(created)

for (let i = 0; i < 30; i++) {
await page.waitForTimeout(5000)

const psmdbCluster = await request.get(`/v1/namespaces/${testsNs}/database-clusters/${clusterName}`)

await checkError(psmdbCluster)

const result = (await psmdbCluster.json())

// waiting for 4 components to be ready (1 node * 2 shards + 1 configservers + 1 mongos)
if (typeof result.status === 'undefined' || typeof result.status.size === 'undefined' || result.status.size !== 4 || result.status.ready !== 4) {
continue
}

expect(result.metadata.name).toBe(clusterName)
expect(result.spec).toMatchObject(psmdbPayload.spec)
expect(result.status.status).toBe('ready')

break
}

await deleteDBCluster(request, page, clusterName)
})
Loading