Browse Source

Improve gate NIC HW compatibility/portability

Change-Id: I5d878b664f552fe04cd2e672293c27578560dab4
Craig Anderson 7 months ago
parent
commit
d8570fe8ad

+ 1
- 1
divingbell/templates/bin/_ethtool.sh.tpl View File

@@ -76,7 +76,7 @@ add_ethtool_param(){
76 76
   [ "$(echo "${current_val_raw}" | wc -l)" -le 1 ] ||
77 77
     die "More than one match for '${user_key}'"
78 78
   [[ ! ${current_val_raw} = *fixed* ]] ||
79
-    die "'${deivce}' does not permit changing the '${user_key}' setting"
79
+    die "'${device}' does not permit changing the '${user_key}' setting"
80 80
   if [[ ${current_val_raw} = *off\ \[requested\ on\] ]]; then
81 81
     current_val_raw='off'
82 82
   elif [[ ${current_val_raw} = *on\ \[requested\ off\] ]]; then

+ 24
- 6
tools/gate/scripts/020-test-divingbell.sh View File

@@ -26,10 +26,13 @@ MOUNTS_PATH3=${MOUNTS_SYSTEMD}3
26 26
 ETHTOOL_KEY2=tx-tcp-segmentation
27 27
 ETHTOOL_VAL2_DEFAULT=on
28 28
 ETHTOOL_KEY3=tx-tcp6-segmentation
29
+# Not all NIC hardware has enough ethtool tunables available
30
+ETHTOOL_KEY3_BACKUP=''
29 31
 ETHTOOL_VAL3_DEFAULT=on
30 32
 ETHTOOL_KEY4=tx-nocache-copy
31 33
 ETHTOOL_VAL4_DEFAULT=off
32 34
 ETHTOOL_KEY5=tx-checksum-ip-generic
35
+ETHTOOL_KEY5_BACKUP=tx-scatter-gather
33 36
 ETHTOOL_VAL5_DEFAULT=on
34 37
 USERNAME1=userone
35 38
 USERNAME1_SUDO=true
@@ -59,6 +62,13 @@ for line in ${nic_info}; do
59 62
   fi
60 63
 done
61 64
 [ -n "${DEVICE}" ] || (echo Could not find physical NIC for tesing; exit 1)
65
+# Not all hardware has the same NIC tunables to use for testing
66
+if [[ $(/sbin/ethtool -k "${DEVICE}" | grep "${ETHTOOL_KEY3}:") =~ .*fixed.* ]]; then
67
+  ETHTOOL_KEY3="${ETHTOOL_KEY3_BACKUP}"
68
+fi
69
+if [[ $(/sbin/ethtool -k "${DEVICE}" | grep "${ETHTOOL_KEY5}:") =~ .*fixed.* ]]; then
70
+  ETHTOOL_KEY5="${ETHTOOL_KEY5_BACKUP}"
71
+fi
62 72
 
63 73
 exec >& >(while read line; do echo "${line}" | sudo tee -a ${LOG_NAME}; done)
64 74
 
@@ -101,6 +111,9 @@ _write_sysctl(){
101 111
 
102 112
 _write_ethtool(){
103 113
   local cur_val
114
+  if [ -z "${2}" ]; then
115
+    return
116
+  fi
104 117
   cur_val="$(/sbin/ethtool -k ${1} |
105 118
              grep "${2}:" | cut -d':' -f2 | cut -d' ' -f2)"
106 119
   if [ "${cur_val}" != "${3}" ]; then
@@ -126,7 +139,7 @@ init_default_state(){
126 139
   _write_sysctl ${SYSCTL_KEY4} ${SYSCTL_VAL4_DEFAULT}
127 140
   # set ethtool original vals
128 141
   _write_ethtool ${DEVICE} ${ETHTOOL_KEY2} ${ETHTOOL_VAL2_DEFAULT}
129
-  _write_ethtool ${DEVICE} ${ETHTOOL_KEY3} ${ETHTOOL_VAL3_DEFAULT}
142
+  _write_ethtool ${DEVICE} "${ETHTOOL_KEY3}" ${ETHTOOL_VAL3_DEFAULT}
130 143
   _write_ethtool ${DEVICE} ${ETHTOOL_KEY4} ${ETHTOOL_VAL4_DEFAULT}
131 144
   _write_ethtool ${DEVICE} ${ETHTOOL_KEY5} ${ETHTOOL_VAL5_DEFAULT}
132 145
   # Remove any created accounts, SSH keys
@@ -403,6 +416,9 @@ test_mounts(){
403 416
 }
404 417
 
405 418
 _test_ethtool_value(){
419
+  if [ -z "${1}" ]; then
420
+    return
421
+  fi
406 422
   test "$(/sbin/ethtool -k ${DEVICE} |
407 423
           grep "${1}:" | cut -d':' -f2 | tr -d '[:space:]')" = "${2}"
408 424
 }
@@ -412,17 +428,18 @@ test_ethtool(){
412 428
   local overrides_yaml=${LOGS_SUBDIR}/${FUNCNAME}-set1.yaml
413 429
   local val2=on
414 430
   local val3=off
431
+  [ -n "${ETHTOOL_KEY3}" ] && local line2_1="${ETHTOOL_KEY3}: $val3"
415 432
   local val4=off
416 433
   echo "conf:
417 434
   ethtool:
418 435
     ${DEVICE}:
419 436
       $ETHTOOL_KEY2: $val2
420
-      $ETHTOOL_KEY3: $val3
437
+      $line2_1
421 438
       $ETHTOOL_KEY4: $val4" > "${overrides_yaml}"
422 439
   install_base "--values=${overrides_yaml}"
423 440
   get_container_status ethtool
424 441
   _test_ethtool_value $ETHTOOL_KEY2 $val2
425
-  _test_ethtool_value $ETHTOOL_KEY3 $val3
442
+  _test_ethtool_value "$ETHTOOL_KEY3" $val3
426 443
   _test_ethtool_value $ETHTOOL_KEY4 $val4
427 444
   echo '[SUCCESS] ethtool test1 passed successfully' >> "${TEST_RESULTS}"
428 445
 
@@ -430,17 +447,18 @@ test_ethtool(){
430 447
   overrides_yaml=${LOGS_SUBDIR}/${FUNCNAME}-set2.yaml
431 448
   val2=off
432 449
   val3=on
450
+  [ -n "${ETHTOOL_KEY3}" ] && local line2_2="${ETHTOOL_KEY3}: $val3"
433 451
   val4=on
434 452
   echo "conf:
435 453
   ethtool:
436 454
     ${DEVICE}:
437 455
       $ETHTOOL_KEY2: $val2
438
-      $ETHTOOL_KEY3: $val3
456
+      $line2_2
439 457
       $ETHTOOL_KEY4: $val4" > "${overrides_yaml}"
440 458
   install_base "--values=${overrides_yaml}"
441 459
   get_container_status ethtool
442 460
   _test_ethtool_value $ETHTOOL_KEY2 $val2
443
-  _test_ethtool_value $ETHTOOL_KEY3 $val3
461
+  _test_ethtool_value "$ETHTOOL_KEY3" $val3
444 462
   _test_ethtool_value $ETHTOOL_KEY4 $val4
445 463
   echo '[SUCCESS] ethtool test2 passed successfully' >> "${TEST_RESULTS}"
446 464
 
@@ -448,7 +466,7 @@ test_ethtool(){
448 466
   install_base
449 467
   get_container_status ethtool
450 468
   _test_ethtool_value $ETHTOOL_KEY2 $ETHTOOL_VAL2_DEFAULT
451
-  _test_ethtool_value $ETHTOOL_KEY3 $ETHTOOL_VAL3_DEFAULT
469
+  _test_ethtool_value "$ETHTOOL_KEY3" $ETHTOOL_VAL3_DEFAULT
452 470
   _test_ethtool_value $ETHTOOL_KEY4 $ETHTOOL_VAL4_DEFAULT
453 471
   echo '[SUCCESS] ethtool test3 passed successfully' >> "${TEST_RESULTS}"
454 472
 

Loading…
Cancel
Save