Feature/config manager push telemetry - #122
Conversation
phalestrivir
left a comment
There was a problem hiding this comment.
You may want to wait until the ESV variables PR is in that adds the global flags you need to make the changes for this PR (since you will need them)
| /* | ||
| FRODO_MOCK=record FRODO_NO_CACHE=1 FRODO_HOST=https://openam-frodo-dev.forgeblocks.com/am frodo config-manager push telemetry -c otlp -N datadog -e test-value -D test/e2e/exports/fr-config-manager/cloud | ||
| FRODO_MOCK=record FRODO_NO_CACHE=1 FRODO_HOST=https://openam-frodo-dev.forgeblocks.com/am frodo config-manager push telemetry -D test/e2e/exports/fr-config-manager/cloud | ||
| */ |
There was a problem hiding this comment.
Add another test for importing using only the -c flag (no -n flag), and have it import the splunk configuration that you add in so we can also test importing splunk.
927a373 to
2c24ca1
Compare
| const { CLOUD_DEPLOYMENT_TYPE_KEY, FORGEOPS_DEPLOYMENT_TYPE_KEY } = | ||
| frodo.utils.constants; | ||
|
|
||
| const deploymentTypes = [ | ||
| CLOUD_DEPLOYMENT_TYPE_KEY, | ||
| FORGEOPS_DEPLOYMENT_TYPE_KEY, | ||
| ]; |
| return false; | ||
| } | ||
|
|
||
| export async function configManagerImportTelemetry( |
| command | ||
| ); | ||
|
|
||
| const getTokensIsSuccessful = await getTokens( |
There was a problem hiding this comment.
Missing check before this. Need to ensure category is provided if name is also provided:
if (options.name && !options.category) {
printMessage(
'Named telemetry config requires category (e.g. --category otlp)',
'error'
);
process.exitCode = 1;
program.help();
}| const importData: TelemetryExportInterface = { | ||
| telemetry: Object.fromEntries( | ||
| categories.map((cat) => [cat, []]) | ||
| ) as TelemetryExportInterface['telemetry'], | ||
| }; |
There was a problem hiding this comment.
I would change this to:
const importData = {
telemetry: Object.fromEntries(
categories.map((cat) => [cat, []])
),
} as TelemetryExportInterface;I think that will fix the type issues while being a big more readable.
| .filter((f) => !name || f === `${name}.json`); | ||
| for (const file of files) { | ||
| const filePath = `${catDir}/${file}`; | ||
| const provider = readJsonFile(filePath) as any; |
There was a problem hiding this comment.
I would change any to LogExporterSkeleton
There was a problem hiding this comment.
I would delete this one. I think we should only have one otlp test file
| */ | ||
|
|
||
| /* | ||
| FRODO_MOCK=record FRODO_NO_CACHE=1 FRODO_HOST=https://openam-frodo-dev.forgeblocks.com/am frodo config-manager push telemetry -n test-otlp -E TELEMETRY_HEADER_OTLP_TEST_OTLP_API_KEY=test-value -E TELEMETRY_HEADER_OTLP_TEST_OTLP_API_SECRET=test-value -D test/e2e/exports/fr-config-manager/cloud |
There was a problem hiding this comment.
This one needs -n to become -c, since -n by itself shouldn't work
|
|
||
| /* | ||
| FRODO_MOCK=record FRODO_NO_CACHE=1 FRODO_HOST=https://openam-frodo-dev.forgeblocks.com/am frodo config-manager push telemetry -n test-otlp -E TELEMETRY_HEADER_OTLP_TEST_OTLP_API_KEY=test-value -E TELEMETRY_HEADER_OTLP_TEST_OTLP_API_SECRET=test-value -D test/e2e/exports/fr-config-manager/cloud | ||
| FRODO_MOCK=record FRODO_NO_CACHE=1 FRODO_HOST=https://openam-frodo-dev.forgeblocks.com/am frodo config-manager push telemetry -c otlp -n datadog -E TELEMETRY_HEADER_OTLP_DATADOG_DD_API_KEY=test-value -D test/e2e/exports/fr-config-manager/cloud |
There was a problem hiding this comment.
Change -n datadog to -n test-otlp since we are going to get rid of the datadog one
| FRODO_MOCK=record FRODO_NO_CACHE=1 FRODO_HOST=https://openam-frodo-dev.forgeblocks.com/am frodo config-manager push telemetry -c otlp -n datadog -E TELEMETRY_HEADER_OTLP_DATADOG_DD_API_KEY=test-value -D test/e2e/exports/fr-config-manager/cloud | ||
| FRODO_MOCK=record FRODO_NO_CACHE=1 FRODO_HOST=https://openam-frodo-dev.forgeblocks.com/am frodo config-manager push telemetry -c splunk -n test -D test/e2e/exports/fr-config-manager/cloud | ||
| FRODO_MOCK=record FRODO_NO_CACHE=1 FRODO_HOST=https://openam-frodo-dev.forgeblocks.com/am frodo config-manager push telemetry -c splunk -D test/e2e/exports/fr-config-manager/cloud | ||
| */ |
There was a problem hiding this comment.
We should add one more test where you import everything with just -D. This is the only test we should expect to have fail (because it will be importing multiple exporters which isn't allowed), all other tests should succeed
| describe('frodo config-manager push telemetry', () => { | ||
| test(`"frodo config-manager push telemetry -n test-otlp -E TELEMETRY_HEADER_OTLP_TEST_OTLP_API_KEY=test-value -E TELEMETRY_HEADER_OTLP_TEST_OTLP_API_SECRET=test-value -D ${telemetryDir}": should push telemetry to cloud`, async () => { | ||
| const CMD = `frodo config-manager push telemetry -n test-otlp -E TELEMETRY_HEADER_OTLP_TEST_OTLP_API_KEY=test-value -E TELEMETRY_HEADER_OTLP_TEST_OTLP_API_SECRET=test-value -D ${telemetryDir}`; | ||
| await testSuccess(CMD, env); | ||
| }); | ||
|
|
||
| test(`"frodo config-manager push telemetry -c otlp -n datadog -E TELEMETRY_HEADER_OTLP_DATADOG_DD_API_KEY=test-value -D ${telemetryDir}": should fail to import otlp telemetry`, async () => { | ||
| const CMD = `frodo config-manager push telemetry -c otlp -n datadog -E TELEMETRY_HEADER_OTLP_DATADOG_DD_API_KEY=test-value -D ${telemetryDir}`; | ||
| await testFail(CMD, env); | ||
| }); | ||
|
|
||
| test(`"frodo config-manager push telemetry -c splunk -n test -D ${telemetryDir}": should fail to import splunk telemetry`, async () => { | ||
| const CMD = `frodo config-manager push telemetry -c splunk -n test -D ${telemetryDir}`; | ||
| await testFail(CMD, env); | ||
| }); | ||
|
|
||
| test(`"frodo config-manager push telemetry -c splunk -D ${telemetryDir}": should fail to import splunk telemetry`, async () => { | ||
| const CMD = `frodo config-manager push telemetry -c splunk -D ${telemetryDir}`; | ||
| await testSuccess(CMD, env); | ||
| }); |
There was a problem hiding this comment.
Make sure to update the test descriptions accordingly after you make the changes I suggested.
|
Also, ensure that the config import and config export tests are passing, since I updated the library to include telemetry in the full export/import. You don't need to re-record those tests, you can just add the network calls to the mock recordings that are missing (the ones for telemetry) and then they should pass again (although you may need to still run update to update the snapshots). You can find those mock requests from the mock recordings for your config-manager push/pull test mocks. Let me know if you have questions on how to do this, but we don't want to re-record those because we don't want to break anything in the tenant |
No description provided.