diff --git a/cli/helpers/cli-helper.ts b/cli/helpers/cli-helper.ts index c21e07e83..b2ac9e740 100644 --- a/cli/helpers/cli-helper.ts +++ b/cli/helpers/cli-helper.ts @@ -79,10 +79,10 @@ export async function getMetrics( async () => { const prefix = dockerContainer ? `sudo docker exec ${dockerContainer} ` : ''; const adminList = (await execute(`${prefix || 'sudo '}pmm-admin list`).assertSuccess()).getStdOutLines(); - const serviceId: string = adminList.find((item) => item.includes(serviceName))! + const serviceId: string = adminList.find((item) => item.includes(serviceName)) + ?.trim() .split(' ') - .find((item: string) => item.includes('/service_id/'))! - .trim() ?? ''; + .pop() ?? ''; // Get the last item in the split result if (!serviceId) { throw new Error(`Failed to find '${serviceName}' service is in pmm-admin list output:\n${adminList}`); diff --git a/cli/tests/generic.spec.ts b/cli/tests/generic.spec.ts index 2fc3281f8..faa5e7da8 100644 --- a/cli/tests/generic.spec.ts +++ b/cli/tests/generic.spec.ts @@ -175,8 +175,8 @@ test.describe('PMM Client "Generic" CLI tests', async () => { await output.assertSuccess(); // there are no request for those urls. but there are requests for /local/status await output.stderr.containsMany([ - 'POST /v1/inventory/Services/List HTTP/1.1', - 'POST /v1/inventory/Agents/List HTTP/1.1', + 'GET /v1/inventory/services', + 'GET /v1/inventory/agents', ]); await output.outContains('.zip created.'); }); @@ -189,8 +189,8 @@ test.describe('PMM Client "Generic" CLI tests', async () => { await output.assertSuccess(); // there are no request for those urls. but there are requests for /local/status await output.stderr.containsMany([ - '(*Runtime).Submit() POST /v1/inventory/Services/List HTTP/1.1', - '(*Runtime).Submit() POST /v1/inventory/Agents/List HTTP/1.1', + '(*Runtime).Submit() GET /v1/inventory/services', + '(*Runtime).Submit() GET /v1/inventory/agents', ]); await output.outContains('.zip created.'); }); @@ -267,8 +267,8 @@ test.describe('PMM Client "Generic" CLI tests', async () => { const output = await cli.exec('sudo pmm-admin summary --skip-server --trace'); await output.assertSuccess(); await output.stderr.containsMany([ - '(*Runtime).Submit() POST /v1/inventory/Services/List HTTP/1.1', - '(*Runtime).Submit() POST /v1/inventory/Agents/List HTTP/1.1']); + '(*Runtime).Submit() GET /v1/inventory/services', + '(*Runtime).Submit() GET /v1/inventory/agents']); await output.outContains('.zip created.'); }); @@ -279,8 +279,8 @@ test.describe('PMM Client "Generic" CLI tests', async () => { const output = await cli.exec('sudo pmm-admin summary --skip-server --debug'); await output.assertSuccess(); await output.stderr.containsMany([ - 'POST /v1/inventory/Services/List HTTP/1.1', - 'POST /v1/inventory/Agents/List HTTP/1.1']); + 'GET /v1/inventory/services', + 'GET /v1/inventory/agents']); await output.outContains('.zip created.'); }); @@ -292,8 +292,8 @@ test.describe('PMM Client "Generic" CLI tests', async () => { const output = await cli.exec(`sudo pmm-admin summary --skip-server --json --debug --filename=${ZIP_FILE_NAME}`); await output.assertSuccess(); await output.stderr.containsMany([ - 'POST /v1/inventory/Services/List HTTP/1.1', - 'POST /v1/inventory/Agents/List HTTP/1.1']); + 'GET /v1/inventory/services', + 'GET /v1/inventory/agents']); }); /** @@ -318,8 +318,8 @@ test.describe('PMM Client "Generic" CLI tests', async () => { const output = await cli.exec('sudo pmm-admin summary --pprof --trace'); await output.assertSuccess(); await output.outContainsMany([ - '(*Runtime).Submit() POST /v1/inventory/Services/List HTTP/1.1', - '(*Runtime).Submit() POST /v1/inventory/Agents/List HTTP/1.1', + '(*Runtime).Submit() GET /v1/inventory/services', + '(*Runtime).Submit() GET /v1/inventory/agents', '.zip created.']); const zipName = output.getStdOutLines().find((item) => item.includes('.zip created.'))! .split(' ').at(0) ?? ''; @@ -334,8 +334,8 @@ test.describe('PMM Client "Generic" CLI tests', async () => { const output = await cli.exec('sudo pmm-admin summary --pprof --debug'); await output.assertSuccess(); await output.outContainsMany([ - 'POST /v1/inventory/Services/List HTTP/1.1', - 'POST /v1/inventory/Agents/List HTTP/1.1', + 'GET /v1/inventory/services', + 'GET /v1/inventory/agents', '.zip created.']); const zipName = output.getStdOutLines().find((item) => item.includes('.zip created.'))! .split(' ').at(0) ?? ''; @@ -402,8 +402,8 @@ test.describe('PMM Client "Generic" CLI tests', async () => { const output = await cli.exec(`pmm-admin summary --pprof --debug --filename=${zipName} --skip-server`); await output.assertSuccess(); await output.outContainsMany([ - 'POST /v1/inventory/Services/List HTTP/1.1', - 'POST /v1/inventory/Agents/List HTTP/1.1', + 'GET /v1/inventory/services', + 'GET /v1/inventory/agents', `${zipName} created.`]); expect(readZipFile(zipName), `Verify 'client/pprof/' is present in ${zipName}`).toContain('client/pprof/'); expect(readZipFile(zipName), `Verify there are 8 files in ${zipName}`).toHaveLength(8); diff --git a/cli/tests/mysql-conf-file.spec.ts b/cli/tests/mysql-conf-file.spec.ts index 1a3db8213..57a7fd0a2 100644 --- a/cli/tests/mysql-conf-file.spec.ts +++ b/cli/tests/mysql-conf-file.spec.ts @@ -1,11 +1,12 @@ import { test, expect } from '@playwright/test'; import * as cli from '@helpers/cli-helper'; +import {execute} from "@helpers/cli-helper"; const MYSQL_USER = 'msandbox'; const MYSQL_PASSWORD = 'msandbox'; const ipPort = '127.0.0.1:3318'; -test.describe('Percona Server MySql (PS) Configuration file test ', async () => { +test.describe('Percona Server MySql (PS) Configuration file test', async () => { test.beforeAll(async ({}) => { const result = await cli.exec('docker ps | grep mysql_pmm | awk \'{print $NF}\''); await result.outContains('mysql_pmm', 'MYSQL docker container should exist. please run pmm-framework with --database mysql'); @@ -34,19 +35,22 @@ test.describe('Percona Server MySql (PS) Configuration file test ', async () => let n = 1; for (const host of hosts) { // Add MySQL to monitoring using conf file: - let output = await cli.exec(`sudo pmm-admin add mysql --query-source=perfschema @${confFilePath} mysql_conf_${n++} ${host}`); + let output = await cli.exec(`sudo pmm-admin add mysql --query-source=perfschema @${confFilePath} mysql_conf_${n} ${host}`); await output.assertSuccess(); await output.outContains('MySQL Service added.'); - // Check that MySQL exporter is RUNNING: - const serviceId = output.getStdOutLines().find((item) => item.includes('/service_id/'))!.trim() - .split(':') - .find((item) => item.includes('/service_id/'))! - .trim(); + const adminList = (await execute('sudo pmm-admin list').assertSuccess()).getStdOutLines(); + // eslint-disable-next-line @typescript-eslint/no-loop-func + const serviceId: string = adminList.find((item: string | string[]) => item.includes(`mysql_conf_${n}`)) + ?.trim() + .split(' ') + .pop() ?? ''; // Get the last item in the split result + await expect(async () => { output = await cli.exec(`sudo pmm-admin list | grep _exporter | grep ${serviceId}`); await output.outContains('Running'); }).toPass({ intervals: [2_000], timeout: 10_000 }); + n++; } }); diff --git a/cli/tests/pmm-client-docker.spec.ts b/cli/tests/pmm-client-docker.spec.ts index 4c0e81a9b..6397e350e 100644 --- a/cli/tests/pmm-client-docker.spec.ts +++ b/cli/tests/pmm-client-docker.spec.ts @@ -82,11 +82,11 @@ test.describe('PMM Client Docker CLI tests', async () => { test.describe('-promscrape.maxScapeSize tests', async () => { const defaultScrapeSize = '64'; test.beforeAll(async () => { - await (await cli.exec('docker-compose -f test-setup/docker-compose-scrape-intervals.yml up -d')).assertSuccess(); + await (await cli.exec('docker compose -f test-setup/docker-compose-scrape-intervals.yml up -d')).assertSuccess(); }); test.afterAll(async () => { - await (await cli.exec('docker-compose -f test-setup/docker-compose-scrape-intervals.yml down')).assertSuccess(); + await (await cli.exec('docker compose -f test-setup/docker-compose-scrape-intervals.yml down')).assertSuccess(); }); test('@PMM-T1664 Verify default value for vm_agents -promscrape.maxScapeSize parameter pmm-client container', async ({}) => { diff --git a/cli/tests/pmm-server-only.spec.ts b/cli/tests/pmm-server-only.spec.ts index 315997dd1..4bbe46f52 100644 --- a/cli/tests/pmm-server-only.spec.ts +++ b/cli/tests/pmm-server-only.spec.ts @@ -66,7 +66,7 @@ test.describe('PMM Server CLI tests for Docker Environment Variables', async () test('PMM-T226 run docker container with all valid environment variables not causing any warning or error message', async ({}) => { // @ts-ignore await cli.exec(`docker run -d -p 83:8080 -p 447:8443 - --name PMM-T226 -e PMM_DATA_RETENTION=48h -e PMM_DISABLE_UPDATES=true -e PMM_DISABLE_TELEMETRY=false + --name PMM-T226 -e PMM_DATA_RETENTION=48h -e PMM_ENABLE_UPDATES=false -e PMM_ENABLE_TELEMETRY=false -e PMM_METRICS_RESOLUTION=24h -e PMM_METRICS_RESOLUTION_LR=24h -e PMM_METRICS_RESOLUTION_MR=24h ${DOCKER_IMAGE}`); stopList.push('PMM-T226'); removeList.push('PMM-T226'); diff --git a/cli/tests/proxySql.spec.ts b/cli/tests/proxySql.spec.ts index cdb99be01..f542e85f1 100644 --- a/cli/tests/proxySql.spec.ts +++ b/cli/tests/proxySql.spec.ts @@ -1,9 +1,9 @@ import { test, expect } from '@playwright/test'; import * as cli from '@helpers/cli-helper'; -const PXC_USER = 'admin'; -const PXC_PASSWORD = 'admin'; -const ipPort = '127.0.0.1:6032'; +const PXC_USER = 'proxysql_user'; +const PXC_PASSWORD = 'passw0rd'; +const ipPort = '127.0.0.1:6033'; test.describe('PMM Client CLI tests for ProxySQL', async () => { test.beforeAll(async ({}) => { diff --git a/cli/tests/remove.spec.ts b/cli/tests/remove.spec.ts index 2838261af..7bf1f3803 100644 --- a/cli/tests/remove.spec.ts +++ b/cli/tests/remove.spec.ts @@ -14,7 +14,7 @@ test.describe('PMM Server CLI tests for Docker Environment Variables', async () test.beforeAll(async () => { await cli.exec(`PMM_SERVER_IMAGE=${PMM_SERVER_IMAGE} PMM_CLIENT_IMAGE=${PMM_CLIENT_IMAGE} - docker-compose -f test-setup/docker-compose-pmm-admin-remove.yml up -d`); + docker compose -f test-setup/docker-compose-pmm-admin-remove.yml up -d`); await cli.exec('sleep 10'); for (let i = 0; i < 2; i++) { @@ -28,7 +28,7 @@ test.describe('PMM Server CLI tests for Docker Environment Variables', async () }); test.afterAll(async () => { - await cli.exec('docker-compose -f test-setup/docker-compose-pmm-admin-remove.yml down -v'); + await cli.exec('docker compose -f test-setup/docker-compose-pmm-admin-remove.yml down -v'); }); test('PMM-T1286, PMM-T1287, PMM-T1288, PMM-T1308 - Verify service removal without specifying service name/service id', async ({}) => { @@ -36,7 +36,7 @@ test.describe('PMM Server CLI tests for Docker Environment Variables', async () const output = await cli.exec(`docker exec pmm-client-remove pmm-admin remove ${services[i]}`); await output.exitCodeEquals(1); await output.outContains( - 'We could not find a service associated with the local node. Please provide "Service ID" or "Service name"', + 'We could not find a service associated with the local node. Please provide "Service ID" or "Service name".', ); } diff --git a/tests/remoteInstances/remoteInstancesHelper.js b/tests/remoteInstances/remoteInstancesHelper.js index 6cce3f635..cace365cb 100644 --- a/tests/remoteInstances/remoteInstancesHelper.js +++ b/tests/remoteInstances/remoteInstancesHelper.js @@ -98,7 +98,7 @@ DB_CONFIG = { MYSQL_SERVER_PORT: '3306', POSTGRES_SERVER_PORT: '5432', MONGODB_SERVER_PORT: '27017', - PROXYSQL_SERVER_PORT: '6032', + PROXYSQL_SERVER_PORT: '6033', }; if (process.env.AMI_UPGRADE_TESTING_INSTANCE === 'true' || process.env.OVF_UPGRADE_TESTING_INSTANCE === 'true') { @@ -187,8 +187,8 @@ module.exports = { proxysql_2_1_1: { host: (PMM_SERVER_OVF_AMI_SETUP === 'true' ? SERVER_HOST : 'proxysql'), port: DB_CONFIG.PROXYSQL_SERVER_PORT, - username: 'proxyadmin', - password: 'yxZq!4SGv0A1', + username: 'proxysql_user', + password: 'passw0rd', environment: 'proxy_env', clusterName: 'proxy_clstr', },