@@ -2525,14 +2525,21 @@ func TestAgent_ManageProcessPriority(t *testing.T) {
2525
2525
t .Skip ("Skipping non-linux environment" )
2526
2526
}
2527
2527
2528
- var buf bytes.Buffer
2529
- log := slog .Make (sloghuman .Sink (& buf )).Leveled (slog .LevelDebug )
2528
+ var (
2529
+ buf bytes.Buffer
2530
+ wr = & syncWriter {
2531
+ w : & buf ,
2532
+ }
2533
+ )
2534
+ log := slog .Make (sloghuman .Sink (wr )).Leveled (slog .LevelDebug )
2530
2535
2531
2536
_ , _ , _ , _ , _ = setupAgent (t , agentsdk.Manifest {}, 0 , func (c * agenttest.Client , o * agent.Options ) {
2532
2537
o .Logger = log
2533
2538
})
2534
2539
2535
2540
require .Eventually (t , func () bool {
2541
+ wr .mu .Lock ()
2542
+ defer wr .mu .Unlock ()
2536
2543
return strings .Contains (buf .String (), "process priority not enabled" )
2537
2544
}, testutil .WaitLong , testutil .IntervalFast )
2538
2545
})
@@ -2544,8 +2551,13 @@ func TestAgent_ManageProcessPriority(t *testing.T) {
2544
2551
t .Skip ("Skipping linux environment" )
2545
2552
}
2546
2553
2547
- var buf bytes.Buffer
2548
- log := slog .Make (sloghuman .Sink (& buf )).Leveled (slog .LevelDebug )
2554
+ var (
2555
+ buf bytes.Buffer
2556
+ wr = & syncWriter {
2557
+ w : & buf ,
2558
+ }
2559
+ )
2560
+ log := slog .Make (sloghuman .Sink (wr )).Leveled (slog .LevelDebug )
2549
2561
2550
2562
_ , _ , _ , _ , _ = setupAgent (t , agentsdk.Manifest {}, 0 , func (c * agenttest.Client , o * agent.Options ) {
2551
2563
o .Logger = log
@@ -2554,6 +2566,9 @@ func TestAgent_ManageProcessPriority(t *testing.T) {
2554
2566
o .EnvironmentVariables = map [string ]string {agent .EnvProcPrioMgmt : "1" }
2555
2567
})
2556
2568
require .Eventually (t , func () bool {
2569
+ wr .mu .Lock ()
2570
+ defer wr .mu .Unlock ()
2571
+
2557
2572
return strings .Contains (buf .String (), "process priority not enabled" )
2558
2573
}, testutil .WaitLong , testutil .IntervalFast )
2559
2574
})
@@ -2580,3 +2595,14 @@ func verifyCollectedMetrics(t *testing.T, expected []agentsdk.AgentMetric, actua
2580
2595
}
2581
2596
return true
2582
2597
}
2598
+
2599
+ type syncWriter struct {
2600
+ mu sync.Mutex
2601
+ w io.Writer
2602
+ }
2603
+
2604
+ func (s * syncWriter ) Write (p []byte ) (int , error ) {
2605
+ s .mu .Lock ()
2606
+ defer s .mu .Unlock ()
2607
+ return s .w .Write (p )
2608
+ }
0 commit comments