Skip to content

Commit fb73f8c

Browse files
committed
custom nice
1 parent e1c1fe9 commit fb73f8c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

agent/agent_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,6 +2463,49 @@ func TestAgent_ManageProcessPriority(t *testing.T) {
24632463
}
24642464
})
24652465

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+
24662509
t.Run("DisabledByDefault", func(t *testing.T) {
24672510
t.Parallel()
24682511

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy