volcano.sh/volcano@v1.9.0/pkg/scheduler/util_test.go (about) 1 /* 2 Copyright 2019 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package scheduler 18 19 import ( 20 "reflect" 21 "testing" 22 23 _ "volcano.sh/volcano/pkg/scheduler/actions" 24 "volcano.sh/volcano/pkg/scheduler/conf" 25 ) 26 27 func TestLoadSchedulerConf(t *testing.T) { 28 configuration := ` 29 actions: "enqueue, allocate, backfill" 30 tiers: 31 - plugins: 32 - name: priority 33 - name: gang 34 - name: conformance 35 - plugins: 36 - name: drf 37 - name: predicates 38 - name: proportion 39 - name: nodeorder 40 ` 41 42 trueValue := true 43 expectedTiers := []conf.Tier{ 44 { 45 Plugins: []conf.PluginOption{ 46 { 47 Name: "priority", 48 EnabledJobOrder: &trueValue, 49 EnabledJobReady: &trueValue, 50 EnabledJobPipelined: &trueValue, 51 EnabledTaskOrder: &trueValue, 52 EnabledPreemptable: &trueValue, 53 EnablePreemptive: &trueValue, 54 EnabledReclaimable: &trueValue, 55 EnabledQueueOrder: &trueValue, 56 EnabledPredicate: &trueValue, 57 EnabledBestNode: &trueValue, 58 EnabledNodeOrder: &trueValue, 59 EnabledTargetJob: &trueValue, 60 EnabledReservedNodes: &trueValue, 61 EnabledJobEnqueued: &trueValue, 62 EnabledVictim: &trueValue, 63 EnabledJobStarving: &trueValue, 64 EnabledOverused: &trueValue, 65 EnabledAllocatable: &trueValue, 66 }, 67 { 68 Name: "gang", 69 EnabledJobOrder: &trueValue, 70 EnabledJobReady: &trueValue, 71 EnabledJobPipelined: &trueValue, 72 EnabledTaskOrder: &trueValue, 73 EnabledPreemptable: &trueValue, 74 EnablePreemptive: &trueValue, 75 EnabledReclaimable: &trueValue, 76 EnabledQueueOrder: &trueValue, 77 EnabledPredicate: &trueValue, 78 EnabledBestNode: &trueValue, 79 EnabledNodeOrder: &trueValue, 80 EnabledTargetJob: &trueValue, 81 EnabledReservedNodes: &trueValue, 82 EnabledJobEnqueued: &trueValue, 83 EnabledVictim: &trueValue, 84 EnabledJobStarving: &trueValue, 85 EnabledOverused: &trueValue, 86 EnabledAllocatable: &trueValue, 87 }, 88 { 89 Name: "conformance", 90 EnabledJobOrder: &trueValue, 91 EnabledJobReady: &trueValue, 92 EnabledJobPipelined: &trueValue, 93 EnabledTaskOrder: &trueValue, 94 EnabledPreemptable: &trueValue, 95 EnablePreemptive: &trueValue, 96 EnabledReclaimable: &trueValue, 97 EnabledQueueOrder: &trueValue, 98 EnabledPredicate: &trueValue, 99 EnabledBestNode: &trueValue, 100 EnabledNodeOrder: &trueValue, 101 EnabledTargetJob: &trueValue, 102 EnabledReservedNodes: &trueValue, 103 EnabledJobEnqueued: &trueValue, 104 EnabledVictim: &trueValue, 105 EnabledJobStarving: &trueValue, 106 EnabledOverused: &trueValue, 107 EnabledAllocatable: &trueValue, 108 }, 109 }, 110 }, 111 { 112 Plugins: []conf.PluginOption{ 113 { 114 Name: "drf", 115 EnabledJobOrder: &trueValue, 116 EnabledJobReady: &trueValue, 117 EnabledJobPipelined: &trueValue, 118 EnabledTaskOrder: &trueValue, 119 EnabledPreemptable: &trueValue, 120 EnablePreemptive: &trueValue, 121 EnabledReclaimable: &trueValue, 122 EnabledQueueOrder: &trueValue, 123 EnabledPredicate: &trueValue, 124 EnabledBestNode: &trueValue, 125 EnabledNodeOrder: &trueValue, 126 EnabledTargetJob: &trueValue, 127 EnabledReservedNodes: &trueValue, 128 EnabledJobEnqueued: &trueValue, 129 EnabledVictim: &trueValue, 130 EnabledJobStarving: &trueValue, 131 EnabledOverused: &trueValue, 132 EnabledAllocatable: &trueValue, 133 }, 134 { 135 Name: "predicates", 136 EnabledJobOrder: &trueValue, 137 EnabledJobReady: &trueValue, 138 EnabledJobPipelined: &trueValue, 139 EnabledTaskOrder: &trueValue, 140 EnabledPreemptable: &trueValue, 141 EnablePreemptive: &trueValue, 142 EnabledReclaimable: &trueValue, 143 EnabledQueueOrder: &trueValue, 144 EnabledPredicate: &trueValue, 145 EnabledBestNode: &trueValue, 146 EnabledNodeOrder: &trueValue, 147 EnabledTargetJob: &trueValue, 148 EnabledReservedNodes: &trueValue, 149 EnabledJobEnqueued: &trueValue, 150 EnabledVictim: &trueValue, 151 EnabledJobStarving: &trueValue, 152 EnabledOverused: &trueValue, 153 EnabledAllocatable: &trueValue, 154 }, 155 { 156 Name: "proportion", 157 EnabledJobOrder: &trueValue, 158 EnabledJobReady: &trueValue, 159 EnabledJobPipelined: &trueValue, 160 EnabledTaskOrder: &trueValue, 161 EnabledPreemptable: &trueValue, 162 EnablePreemptive: &trueValue, 163 EnabledReclaimable: &trueValue, 164 EnabledQueueOrder: &trueValue, 165 EnabledPredicate: &trueValue, 166 EnabledBestNode: &trueValue, 167 EnabledNodeOrder: &trueValue, 168 EnabledTargetJob: &trueValue, 169 EnabledReservedNodes: &trueValue, 170 EnabledJobEnqueued: &trueValue, 171 EnabledVictim: &trueValue, 172 EnabledJobStarving: &trueValue, 173 EnabledOverused: &trueValue, 174 EnabledAllocatable: &trueValue, 175 }, 176 { 177 Name: "nodeorder", 178 EnabledJobOrder: &trueValue, 179 EnabledJobReady: &trueValue, 180 EnabledJobPipelined: &trueValue, 181 EnabledTaskOrder: &trueValue, 182 EnabledPreemptable: &trueValue, 183 EnablePreemptive: &trueValue, 184 EnabledReclaimable: &trueValue, 185 EnabledQueueOrder: &trueValue, 186 EnabledPredicate: &trueValue, 187 EnabledBestNode: &trueValue, 188 EnabledNodeOrder: &trueValue, 189 EnabledTargetJob: &trueValue, 190 EnabledReservedNodes: &trueValue, 191 EnabledJobEnqueued: &trueValue, 192 EnabledVictim: &trueValue, 193 EnabledJobStarving: &trueValue, 194 EnabledOverused: &trueValue, 195 EnabledAllocatable: &trueValue, 196 }, 197 }, 198 }, 199 } 200 201 var expectedConfigurations []conf.Configuration 202 203 _, tiers, configurations, _, err := UnmarshalSchedulerConf(configuration) 204 if err != nil { 205 t.Errorf("Failed to load Scheduler configuration: %v", err) 206 } 207 if !reflect.DeepEqual(tiers, expectedTiers) { 208 t.Errorf("Failed to set default settings for plugins, expected: %+v, got %+v", 209 expectedTiers, tiers) 210 } 211 if !reflect.DeepEqual(configurations, expectedConfigurations) { 212 t.Errorf("Wrong configuration, expected: %+v, got %+v", 213 expectedConfigurations, configurations) 214 } 215 }