mirror of
https://github.com/siderolabs/talos.git
synced 2025-12-17 07:21:22 +01:00
test: fix dns test in race mode
This is a workaround, as using `t.Context()` causes panics as `t.Log` is used after the test finishes, this is related to unsynchronized context.AfterFunc, but I will leave the fix to @DmitryMV. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
This commit is contained in:
parent
17965c32fa
commit
c3c0d2e42f
@ -128,9 +128,9 @@ func TestGC_NOGC(t *testing.T) {
|
|||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
m := dns.NewManager(&testReader{}, func(e suture.Event) { t.Log("dns-runners event:", e) }, zaptest.NewLogger(t))
|
m := dns.NewManager(&testReader{}, func(e suture.Event) { t.Log("dns-runners event:", e) }, zaptest.NewLogger(t))
|
||||||
|
|
||||||
m.ServeBackground(t.Context())
|
m.ServeBackground(context.Background()) //nolint:usetesting
|
||||||
m.ServeBackground(t.Context())
|
m.ServeBackground(context.Background()) //nolint:usetesting
|
||||||
require.Panics(t, func() { m.ServeBackground(context.Background()) }) //nolint:usetesting // need background context to trigger panic
|
require.Panics(t, func() { m.ServeBackground(context.TODO()) }) //nolint:usetesting
|
||||||
|
|
||||||
for _, err := range m.RunAll(slices.Values([]dns.AddressPair{
|
for _, err := range m.RunAll(slices.Values([]dns.AddressPair{
|
||||||
{Network: "udp", Addr: netip.MustParseAddrPort("127.0.0.1:10700")},
|
{Network: "udp", Addr: netip.MustParseAddrPort("127.0.0.1:10700")},
|
||||||
@ -172,7 +172,7 @@ func newManager(t *testing.T, nameservers ...string) func() {
|
|||||||
return p
|
return p
|
||||||
})
|
})
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(t.Context())
|
ctx, cancel := context.WithCancel(context.Background()) //nolint:usetesting
|
||||||
t.Cleanup(cancel)
|
t.Cleanup(cancel)
|
||||||
|
|
||||||
m.SetUpstreams(slices.Values(pxs))
|
m.SetUpstreams(slices.Values(pxs))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user