Skip to content

Commit

Permalink
PMM-7 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yurkovychv committed Aug 21, 2023
1 parent 1f2e280 commit f55256f
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 72 deletions.
63 changes: 50 additions & 13 deletions cli/test-setup/docker-compose-scrape-intervals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
version: '3.7'

volumes:
scrape-intervals-pmm-server-data:
scrape-interval-pmm-server-data:

networks:
scrape-intervals:
scrape-interval:

services:
pmm-server-scrape-intervals:
pmm-server-scrape-interval:
image: ${DOCKER_VERSION:-perconalab/pmm-server:dev-latest}
container_name: pmm-server-scrape-intervals
container_name: pmm-server-scrape-interval
healthcheck:
test: [ "CMD", "curl", "-f", "http://127.0.0.1/ping" ]
interval: 3s
Expand All @@ -21,29 +21,66 @@ services:
- "1443:443"
environment:
- PMM_DEBUG=1
volumes:
- scrape-intervals-pmm-server-data:/srv
networks:
- scrape-intervals
- scrape-interval

pmm-client-scrape-intervals:
pmm-client-scrape-interval:
image: ${CLIENT_DOCKER_VERSION:-perconalab/pmm-client:dev-latest}
container_name: pmm-client-scrape-intervals
container_name: pmm-client-scrape-interval
depends_on:
pmm-server-scrape-intervals:
pmm-server-scrape-interval:
condition: service_healthy
environment:
- PMM_AGENT_SETUP=1
- PMM_AGENT_SERVER_ADDRESS=pmm-server-scrape-intervals
- PMM_AGENT_SERVER_ADDRESS=pmm-server-scrape-interval
- PMM_AGENT_SERVER_USERNAME=admin
- PMM_AGENT_SERVER_PASSWORD=admin
- PMM_AGENT_PORTS_MIN=41000
- PMM_AGENT_PORTS_MAX=41500
- PMM_AGENT_SERVER_INSECURE_TLS=1
- PMM_AGENT_CONFIG_FILE=config/pmm-agent.yaml
- PMM_AGENT_SETUP_NODE_NAME=pmm-client-scrape-intervals
- PMM_AGENT_SETUP_NODE_NAME=pmm-client-scrape-interval
- PMM_AGENT_SETUP_FORCE=1
- PMM_AGENT_SETUP_NODE_TYPE=container
restart: on-failure
networks:
- scrape-intervals
- scrape-interval

pmm-server-custom-scrape-interval:
image: ${DOCKER_VERSION:-perconalab/pmm-server:dev-latest}
container_name: pmm-server-custom-scrape-interval
healthcheck:
test: [ "CMD", "curl", "-f", "http://127.0.0.1/ping" ]
interval: 3s
timeout: 2s
retries: 20
ports:
- "280:80"
- "2443:443"
environment:
- PMM_DEBUG=1
- PMM_PROMSCRAPE_MAX_SCRAPE_SIZE=128MiB
networks:
- scrape-interval

pmm-client-custom-scrape-interval:
image: ${CLIENT_DOCKER_VERSION:-perconalab/pmm-client:dev-latest}
container_name: pmm-client-custom-scrape-interval
depends_on:
pmm-server-custom-scrape-interval:
condition: service_healthy
environment:
- PMM_AGENT_SETUP=1
- PMM_AGENT_SERVER_ADDRESS=pmm-server-custom-scrape-interval
- PMM_AGENT_SERVER_USERNAME=admin
- PMM_AGENT_SERVER_PASSWORD=admin
- PMM_AGENT_PORTS_MIN=41000
- PMM_AGENT_PORTS_MAX=41500
- PMM_AGENT_SERVER_INSECURE_TLS=1
- PMM_AGENT_CONFIG_FILE=config/pmm-agent.yaml
- PMM_AGENT_SETUP_NODE_NAME=pmm-server-custom-scrape-interval
- PMM_AGENT_SETUP_FORCE=1
- PMM_AGENT_SETUP_NODE_TYPE=container
restart: on-failure
networks:
- scrape-interval
37 changes: 28 additions & 9 deletions cli/tests/pmm-client-docker.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect } from '@playwright/test';
import { test } from '@playwright/test';
import * as cli from '@helpers/cliHelper';

