|
| 1 | +# shellcheck disable=SC2148 |
| 2 | +# shellcheck disable=SC2329 |
| 3 | + |
| 4 | +#setup_file() { |
| 5 | +# load 'helpers.sh' |
| 6 | +# local _iargs=("--set" "logVerbosity=6") |
| 7 | +# iupgrade_wait "${TEST_CHART_REPO}" "${TEST_CHART_VERSION}" _iargs |
| 8 | +#} |
| 9 | + |
| 10 | + |
| 11 | +setup () { |
| 12 | + load 'helpers.sh' |
| 13 | + _common_setup |
| 14 | +} |
| 15 | + |
| 16 | + |
| 17 | +@test "CD controller/plugin: startup config / detail in logs on level 0" { |
| 18 | + local _iargs=("--set" "logVerbosity=0") |
| 19 | + iupgrade_wait "${TEST_CHART_REPO}" "${TEST_CHART_VERSION}" _iargs |
| 20 | + |
| 21 | + run kubectl logs -l nvidia-dra-driver-gpu-component=controller -n nvidia-dra-driver-gpu --tail=-1 |
| 22 | + assert_output --partial "Verbosity:" |
| 23 | + assert_output --partial '"MPSSupport":false' |
| 24 | + assert_output --partial 'additionalNamespaces:' |
| 25 | + |
| 26 | + run kubectl logs -l nvidia-dra-driver-gpu-component=kubelet-plugin -n nvidia-dra-driver-gpu --tail=-1 |
| 27 | + assert_output --partial "Verbosity" |
| 28 | + assert_output --partial "nodeName" |
| 29 | + assert_output --partial "identified fabric clique" |
| 30 | + assert_output --partial "driver version validation" |
| 31 | +} |
| 32 | + |
| 33 | +@test "CD controller: test log verbosity levels" { |
| 34 | + iupgrade_wait "${TEST_CHART_REPO}" "${TEST_CHART_VERSION}" NOARGS |
| 35 | + |
| 36 | + # Deploy workload: give the controller something to log about. |
| 37 | + log_objects |
| 38 | + kubectl apply -f demo/specs/imex/channel-injection.yaml |
| 39 | + kubectl wait --for=condition=READY pods imex-channel-injection --timeout=100s |
| 40 | + run kubectl logs imex-channel-injection |
| 41 | + assert_output --partial "channel0" |
| 42 | + |
| 43 | + echo "test level 0" |
| 44 | + local _iargs=("--set" "logVerbosity=0") |
| 45 | + iupgrade_wait "${TEST_CHART_REPO}" "${TEST_CHART_VERSION}" _iargs |
| 46 | + kubectl logs -l nvidia-dra-driver-gpu-component=controller -n nvidia-dra-driver-gpu --tail=-1 |
| 47 | + run kubectl logs -l nvidia-dra-driver-gpu-component=controller -n nvidia-dra-driver-gpu --tail=-1 |
| 48 | + assert_output --partial 'controller manager config' |
| 49 | + assert_output --partial 'maxNodesPerIMEXDomain' |
| 50 | + |
| 51 | + echo "test level 1" |
| 52 | + local _iargs=("--set" "logVerbosity=1") |
| 53 | + iupgrade_wait "${TEST_CHART_REPO}" "${TEST_CHART_VERSION}" _iargs |
| 54 | + run kubectl logs -l nvidia-dra-driver-gpu-component=controller -n nvidia-dra-driver-gpu --tail=-1 |
| 55 | + refute_output --partial 'Processing added or updated ComputeDomain' |
| 56 | + refute_output --partial 'reflector.go' |
| 57 | + refute_output --partial 'Caches populated' |
| 58 | + refute_output --partial 'round_trippers.go' |
| 59 | + refute_output --partial 'Listing and watching' |
| 60 | + |
| 61 | + echo "test level 2" |
| 62 | + local _iargs=("--set" "logVerbosity=2") |
| 63 | + iupgrade_wait "${TEST_CHART_REPO}" "${TEST_CHART_VERSION}" _iargs |
| 64 | + run kubectl logs -l nvidia-dra-driver-gpu-component=controller -n nvidia-dra-driver-gpu --tail=-1 |
| 65 | + assert_output --partial 'Processing added or updated ComputeDomain' |
| 66 | + assert_output --partial 'reflector.go' |
| 67 | + assert_output --partial 'Caches populated' |
| 68 | + refute_output --partial 'Listing and watching' |
| 69 | + refute_output --partial 'round_trippers.go' |
| 70 | + |
| 71 | + echo "test level 3" |
| 72 | + local _iargs=("--set" "logVerbosity=3") |
| 73 | + iupgrade_wait "${TEST_CHART_REPO}" "${TEST_CHART_VERSION}" _iargs |
| 74 | + run kubectl logs -l nvidia-dra-driver-gpu-component=controller -n nvidia-dra-driver-gpu --tail=-1 |
| 75 | + assert_output --partial 'reflector.go' |
| 76 | + assert_output --partial 'Caches populated' |
| 77 | + assert_output --partial 'Listing and watching' |
| 78 | + refute_output --partial 'round_trippers.go' |
| 79 | + |
| 80 | + echo "test level 4" |
| 81 | + local _iargs=("--set" "logVerbosity=4") |
| 82 | + iupgrade_wait "${TEST_CHART_REPO}" "${TEST_CHART_VERSION}" _iargs |
| 83 | + run kubectl logs -l nvidia-dra-driver-gpu-component=controller -n nvidia-dra-driver-gpu --tail=-1 |
| 84 | + refute_output --partial 'round_trippers.go' |
| 85 | + |
| 86 | + echo "test level 5" |
| 87 | + local _iargs=("--set" "logVerbosity=5") |
| 88 | + iupgrade_wait "${TEST_CHART_REPO}" "${TEST_CHART_VERSION}" _iargs |
| 89 | + run kubectl logs -l nvidia-dra-driver-gpu-component=controller -n nvidia-dra-driver-gpu --tail=-1 |
| 90 | + refute_output --partial 'round_trippers.go' |
| 91 | + |
| 92 | + echo "test level 6" |
| 93 | + local _iargs=("--set" "logVerbosity=6") |
| 94 | + iupgrade_wait "${TEST_CHART_REPO}" "${TEST_CHART_VERSION}" _iargs |
| 95 | + run kubectl logs -l nvidia-dra-driver-gpu-component=controller -n nvidia-dra-driver-gpu --tail=-1 |
| 96 | + assert_output --partial 'Cleanup: perform for' |
| 97 | + assert_output --partial 'round_trippers.go' |
| 98 | + assert_output --partial '"Response" verb="GET"' |
| 99 | + |
| 100 | + # Delete workload and hence CD daemon |
| 101 | + kubectl delete -f demo/specs/imex/channel-injection.yaml |
| 102 | + kubectl wait --for=delete pods imex-channel-injection --timeout=10s |
| 103 | +} |
| 104 | + |
| 105 | +@test "CD daemon: test log verbosity levels" { |
| 106 | + log_objects |
| 107 | + iupgrade_wait "${TEST_CHART_REPO}" "${TEST_CHART_VERSION}" NOARGS |
| 108 | + |
| 109 | + echo "test level 6" |
| 110 | + local _iargs=("--set" "logVerbosity=6") |
| 111 | + iupgrade_wait "${TEST_CHART_REPO}" "${TEST_CHART_VERSION}" _iargs |
| 112 | + |
| 113 | + kubectl apply -f demo/specs/imex/channel-injection.yaml |
| 114 | + kubectl wait --for=condition=READY pods imex-channel-injection --timeout=100s |
| 115 | + |
| 116 | + # Confirm that the CD daemon logs on level six |
| 117 | + run get_all_cd_daemon_logs_for_cd_name "imex-channel-injection" |
| 118 | + assert_output --partial 'wait for nodes update' # level 1 msg |
| 119 | + assert_output --partial 'round_trippers.go' # level 6 msg |
| 120 | + |
| 121 | + # Delete workload and hence CD daemon |
| 122 | + kubectl delete -f demo/specs/imex/channel-injection.yaml |
| 123 | + kubectl wait --for=delete pods imex-channel-injection --timeout=10s |
| 124 | + |
| 125 | + echo "test level 0" |
| 126 | + log_objects |
| 127 | + # Reconfigure (only the) log verbosity for CD daemons spawned in the future. |
| 128 | + # The deployment mutation via `set env` below is expected to restart the |
| 129 | + # controller. Wait for the old controller pod to go away (to be sure that the |
| 130 | + # new LOG_VERBOSITY_CD_DAEMON setting applies), and make sure controller |
| 131 | + # deployment is still READY before moving on (make sure 1/1 READY). |
| 132 | + CPOD_OLD="$(get_current_controller_pod_name)" |
| 133 | + kubectl set env deployment nvidia-dra-driver-gpu-controller -n nvidia-dra-driver-gpu LOG_VERBOSITY_CD_DAEMON=0 |
| 134 | + echo "wait --for=delete: $CPOD_OLD" |
| 135 | + kubectl wait --for=delete pods "$CPOD_OLD" -n nvidia-dra-driver-gpu --timeout=10s |
| 136 | + echo "returned: wait --for=delete" |
| 137 | + CPOD_NEW="$(get_current_controller_pod_name)" |
| 138 | + kubectl wait --for=condition=READY pods "$CPOD_NEW" -n nvidia-dra-driver-gpu --timeout=10s |
| 139 | + echo "new controller pod is in effect" |
| 140 | + |
| 141 | + # Spawn new workload |
| 142 | + kubectl apply -f demo/specs/imex/channel-injection.yaml |
| 143 | + kubectl wait --for=condition=READY pods imex-channel-injection --timeout=100s |
| 144 | + |
| 145 | + # Confirm that the CD daemon now does not contain a level 1 msg |
| 146 | + run get_all_cd_daemon_logs_for_cd_name "imex-channel-injection" |
| 147 | + refute_output --partial 'wait for nodes update' # expected level 1 msg |
| 148 | + |
| 149 | + # Delete workload |
| 150 | + kubectl delete -f demo/specs/imex/channel-injection.yaml |
| 151 | + kubectl wait --for=delete pods imex-channel-injection --timeout=10s |
| 152 | +} |
0 commit comments