Skip to content

Commit

Permalink
Create a registry for agent config tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gbamparop committed May 20, 2022
1 parent e918b75 commit fc5fa66
Showing 1 changed file with 57 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fc5fa66

Please sign in to comment.