Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: Add integration testing harness and some tests #37

Merged
merged 13 commits into from
Sep 19, 2023

Conversation

knusbaum
Copy link
Contributor

@knusbaum knusbaum commented Aug 28, 2023

What does this PR do?

This commit adds an integration test harness to the repository.

Individual tests consist of a directory under _integration-tests/tests
which contains a go program and a file, validation.json.

The go program will be instrumented by orchestrion, then run. The traces
output by that program go to a fake agent, which records the traces.

The validation.json file describes the expected structure of the traces
which should be produced by each test. This includes things like name,
resource, service, metadata and metrics.

Once the traces are recorded and the test program shuts down, the traces
recorded by the fake agent are checked against the expected ones
described in validation.json to ensure the test produced exactly what we
expected, in terms of the number of traces, the structure of those
traces, and the fields in the spans of the traces.

Motivation

Reviewer's Checklist

  • Changed code has unit tests for its functionality.

@knusbaum knusbaum force-pushed the knusbaum/integration-tests branch 2 times, most recently from edc3c8d to c9eb5b8 Compare August 29, 2023 17:12
@knusbaum knusbaum changed the title [WIP] testing first integration tests [WIP] all: Add integration testing harness and some tests Aug 29, 2023
@knusbaum knusbaum force-pushed the knusbaum/integration-tests branch from c9eb5b8 to 30f6437 Compare August 29, 2023 17:14
@knusbaum knusbaum changed the title [WIP] all: Add integration testing harness and some tests all: Add integration testing harness and some tests Sep 6, 2023
@knusbaum knusbaum marked this pull request as ready for review September 6, 2023 13:17
This commit adds an integration test harness to the repository.

Individual tests consist of a directory under _integration-tests/tests
which contains a go program and a file, validation.json.

The go program will be instrumented by orchestrion, then run. The traces
output by that program go to a fake agent, which records the traces.

The validation.json file describes the expected structure of the traces
which should be produced by each test. This includes things like name,
resource, service, metadata and metrics.

Once the traces are recorded and the test program shuts down, the traces
recorded by the fake agent are checked against the expected ones
described in validation.json to ensure the test produced exactly what we
expected, in terms of the number of traces, the structure of those
traces, and the fields in the spans of the traces.
@knusbaum knusbaum force-pushed the knusbaum/integration-tests branch from c2b2f06 to 0772417 Compare September 6, 2023 13:19
.github/workflows/tests.yaml Outdated Show resolved Hide resolved
.github/workflows/tests.yaml Outdated Show resolved Hide resolved
.github/workflows/tests.yaml Outdated Show resolved Hide resolved
_integration-tests/tests/chi/main.go Outdated Show resolved Hide resolved
_integration-tests/tests/echo/main.go Outdated Show resolved Hide resolved
_integration-tests/validator/validator.go Outdated Show resolved Hide resolved
_integration-tests/validator/validator.go Outdated Show resolved Hide resolved
_integration-tests/go.mod Outdated Show resolved Hide resolved
integration-tests.sh Outdated Show resolved Hide resolved
internal/instrument/instrument.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ahmed-mez ahmed-mez left a comment

Choose a reason for hiding this comment

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

Looks really good! Let's add a some docs in a readme file under _integration-tests with instruction on how to run them locally.

@darccio
Copy link
Member

darccio commented Sep 7, 2023

@knusbaum I've a similar set of comments that @ahmed-mez already wrote, so I won't duplicate them. My only addition would be: could it be interesting to document any specifics about these integration tests when adding new contribs?

Copy link
Contributor

@ahmed-mez ahmed-mez left a comment

Choose a reason for hiding this comment

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

LGTM. Let's add a some docs in a readme file under _integration-tests with instruction on how to run them locally.

@knusbaum
Copy link
Contributor Author

knusbaum commented Sep 18, 2023

@ahmed-mez @darccio
I added documentation about running and writing tests, as well as adding better support for running the tests locally with the script.

I also cleaned up the github action. I ended up removing the explicit cache since it looks like the setup-go cache is mostly working, and it simplifies the setup.

Ready to merge.

Copy link
Member

@darccio darccio left a comment

Choose a reason for hiding this comment

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

@ahmed-mez ahmed-mez merged commit 3fce9ce into main Sep 19, 2023
3 checks passed
@ahmed-mez ahmed-mez deleted the knusbaum/integration-tests branch September 19, 2023 09:38
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