mirror of
https://github.com/slackhq/nebula.git
synced 2026-11-15 11:16:52 +01:00
cpupick: Make tun.avoid_cpus a pin selection rule instead of a process-wide mask
This commit is contained in:
1 parent
36579bae03
commit
df1c4d9364
7 files changed
+127
-58
No files matched your search
@@ -0,0 +1,35 @@
|
||||
//go:build linux && !android && !e2e_testing
|
||||
|
||||
package cpupick
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/slackhq/nebula/util"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestDefaultSkipsAvoided(t *testing.T) {
|
||||
allowed, err := util.AllowedCPUs()
|
||||
require.NoError(t, err)
|
||||
if len(allowed) < 2 {
|
||||
t.Skip("requires at least two allowed CPUs")
|
||||
}
|
||||
avoid := allowed[:len(allowed)/2]
|
||||
for key := range uint64(16) {
|
||||
got := Default(len(allowed), key, avoid, nil)
|
||||
require.NotEmpty(t, got)
|
||||
for _, cpu := range got {
|
||||
assert.NotContains(t, avoid, cpu, "key %d", key)
|
||||
assert.Contains(t, allowed, cpu, "key %d", key)
|
||||
}
|
||||
}
|
||||
assert.Nil(t, Default(2, 0, allowed, nil), "avoiding everything leaves nothing to suggest")
|
||||
|
||||
// Without avoid every allowed CPU stays in play
|
||||
got := Default(len(allowed), 0, nil, nil)
|
||||
slices.Sort(got)
|
||||
assert.Equal(t, allowed, got)
|
||||
}
|
||||
Reference in new issue
Block a user