From fc5fa667f00aa2e4a008ee981655c7c6a5e4764d Mon Sep 17 00:00:00 2001 From: gbamparop Date: Fri, 20 May 2022 09:22:42 +0100 Subject: [PATCH] Create a registry for agent config tests --- .../agent_configuration.spec.ts | 109 +++++++++--------- 1 file changed, 57 insertions(+), 52 deletions(-) diff --git a/x-pack/test/apm_api_integration/tests/settings/agent_configuration/agent_configuration.spec.ts b/x-pack/test/apm_api_integration/tests/settings/agent_configuration/agent_configuration.spec.ts index 76b1d90c137c6..cb627d256d68a 100644 --- a/x-pack/test/apm_api_integration/tests/settings/agent_configuration/agent_configuration.spec.ts +++ b/x-pack/test/apm_api_integration/tests/settings/agent_configuration/agent_configuration.spec.ts @@ -387,72 +387,77 @@ export default function agentConfigurationTests({ getService }: FtrProviderConte ); registry.when( - 'agent configuration when data is loaded', - { config: 'basic', archives: [archiveName] }, + 'Agent configurations through fleet', + { config: 'basic', archives: ['apm_mappings_only_8.0.0'] }, () => { - describe('agent configurations through fleet', () => { - const name = 'myservice'; - const environment = 'development'; - const testConfig = { - service: { name, environment }, - settings: { transaction_sample_rate: '0.9' }, - }; - - let agentConfiguration: - | APIReturnType<'GET /api/apm/settings/agent-configuration/view'> - | undefined; + const name = 'myservice'; + const environment = 'development'; + const testConfig = { + service: { name, environment }, + settings: { transaction_sample_rate: '0.9' }, + }; + + let agentConfiguration: + | APIReturnType<'GET /api/apm/settings/agent-configuration/view'> + | undefined; + + before(async () => { + log.debug('creating agent configuration'); + await createConfiguration(testConfig); + const { body } = await findExactConfiguration(name, environment); + agentConfiguration = body; + }); - before(async () => { - log.debug('creating agent configuration'); - await createConfiguration(testConfig); - const { body } = await findExactConfiguration(name, environment); - agentConfiguration = body; - }); + after(async () => { + await deleteConfiguration(testConfig); + }); - after(async () => { - await deleteConfiguration(testConfig); - await synthtraceEsClient.clean(); - }); + it(`should have 'applied_by_agent=false' when there are no agent config metrics for this etag`, async () => { + expect(agentConfiguration?.applied_by_agent).to.be(false); + }); - it(`should have 'applied_by_agent=false' when there are no agent config metrics for this etag`, async () => { - expect(agentConfiguration?.applied_by_agent).to.be(false); + describe('when there are agent config metrics for this etag', () => { + before(async () => { + const start = new Date().getTime(); + const end = moment(start).add(5, 'minutes').valueOf(); + + await addAgentConfigMetrics({ + synthtraceEsClient, + start, + end, + etag: agentConfiguration?.etag, + }); }); - describe('when there are agent config metrics for this etag', () => { - before(async () => { - const start = new Date().getTime(); - const end = moment(start).add(5, 'minutes').valueOf(); - - await addAgentConfigMetrics({ - synthtraceEsClient, - start, - end, - etag: agentConfiguration?.etag, - }); - }); + after(() => synthtraceEsClient.clean()); - it(`should have 'applied_by_agent=true' when getting a config from all configurations`, async () => { - const { - body: { configurations }, - } = await getAllConfigurations(); + it(`should have 'applied_by_agent=true' when getting a config from all configurations`, async () => { + const { + body: { configurations }, + } = await getAllConfigurations(); - const updatedConfig = configurations.find( - (x) => x.service.name === name && x.service.environment === environment - ); + const updatedConfig = configurations.find( + (x) => x.service.name === name && x.service.environment === environment + ); - expect(updatedConfig?.applied_by_agent).to.be(true); - }); + expect(updatedConfig?.applied_by_agent).to.be(true); + }); - it(`should have 'applied_by_agent=true' when getting a single config`, async () => { - const { - body: { applied_by_agent: appliedByAgent }, - } = await findExactConfiguration(name, environment); + it(`should have 'applied_by_agent=true' when getting a single config`, async () => { + const { + body: { applied_by_agent: appliedByAgent }, + } = await findExactConfiguration(name, environment); - expect(appliedByAgent).to.be(true); - }); + expect(appliedByAgent).to.be(true); }); }); + } + ); + registry.when( + 'agent configuration when data is loaded', + { config: 'basic', archives: [archiveName] }, + () => { it('returns the environments, all unconfigured', async () => { const { body } = await getEnvironments('opbeans-node'); const { environments } = body;