test.describe('PMM Client Docker CLI tests', async () => {
Expand Down Expand Up @@ -75,16 +75,35 @@ test.describe('PMM Client Docker CLI tests', async () => {
await output.outContains('Service removed.');
});

test('@PMM-T1664 Verify vm_agents default value of -promscrape.maxScapeSize', async ({page}) => {
const expectedScrapeSize = '64';
test.only('@PMM-T1664 @PMM-T1665 Verify vm_agents -promscrape.maxScapeSize parameter', async ({page}) => {
const defaultScrapeSize = '64';
const customScrapeSize = '128';

await (await cli.exec(`docker-compose -f test-setup/docker-compose-scrape-intervals.yml up -d`)).assertSuccess();
await (await cli.exec('sudo pmm-admin config --force \'--server-url=https://admin:[email protected]:1443\' --server-insecure-tls 127.0.0.1')).assertSuccess()
await test.step('verify client docker logs for default value', async () => {
await (await cli.exec(`docker-compose -f cli/test-setup/docker-compose-scrape-intervals.yml up -d`)).assertSuccess();
await page.waitForTimeout(10_000);

const scrapeSizeContainer = await cli.exec('docker logs pmm-client-scrape-intervals 2>&1 | grep \'promscrape.maxScrapeSize.*vm_agent\' | tail -1');
await scrapeSizeContainer.outContains(`promscrape.maxScrapeSize=\\\"${expectedScrapeSize}MiB\\\"`)
const scrapeSizeLog = await cli.exec('docker logs pmm-client-scrape-interval 2>&1 | grep \'promscrape.maxScrapeSize.*vm_agent\' | tail -1');
await scrapeSizeLog.outContains(`promscrape.maxScrapeSize=\\\"${defaultScrapeSize}MiB\\\"`)

const scrapeSizeTarball = await cli.exec('ps aux | grep -v \'grep\' | grep \'vm_agent\' | tail -1')
await scrapeSizeTarball.outContains(`promscrape.maxScrapeSize=${expectedScrapeSize}MiB`)
})
await test.step('verify client docker logs for custom value', async () => {
const scrapeSizeLog = await cli.exec('docker logs pmm-client-custom-scrape-interval 2>&1 | grep \'promscrape.maxScrapeSize.*vm_agent\' | tail -1');
await scrapeSizeLog.outContains(`promscrape.maxScrapeSize=\\\"${customScrapeSize}MiB\\\"`)
})

await test.step('verify logs from binary for default value', async () => {
await (await cli.exec('sudo pmm-admin config --force \'--server-url=https://admin:[email protected]:1443\' --server-insecure-tls 127.0.0.1')).assertSuccess()

const scrapeSizeLog = await cli.exec('ps aux | grep -v \'grep\' | grep \'vm_agent\' | tail -1')
await scrapeSizeLog.outContains(`promscrape.maxScrapeSize=${defaultScrapeSize}MiB`)
})

await test.step('verify logs from binary for custom value', async () => {
await (await cli.exec('sudo pmm-admin config --force \'--server-url=https://admin:[email protected]:2443\' --server-insecure-tls 127.0.0.1')).assertSuccess()

const scrapeSizeLog = await cli.exec('ps aux | grep -v \'grep\' | grep \'vm_agent\' | tail -1')
await scrapeSizeLog.outContains(`promscrape.maxScrapeSize=${customScrapeSize}MiB`)
})
});
});
50 changes: 0 additions & 50 deletions tests/cli/generic_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ After(async ({ I }) => {
await I.verifyCommand('docker rm -f pg-local ubuntu');
});


Scenario(
'PMM-T1201 Verify yum-cron updates are removed from PMM Server @settings',
async ({ I }) => {
Expand All @@ -38,55 +37,6 @@ Scenario(
);
},
);
Scenario(
'@PMM-T1664 Verify vm_agents default value of -promscrape.maxScapeSize flag @cli',
async ({ I }) => {
const serverIp = await I.verifyCommand('curl ifconfig.me');
const containerName = 'pmm-server-default-scrape';
const expectedScrapeSize = '64';

await I.verifyCommand(`docker run -d -p 1443:443 -p 180:80 --name ${containerName} perconalab/pmm-server:dev-latest`);
await I.asyncWaitFor(async () => await I.verifyCommand('echo $(curl -s -o /dev/null -w \'%{http_code}\' 0.0.0.0:180/ping)') === '200', 100);

const containerIp = await I.verifyCommand(`docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${containerName}`);

await I.verifyCommand(`docker run -d --name pmm-client-scrape --env PMM_AGENT_SETUP=1 --env PMM_AGENT_SERVER_ADDRESS=${containerIp}:443 --env PMM_AGENT_SERVER_USERNAME=admin --env PMM_AGENT_SERVER_PASSWORD=admin --env PMM_AGENT_PORTS_MIN=41000 --env PMM_AGENT_PORTS_MAX=41500 --env PMM_AGENT_SERVER_INSECURE_TLS=1 --env PMM_AGENT_CONFIG_FILE=config/pmm-agent.yaml --env PMM_AGENT_SETUP_NODE_NAME=pmm-client-scrape-container --env PMM_AGENT_SETUP_FORCE=1 --env PMM_AGENT_SETUP_NODE_TYPE=container perconalab/pmm-client:dev-latest`);
await I.verifyCommand(`sudo pmm-admin config --force '--server-url=https://admin:[email protected]:1443' --server-insecure-tls ${serverIp}`);

I.wait(5);

const scrapeSizeTarball = await I.verifyCommand('ps aux | grep -v \'grep\' | grep \'vm_agent\' | tail -1 | grep -o \'promscrape.maxScrapeSize=.*MiB\'');
const scrapeSizeContainer = await I.verifyCommand('docker logs pmm-client-scrape 2>&1 | grep \'promscrape.maxScrapeSize.*vm_agent\' | tail -1 | grep -o \'promscrape.maxScrapeSize=".*MiB"\'');

I.assertEqual(scrapeSizeContainer, `promscrape.maxScrapeSize="${expectedScrapeSize}MiB"`, 'Max scrape size from client container logs does not match expected value!');
I.assertEqual(scrapeSizeTarball, `promscrape.maxScrapeSize=${expectedScrapeSize}MiB`, 'Max scrape size from local client logs does not match expected value!');
},
);

Scenario(
'@PMM-T1665 Verify that vm_agents -promscrape.maxScapeSize flag value can be set by user @cli',
async ({ I }) => {
const serverIp = await I.verifyCommand('curl ifconfig.me');
const containerName = 'pmm-server-custom-scrape';
const expectedScrapeSize = '128';

await I.verifyCommand(`docker run -d -p 2443:443 -p 280:80 --name ${containerName} --env PMM_PROMSCRAPE_MAX_SCRAPE_SIZE=${expectedScrapeSize}MiB perconalab/pmm-server:dev-latest`);
await I.asyncWaitFor(async () => await I.verifyCommand('echo $(curl -s -o /dev/null -w \'%{http_code}\' 0.0.0.0:280/ping)') === '200', 100);

const containerIp = await I.verifyCommand(`docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${containerName}`);

await I.verifyCommand(`docker run -d --name pmm-client-scrape --env PMM_AGENT_SETUP=1 --env PMM_AGENT_SERVER_ADDRESS=${containerIp}:443 --env PMM_AGENT_SERVER_USERNAME=admin --env PMM_AGENT_SERVER_PASSWORD=admin --env PMM_AGENT_PORTS_MIN=41000 --env PMM_AGENT_PORTS_MAX=41500 --env PMM_AGENT_SERVER_INSECURE_TLS=1 --env PMM_AGENT_CONFIG_FILE=config/pmm-agent.yaml --env PMM_AGENT_SETUP_NODE_NAME=pmm-client-scrape-container --env PMM_AGENT_SETUP_FORCE=1 --env PMM_AGENT_SETUP_NODE_TYPE=container perconalab/pmm-client:dev-latest`);
await I.verifyCommand(`sudo pmm-admin config --force '--server-url=https://admin:[email protected]:2443' --server-insecure-tls ${serverIp}`);

const scrapeSizeTarball = await I.verifyCommand('ps aux | grep -v \'grep\' | grep \'vm_agent\' | tail -1 | grep -o \'promscrape.maxScrapeSize=.*MiB\'');
const scrapeSizeContainer = await I.verifyCommand('docker logs pmm-client-scrape 2>&1 | grep \'promscrape.maxScrapeSize.*vm_agent\' | tail -1 | grep -o \'promscrape.maxScrapeSize=".*MiB"\'');

I.wait(5);

I.assertEqual(scrapeSizeContainer, `promscrape.maxScrapeSize="${expectedScrapeSize}MiB"`, 'Max scrape size from client container logs does not match expected value!');
I.assertEqual(scrapeSizeTarball, `promscrape.maxScrapeSize=${expectedScrapeSize}MiB`, 'Max scrape size from local client logs does not match expected value!');
},
);

Scenario(
'@PMM-T1696 Verify that PostgreSQL exporter collects uptime on Ubuntu @cli',
Expand Down

0 comments on commit f55256f

Please sign in to comment.