Skip to content

add otel-cli tests#2

Merged
tobert merged 27 commits intomainfrom
add-otel-cli-tests
Aug 25, 2021
Merged

add otel-cli tests#2
tobert merged 27 commits intomainfrom
add-otel-cli-tests

Conversation

@tobert
Copy link
Copy Markdown
Contributor

@tobert tobert commented Aug 19, 2021

[api change] CI, unit tests, and a full system test for otel-init-go. Changes the API to be more testable and carry context.

Uses otel-cli server to validate all the way through.

More to do but this gets otel-init-go to a good enough place for the uses I need at work right now.

Amy Tobey added 26 commits August 18, 2021 17:16
Shellspec looks like the best option for shell-based testing frameworks.

I have no idea if this is gonna work out :)

Signed-off-by: Amy Tobey <[email protected]>
Turns out strconv.ParseBool returns error on empty string, so this
avoids that while keeping it clear how it fails closed.

Signed-off-by: Amy Tobey <[email protected]>
This program calls the otel-init-go API, creates one span, then
immediately ends it and exits.
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.)

Signed-off-by: Amy Tobey <[email protected]>
Signed-off-by: Amy Tobey <[email protected]>
This code path might never fire but if it does, it probably shouldn't
crash :)

Signed-off-by: Amy Tobey <[email protected]>
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 :)

Signed-off-by: Amy Tobey <[email protected]>
not gonna need it, doing it all in Go :)

Signed-off-by: Amy Tobey <[email protected]>
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 :)

Signed-off-by: Amy Tobey <[email protected]>
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.

Signed-off-by: Amy Tobey <[email protected]>
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.

Signed-off-by: Amy Tobey <[email protected]>
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.

Signed-off-by: Amy Tobey <[email protected]>
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.

Signed-off-by: Amy Tobey <[email protected]>
Signed-off-by: Amy Tobey <[email protected]>
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.

Signed-off-by: Amy Tobey <[email protected]>
Signed-off-by: Amy Tobey <[email protected]>
@tobert tobert marked this pull request as ready for review August 24, 2021 01:46
Signed-off-by: Amy Tobey <[email protected]>
ElapsedMS int `json:"elapsed_ms"`
Attributes map[string]string `json:"attributes"`
Events []CliEvent // reader code will stuff kind=event in here
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when equinix-labs/otel-cli#51 merges some of this can go away

// the problem here is we need to wait for otel-cli to start and listen
// so the solution is probably to do some kind of healthcheck on otel-cli's port
// but this works ok for now
time.Sleep(time.Millisecond * 10)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equinix-labs/otel-cli#51 splits the otel-cli server into a reusable package with a little more control over startup so this can go away soon and it gets rid of needing to download otel-cli in the build pipeline which is kinda nice too.

tobert pushed a commit to tobert/boots that referenced this pull request Aug 24, 2021
It's the same launcher but with tests. This will need one more update
when things land on main in otel-init-go but this gets things in shape
for future maintenance.

will update when this PR merges:
equinix-labs/otel-init-go#2

Signed-off-by: Amy Tobey <[email protected]>
Comment thread .github/workflows/ci.yml
with:
name: "otel-cli"
pathInArchive: /otel-cli
url: "https://github.com/equinix-labs/otel-cli/releases/download/v0.0.5/otel-cli-0.0.5-Linux-x86_64.tar.gz"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it require a GITHUB_TOKEN secret? I think I tried that first and it wanted me to set up more stuff and the way these repos are configured I didn't feel it was worth the trouble.

In any case I'll probably refactor this out soon.

@tobert tobert merged commit d3a4ca4 into main Aug 25, 2021
@tobert tobert deleted the add-otel-cli-tests branch August 25, 2021 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants