github.com/kubewharf/katalyst-core@v0.5.3/pkg/util/external/rdt/manager_linux_test.go (about) 1 //go:build linux 2 // +build linux 3 4 /* 5 Copyright 2022 The Katalyst Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 */ 19 20 package rdt 21 22 import ( 23 "strconv" 24 "testing" 25 26 "github.com/stretchr/testify/assert" 27 ) 28 29 var ( 30 clos = "fake-clos" 31 tasks = []string{"0", "1"} 32 defaultCATValue = "7ff" 33 defaultMBAValue = 100 34 ) 35 36 func TestNewDefaultManager(t *testing.T) { 37 t.Parallel() 38 39 defaultManager := NewDefaultManager() 40 assert.NotNil(t, defaultManager) 41 } 42 43 func TestCheckSupportRDT(t *testing.T) { 44 t.Parallel() 45 46 defaultManager := NewDefaultManager() 47 assert.NotNil(t, defaultManager) 48 49 isSupport, err := defaultManager.CheckSupportRDT() 50 assert.Error(t, err) 51 assert.False(t, isSupport) 52 } 53 54 func TestInitRDT(t *testing.T) { 55 t.Parallel() 56 57 defaultManager := NewDefaultManager() 58 assert.NotNil(t, defaultManager) 59 60 err := defaultManager.InitRDT() 61 assert.Error(t, err) 62 } 63 64 func TestApplyTasks(t *testing.T) { 65 t.Parallel() 66 67 defaultManager := NewDefaultManager() 68 assert.NotNil(t, defaultManager) 69 70 err := defaultManager.ApplyTasks(clos, tasks) 71 assert.Error(t, err) 72 } 73 74 func TestApplyCAT(t *testing.T) { 75 t.Parallel() 76 77 defaultManager := NewDefaultManager() 78 assert.NotNil(t, defaultManager) 79 80 catInt64, err := strconv.ParseInt(defaultCATValue, 16, 32) 81 assert.NoError(t, err) 82 83 cat := map[int]int{ 84 0: int(catInt64), 85 1: int(catInt64), 86 } 87 err = defaultManager.ApplyCAT(clos, cat) 88 assert.Error(t, err) 89 90 return 91 } 92 93 func TestApplyMBA(t *testing.T) { 94 t.Parallel() 95 96 defaultManager := NewDefaultManager() 97 assert.NotNil(t, defaultManager) 98 99 mba := map[int]int{ 100 0: defaultMBAValue, 101 1: defaultMBAValue, 102 } 103 err := defaultManager.ApplyMBA(clos, mba) 104 assert.Error(t, err) 105 106 return 107 }