Skip to content

[Bug]: Race condition in TestSpanCollectorHTTPS #4497

Closed
@yurishkuro

Description

@yurishkuro

What happened?

Unit tests failed on a data race

Steps to reproduce

unknown, this seems spurious

Expected behavior

test should succeed

Relevant log output

=== RUN   TestSpanCollectorHTTPS/should_fail_with_TLS_client_to_untrusted_TLS_server
    logger.go:130: 2023-06-04T03:17:47.537Z	INFO	Starting jaeger-collector HTTP server	{"http host-port": ":14268"}
    logger.go:130: 2023-06-04T03:17:47.558Z	ERROR	http: TLS handshake error from [::1]:41006: remote error: tls: bad certificate
==================
WARNING: DATA RACE
Read at 0x00c000196863 by goroutine 88:
  testing.(*common).logDepth()
      /opt/hostedtoolcache/go/1.20.4/x64/src/testing/testing.go:992 +0xc4
  testing.(*common).log()
      /opt/hostedtoolcache/go/1.20.4/x64/src/testing/testing.go:985 +0xa4
  testing.(*common).Logf()
      /opt/hostedtoolcache/go/1.20.4/x64/src/testing/testing.go:1036 +0x6a
  testing.(*T).Logf()
      <autogenerated>:1 +0x75
  go.uber.org/zap/zaptest.testingWriter.Write()
      /home/runner/go/pkg/mod/go.uber.org/[email protected]/zaptest/logger.go:130 +0x12c
  go.uber.org/zap/zaptest.(*testingWriter).Write()
      <autogenerated>:1 +0x7e
  go.uber.org/zap/zapcore.(*ioCore).Write()
      /home/runner/go/pkg/mod/go.uber.org/[email protected]/zapcore/core.go:99 +0x199
  go.uber.org/zap/zapcore.(*CheckedEntry).Write()
      /home/runner/go/pkg/mod/go.uber.org/[email protected]/zapcore/entry.go:255 +0x2ce
  go.uber.org/zap.(*Logger).Error()
      /home/runner/go/pkg/mod/go.uber.org/[email protected]/logger.go:236 +0x6d
  go.uber.org/zap.(*Logger).Error-fm()
=== RUN   TestSpanCollectorHTTPS/should_pass_with_TLS_client_with_cert_to_trusted_TLS_server_requiring_cert
    logger.go:130: 2023-06-04T03:17:47.709Z	INFO	Starting jaeger-collector HTTP server	{"http host-port": ":14268"}
=== RUN   TestSpanCollectorHTTPS/should_fail_with_TLS_client_without_cert_to_trusted_TLS_server_requiring_cert_from_a_different_CA
    logger.go:130: 2023-06-04T03:17:47.788Z	INFO	Starting jaeger-collector HTTP server	{"http host-port": ":14268"}
    logger.go:130: 2023-06-04T03:17:47.832Z	ERROR	http: TLS handshake error from [::1]:41102: tls: failed to verify certificate: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "Jaeger")
    logger.go:130: 2023-06-04T03:17:47.859Z	ERROR	http: TLS handshake error from [::1]:41114: tls: failed to verify certificate: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "Jaeger")
=== NAME  TestSpanCollectorHTTPS
    testing.go:1446: race detected during execution of test
--- FAIL: TestSpanCollectorHTTPS (0.32s)

Screenshot

No response

Additional context

This looks similar to another issue that happened a few months ago. The race happens inside standard testing lib related to deferred behavior. My suspicion is that we are shutting down a server that is running in a different goroutine (or even leaking it) and it's writing a log via zap/zaptest into testing.T after the test is finished. We may either be missing defer server.close() in the test or the close() actually returns before the server gorouting is stopped

Jaeger backend version

No response

SDK

No response

Pipeline

No response

Stogage backend

No response

Operating system

No response

Deployment model

No response

Deployment configs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issueGood for beginnershelp wantedFeatures that maintainers are willing to accept but do not have cycles to implement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions