Tags: equinix-labs/otel-init-go
Tags
add more helpers (#4) * add some more helpers * rename file to align with its contents * add more helpers and some tests for them Not perfect test coverage but enough to get *some* confidence it's mostly right. More to come. * fix comment that's what I get for copying from otel-cli Signed-off-by: Amy Tobey <[email protected]>
add otel-cli tests (#2) Adds a first pass at full-system testing using otel-cli's server mode. This is working well enough to merge now as a basis for further work. * empty OTEL_EXPORTER_OTLP_INSECURE should not log Turns out strconv.ParseBool returns error on empty string, so this avoids that while keeping it clear how it fails closed. * add a test program This program calls the otel-init-go API, creates one span, then immediately ends it and exits. * make test program dump state to json The test program now writes its state to json on stdout. This output is intended to be captured in tests, to compare against pre-set environment variable configurations. Made otelinit.Config public so it can be tunneled through context and picked up in the test program. There are other ways to accomplish this but it might be useful to folks down the road for debugging. So now the "otel-init-config" value in the context can be used to grab the config without an increase in API surface other than returning context, which like the last API change, it probably should have in the first place. (I fully expect these changes to settle down by the time this PR merges.) * add a safe function for extracting config from context * remove outdated comment * set conf to empty config on retrieval error This code path might never fire but if it does, it probably shouldn't crash :) * add tests! This is the first pass at trying the idea of using a stub program and otel-cli together to validate otel-cli's behavior through real environment variable configuration and connections to an OTLP server (otel-cli). Lots to do, but this is a working start and it's the end of my work day :) * add an explanatory comment to main.go * first pass at data tests This was easier than I thought it would be? Hooray for comparing string/string maps I guess. Also fixed a test failure in 01, that was a mistake in the data :) * move fixtures to testdata/, clean up Now that this seems to be working, move the test fixtures into the testdata/ directory that is a Go standard for things like fixture data. Along the way remove printf stuff that's no longer needed. Also map filename through in Scenario struct so it can be used in errors. * add a full-loop test using otel-cli Discovered I needed to add a wildcard match for especially trace and span ids, but did it for the whole map while I was there. It's not the prettiest approach but I tried writing a cmp.Comparator and it didn't work out, so for now this gets the job done nicely. * add basic github actions test runner * add unit tests for otelinit/config.go * add godoc to type * try not to leak envvars prefixed with GITHUB This could be better but for now should filter out most of the noise and dangerous stuff. And it's a test program so maybe it's ok to be a leetle gross. * get rid of hard-coded paths The setup for the test stub is a little gross but seems to work ok. This is better than a hard-coded path, so let's see how it goes. * download the latest otel-cli release for tests * try the engineerd/configurator downloader instead * try templating the url & set token * fix ordering * avoid releases to avoid needing a token for now Looks like I need to set up token passing for the release-based download to work. Instead, for now, just download the tarball and pull otel-cli out. * simplify stub path, have CI build stub before test * try working-directory instead of path * move build up * fix up horrible comments Signed-off-by: Amy Tobey <[email protected]>