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

fix: test failure cases on windows #1047

Merged
merged 10 commits into from
Dec 6, 2021

Conversation

laojianzi
Copy link
Contributor

@laojianzi laojianzi commented Sep 3, 2021

Fixed #1010


But it's not clear what the problem is here

https://github.com/laojianzi/opentelemetry-go-contrib/runs/3504741867?check_suite_focus=true#step:6:297

=== RUN ExampleExporter
--- FAIL: ExampleExporter (0.00s)
got:
myrecorder.max:100|g|#env:dev,l:1,service.name:unknown_service:datadog.test.exe,telemetry.sdk.language:go,telemetry.sdk.name:opentelemetry,telemetry.sdk.version:1.0.0-RC1
want:
myrecorder.max:100|g|#env:dev,l:1,service.name:unknown_service:datadog.test,telemetry.sdk.language:go,telemetry.sdk.name:opentelemetry,telemetry.sdk.version:1.0.0-RC1
FAIL
FAIL go.opentelemetry.io/contrib/exporters/metric/datadog 0.026s
FAIL
mingw32-make: *** [Makefile:130: test-short] Error 1
Error: Process completed with exit code 1.

Resolved in #1047 (comment)

@Aneurysm9
Copy link
Member

The DataDog test failure seems to be caused by the default service name being unknown_service:datadog.test.exe on windows and the .exe is unexpected. It should be possible to solve that by giving the TracerProvider a resource with an explicitly set service name so that it doesn't vary by platform.

@laojianzi
Copy link
Contributor Author

The DataDog test failure seems to be caused by the default service name being unknown_service:datadog.test.exe on windows and the .exe is unexpected. It should be possible to solve that by giving the TracerProvider a resource with an explicitly set service name so that it doesn't vary by platform.

thx, I think I found the answer here 😃

https://github.com/open-telemetry/opentelemetry-go/blob/v1.0.0-RC2/semconv/v1.4.0/resource.go#L785

@laojianzi laojianzi force-pushed the fix/issues-1010 branch 2 times, most recently from 2b7bd82 to b296754 Compare September 5, 2021 06:56
Copy link
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

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

nice 👍

@laojianzi
Copy link
Contributor Author

@Aneurysm9 pls review again 🙃

@laojianzi
Copy link
Contributor Author

laojianzi commented Sep 15, 2021

=== RUN   TestHostNetwork
    assertion_compare.go:342:
        	Error Trace:	host_test.go:235
        	Error:      	"10000" is not less than or equal to "7837"
        	Test:       	TestHostNetwork
        	Messages:   	[]
--- FAIL: TestHostNetwork

This mistake was accidental and increasing sleep can only improve the chances of success, any ideas to help?

on windows

@laojianzi laojianzi changed the title fix: utils.NewConfig returns a file not found error in windows os fix: test failure cases on windows Sep 15, 2021
@laojianzi
Copy link
Contributor Author

=== RUN   TestHostNetwork
    assertion_compare.go:342:
        	Error Trace:	host_test.go:235
        	Error:      	"10000" is not less than or equal to "7837"
        	Test:       	TestHostNetwork
        	Messages:   	[]
--- FAIL: TestHostNetwork

This mistake was accidental and increasing sleep can only improve the chances of success, any ideas to help?

on windows


@Aneurysm9 I used the following method to debug and the test passed in 3s/8s/10s ... etc, so I can't use sleep to guarantee the success of the test, do you think it's reasonable to wait for sent/recv

Is it reasonable to wait until sent/recv is satisfied until the go test times out?

// As we are going to read the /proc file system for this info, sleep a while:
time.Sleep(time.Second)

// As we are going to read the /proc file system for this info, sleep a while:
for {
hostAfter, err := net.IOCountersWithContext(ctx, false)
require.NoError(t, err)
time.Sleep(time.Second / 2)
if uint64(howMuch) <= hostAfter[0].BytesSent-hostBefore[0].BytesSent &&
uint64(howMuch) <= hostAfter[0].BytesRecv-hostBefore[0].BytesRecv {
break
}
}

@pellared
Copy link
Member

I used the following method to debug and the test passed in 3s/8s/10s ... etc, so I can't use sleep to guarantee the success of the test, do you think it's reasonable to wait for sent/recv

At first glance it looks like a good candidate to use require.Eventually. WDYT?

@laojianzi
Copy link
Contributor Author

At first glance it looks like a good candidate to use require.Eventually. WDYT?

Of course, but how long should we wait ? as this process seems very unstable on Windows 🤔

@pellared
Copy link
Member

pellared commented Sep 28, 2021

Of course, but how long should we wait ? as this process seems very unstable on Windows

I would try max 30s - should be long enough I guess 😉 intervals one or half of a second?

@laojianzi
Copy link
Contributor Author

@pellared Thank you for your help 👍

Comment on lines +228 to +229
return uint64(howMuch) <= hostAfter[0].BytesSent-hostBefore[0].BytesSent &&
uint64(howMuch) <= hostAfter[0].BytesRecv-hostBefore[0].BytesRecv
Copy link
Member

Choose a reason for hiding this comment

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

Can you keep these as assertions? Doing so should help in understanding where a failure occurred if this test starts failing in the future.

Copy link
Contributor Author

@laojianzi laojianzi Nov 1, 2021

Choose a reason for hiding this comment

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

Thanks @Aneurysm9

Because it is necessary to wait for BytesSent and BytesRecv all the time, they are not assert here.

There should only be one timeout error here and it will be tracked to the require.Eventually line, but 30 seconds will cause the go test to time out without printing the error tracking message, so consider updating it to <30 seconds?

#1047 (comment) The idea. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the error trace info for the 20s timeout

=== RUN TestHostNetwork
host_test.go:222:
Error Trace: host_test.go:222
Error: Condition never satisfied
Test: TestHostNetwork
--- FAIL: TestHostNetwork (20.00s)

pusher := controller.New(processor, controller.WithExporter(exp), controller.WithCollectPeriod(time.Second*10))
pusher := controller.New(processor, controller.WithExporter(exp), controller.WithCollectPeriod(time.Second*10),
controller.WithResource(resource.Default()),
controller.WithResource(resource.NewSchemaless(semconv.ServiceNameKey.String("ExampleExporter"))))
Copy link
Member

Choose a reason for hiding this comment

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

Should this use New() instead of NewSchemaless()? We have a schema from semconv.SchemaURL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @Aneurysm9

Okey! like this?

ctx := context.Background()
serviceName, err := resource.New(ctx, resource.WithAttributes(semconv.ServiceNameKey.String("ExampleExporter")))
if err != nil {
	panic(err)
}

cont := controller.New(processor, controller.WithExporter(exp), controller.WithCollectPeriod(time.Second*10),
	controller.WithResource(resource.Default()), controller.WithResource(serviceName))

Copy link
Contributor

@MadVikingGod MadVikingGod left a comment

Choose a reason for hiding this comment

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

Can you please merge in main to resolve some conflicts?

Other than the outstanding comments it LGTM

@laojianzi laojianzi force-pushed the fix/issues-1010 branch 12 times, most recently from 5edf45d to cacb124 Compare December 3, 2021 03:22
@laojianzi
Copy link
Contributor Author

Can you please merge in main to resolve some conflicts?

Other than the outstanding comments it LGTM

@MadVikingGod Done

@Aneurysm9 Aneurysm9 merged commit dac6cdb into open-telemetry:main Dec 6, 2021
@pellared pellared added this to the untracked milestone Nov 8, 2024
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.

Support Windows with the CI system
5 participants