@@ -2463,6 +2463,49 @@ func TestAgent_ManageProcessPriority(t *testing.T) {
2463
2463
}
2464
2464
})
2465
2465
2466
+ t .Run ("IgnoreCustomNice" , func (t * testing.T ) {
2467
+ t .Parallel ()
2468
+
2469
+ var (
2470
+ expectedProcs = map [int32 ]agentproc.Process {}
2471
+ fs = afero .NewMemMapFs ()
2472
+ ticker = make (chan time.Time )
2473
+ syscaller = agentproctest .NewMockSyscaller (gomock .NewController (t ))
2474
+ modProcs = make (chan []* agentproc.Process )
2475
+ logger = slog .Make (sloghuman .Sink (io .Discard ))
2476
+ )
2477
+
2478
+ // Create some processes.
2479
+ for i := 0 ; i < 2 ; i ++ {
2480
+ // Create a prioritized process.
2481
+ proc := agentproctest .GenerateProcess (t , fs , agentproc .DefaultProcDir )
2482
+ syscaller .EXPECT ().
2483
+ Kill (proc .PID , syscall .Signal (0 )).
2484
+ Return (nil )
2485
+
2486
+ if i == 0 {
2487
+ syscaller .EXPECT ().GetPriority (proc .PID ).Return (25 , nil )
2488
+ } else {
2489
+ syscaller .EXPECT ().GetPriority (proc .PID ).Return (20 , nil )
2490
+ syscaller .EXPECT ().SetPriority (proc .PID , 10 ).Return (nil )
2491
+ }
2492
+
2493
+ expectedProcs [proc .PID ] = proc
2494
+ }
2495
+
2496
+ _ , _ , _ , _ , _ = setupAgent (t , agentsdk.Manifest {}, 0 , func (c * agenttest.Client , o * agent.Options ) {
2497
+ o .ProcessManagementTick = ticker
2498
+ o .Syscaller = syscaller
2499
+ o .ModifiedProcesses = modProcs
2500
+ o .EnvironmentVariables = map [string ]string {agent .EnvProcMemNice : "1" }
2501
+ o .Filesystem = fs
2502
+ o .Logger = logger
2503
+ })
2504
+ actualProcs := <- modProcs
2505
+ // We should ignore the process with a custom nice score.
2506
+ require .Len (t , actualProcs , 1 )
2507
+ })
2508
+
2466
2509
t .Run ("DisabledByDefault" , func (t * testing.T ) {
2467
2510
t .Parallel ()
2468
2511
0 commit comments