Skip to content

Conversation

@fangn2
Copy link
Contributor

@fangn2 fangn2 commented Nov 15, 2022

Add unit tests to NewExporter and NewTracer for opentelemetry tracing support
The unit tests feed input of different combination of the cfg, then check the expected output
This PR is part of issue 7493
Signed-off-by: Tony Fang nenghui.fang@gmail.com

Unit test ran locally:

$ go test -v -run TestNewExporter
=== RUN   TestNewExporter
=== RUN   TestNewExporter/Test_http/protobuf_protocol,_expect_no_error
    otlp_test.go:72: input: {http://localhost:4318 http/protobuf false}
    otlp_test.go:76: output: <nil>
=== RUN   TestNewExporter/Test_invalid_endpoint,_expect_ErrInvalidArgument_error
    otlp_test.go:72: input: {http://localhost
        :4318 http/protobuf false}
    otlp_test.go:76: output: OpenTelemetry endpoint "http://localhost\n:4318" is invalid: invalid argument
=== RUN   TestNewExporter/Test_default_protocol,_expect_no_error
    otlp_test.go:72: input: {http://localhost:4318  false}
    otlp_test.go:76: output: <nil>
=== RUN   TestNewExporter/Test_grpc_protocol,_expect_no_error
    otlp_test.go:72: input: {http://localhost:4317 grpc false}
    otlp_test.go:76: output: <nil>
=== RUN   TestNewExporter/Test_http/json_protocol_which_is_not_supported,_expect_not_implemented_error
    otlp_test.go:72: input: {http://localhost:4318 http/json false}
    otlp_test.go:76: output: OpenTelemetry protocol "http/json" : not implemented
--- PASS: TestNewExporter (0.00s)
    --- PASS: TestNewExporter/Test_http/protobuf_protocol,_expect_no_error (0.00s)
    --- PASS: TestNewExporter/Test_invalid_endpoint,_expect_ErrInvalidArgument_error (0.00s)
    --- PASS: TestNewExporter/Test_default_protocol,_expect_no_error (0.00s)
    --- PASS: TestNewExporter/Test_grpc_protocol,_expect_no_error (0.00s)
    --- PASS: TestNewExporter/Test_http/json_protocol_which_is_not_supported,_expect_not_implemented_error (0.00s)
PASS
ok      github.com/containerd/containerd/tracing/plugin 0.006s


$ go test -v -run TestNewTracer
=== RUN   TestNewTracer
    otlp_test.go:101: config: &{containerd 1}
--- PASS: TestNewTracer (0.00s)
PASS
ok      github.com/containerd/containerd/tracing/plugin 0.006s

@k8s-ci-robot
Copy link

Hi @fangn2. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@fangn2 fangn2 force-pushed the adding-unit-test-for-opentelemetry-tracing branch 4 times, most recently from dba38e1 to bb67ebb Compare November 15, 2022 20:44
@fangn2 fangn2 force-pushed the adding-unit-test-for-opentelemetry-tracing branch 4 times, most recently from 2b4928a to 09c1a6b Compare December 5, 2022 21:00
@fangn2 fangn2 changed the title Add unit test to NewExporter Add unit test to Opentelemetry tracing Dec 5, 2022
@fangn2 fangn2 marked this pull request as draft December 5, 2022 21:26
@fangn2 fangn2 closed this Dec 5, 2022
@fangn2 fangn2 force-pushed the adding-unit-test-for-opentelemetry-tracing branch from 73af0b1 to 6918432 Compare December 5, 2022 21:37
@fangn2 fangn2 reopened this Dec 5, 2022
@fangn2 fangn2 force-pushed the adding-unit-test-for-opentelemetry-tracing branch 2 times, most recently from e79aaa0 to 78463cc Compare December 5, 2022 22:50
Refractor newExporter and newTracer, add unit tests to them
This PR is part of issue 7493

Signed-off-by: Tony Fang <nenghui.fang@gmail.com>
@fangn2 fangn2 force-pushed the adding-unit-test-for-opentelemetry-tracing branch from 78463cc to 8472946 Compare December 6, 2022 03:14
@fangn2 fangn2 marked this pull request as ready for review December 6, 2022 03:23
Copy link
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

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

LGTM

@kzys kzys merged commit 62968d9 into containerd:main Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants