-
Notifications
You must be signed in to change notification settings - Fork 592
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
Changes from all commits
4b9fb4f
bac4231
5fbe2c8
072939c
3c59acf
08b8025
f7764b4
73e1e61
ca6b0a3
948f3dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,9 +28,10 @@ import ( | |
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"go.opentelemetry.io/contrib/instrumentation/host" | ||
"go.opentelemetry.io/otel/attribute" | ||
"go.opentelemetry.io/otel/metric/metrictest" | ||
|
||
"go.opentelemetry.io/contrib/instrumentation/host" | ||
) | ||
|
||
func getMetric(provider *metrictest.MeterProvider, name string, lbl attribute.KeyValue) float64 { | ||
|
@@ -218,20 +219,18 @@ func TestHostNetwork(t *testing.T) { | |
require.NoError(t, err) | ||
|
||
// As we are going to read the /proc file system for this info, sleep a while: | ||
time.Sleep(time.Second) | ||
|
||
provider.RunAsyncInstruments() | ||
require.Eventually(t, func() bool { | ||
hostAfter, err := net.IOCountersWithContext(ctx, false) | ||
require.NoError(t, err) | ||
|
||
hostAfter, err := net.IOCountersWithContext(ctx, false) | ||
require.NoError(t, err) | ||
return uint64(howMuch) <= hostAfter[0].BytesSent-hostBefore[0].BytesSent && | ||
uint64(howMuch) <= hostAfter[0].BytesRecv-hostBefore[0].BytesRecv | ||
Comment on lines
+226
to
+227
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @Aneurysm9 Because it is necessary to wait for There should only be one timeout error here and it will be tracked to the #1047 (comment) The idea. WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the error trace info for the 20s timeout
|
||
}, 30*time.Second, time.Second/2) | ||
|
||
provider.RunAsyncInstruments() | ||
hostTransmit := getMetric(provider, "system.network.io", host.AttributeNetworkTransmit[0]) | ||
hostReceive := getMetric(provider, "system.network.io", host.AttributeNetworkReceive[0]) | ||
|
||
// Check that the network transmit/receive used is greater than before: | ||
require.LessOrEqual(t, uint64(howMuch), hostAfter[0].BytesSent-hostBefore[0].BytesSent) | ||
require.LessOrEqual(t, uint64(howMuch), hostAfter[0].BytesRecv-hostBefore[0].BytesRecv) | ||
|
||
// Check that the recorded measurements reflect the same change: | ||
require.LessOrEqual(t, uint64(howMuch), uint64(hostTransmit)-hostBefore[0].BytesSent) | ||
require.LessOrEqual(t, uint64(howMuch), uint64(hostReceive)-hostBefore[0].BytesRecv) | ||
|
There was a problem hiding this comment.
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 ofNewSchemaless()
? We have a schema fromsemconv.SchemaURL
.There was a problem hiding this comment.
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?