Skip to content

Commit

Permalink
add bios get/set tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Salmela <jacob.salmela@hpe.com>
  • Loading branch information
jacobsalmela committed Oct 26, 2023
1 parent f6d39a1 commit eb77326
Show file tree
Hide file tree
Showing 9 changed files with 470 additions and 11 deletions.
103 changes: 103 additions & 0 deletions spec/functional/bios_get_attributes_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/usr/bin/env sh
# MIT License
#
# (C) Copyright 2023 Hewlett Packard Enterprise Development LP
#
# Permissioff is hereby granted, free of charge, to any persoff obtaining a
# copy of this software and associated documentatioff files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permissioff notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTIoff OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTIoff WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

Describe 'gru get bios'

BeforeAll use_valid_config

# getting a single key should return only those key
It "--config ${GRU_CONF} --attributes BootTimeout 127.0.0.1:5000"
When call ./gru get bios --config "${GRU_CONF}" --attributes BootTimeout 127.0.0.1:5000
The status should equal 0
The stdout should include 'BootTimeout'
The lines of stdout should equal 3
End

# getting a single key should return only those key in json
It "--config ${GRU_CONF} --attributes BootTimeout 127.0.0.1:5000 --json"
When call ./gru get bios --config "${GRU_CONF}" --attributes BootTimeout 127.0.0.1:5000 --json
The status should equal 0
The stdout should include 'BootTimeout'
The stdout should be_json
End

# getting multiple keys should return only those keys
It "--config ${GRU_CONF} --attributes ProcessorHyperThreadingDisable,SRIOVEnable 127.0.0.1:5000"
When call ./gru get bios --config "${GRU_CONF}" --attributes ProcessorHyperThreadingDisable,SRIOVEnable 127.0.0.1:5000
The status should equal 0
The stdout should include 'ProcessorHyperThreadingDisable'
The stdout should include 'SRIOVEnable'
The lines of stdout should equal 4
End

# getting specific keys should return only those keys and should be json
It "--config ${GRU_CONF} --attributes ProcessorHyperThreadingDisable,SRIOVEnable 127.0.0.1:5000 --json"
When call ./gru get bios --config "${GRU_CONF}" --attributes ProcessorHyperThreadingDisable,SRIOVEnable 127.0.0.1:5000 --json
The status should equal 0
The stdout should include 'ProcessorHyperThreadingDisable'
The stdout should include 'SRIOVEnable'
The stdout should be_json
End

# it should error if no matching keys were found
It "--config ${GRU_CONF} --attributes junk 127.0.0.1:5000"
When call ./gru get bios --config "${GRU_CONF}" --attributes junk 127.0.0.1:5000
The status should equal 0
The line 3 of stdout should include 'junk'
The line 3 of stdout should include '<nil>'
The lines of stdout should equal 3
End

# it should error if no attributes are passed to the flag
It "--config ${GRU_CONF} --attributes 127.0.0.1:5000"
When call ./gru get bios --config "${GRU_CONF}" --attributes 127.0.0.1:5000
The status should equal 1
The stderr should include 'requires at least 1 arg(s), only received 0'
End

# --virt shortcut should return only virtualization attributes (Gigabyte)
It "--config ${GRU_CONF} --virt 127.0.0.1:5001"
When call ./gru get bios --config "${GRU_CONF}" --virt 127.0.0.1:5001
The status should equal 0
The stdout should include 'SR-IOV Support'
The stdout should include 'SMT Control'
The stdout should include 'Local APIC Mode'
The stdout should include 'IOMMU'
The stdout should include 'SVM Mode'
The lines of stdout should equal 7
End

# --virt shortcut should return only virtualization attributes in json format (Gigabyte)
It "--config ${GRU_CONF} --virt 127.0.0.1:5001 --json"
When call ./gru get bios --config "${GRU_CONF}" --virt 127.0.0.1:5001 --json
The status should equal 0
The stdout should include 'PCIS007' # 'SR-IOV Support'
The stdout should include 'Rome0039' # 'Local APIC Mode'
The stdout should include 'Rome0059' # 'SMT Control'
The stdout should include 'Rome0162' # 'IOMMU'
The stdout should include 'Rome0565' # 'SVM Mode'
The stdout should be_json
End


End
104 changes: 104 additions & 0 deletions spec/functional/bios_get_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env sh
# MIT License
#
# (C) Copyright 2023 Hewlett Packard Enterprise Development LP
#
# Permissioff is hereby granted, free of charge, to any persoff obtaining a
# copy of this software and associated documentatioff files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permissioff notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTIoff OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTIoff WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.


Describe 'gru get bios'

BeforeAll use_valid_config
BeforeAll use_valid_bios_attributes_file

# getting all bios keys should return lots of output
It "--config ${GRU_CONF} 127.0.0.1:5000"
When call ./gru get bios --config "${GRU_CONF}" 127.0.0.1:5000
The status should equal 0
# check for some arbitrary keys to ensure it is not junk
The stdout should include 'ProcessorHyperThreadingDisable'
The stdout should include 'SRIOVEnable'
The stdout should include 'VTdSupport'
The lines of stdout should equal 866
End

# neglecting to add a host as an arg should fail with instructions
It "--config ${GRU_CONF}"
When call ./gru --config "${GRU_CONF}" get bios
The status should equal 1
The stderr should include 'Error: requires at least 1 arg(s), only received 0'
End

# getting pending changes should return an error if the Bios/Settings.Attributes does not exist
It "--config ${GRU_CONF} --pending 127.0.0.1:5000"
When call ./gru get bios --config "${GRU_CONF}" --pending 127.0.0.1:5000
The status should equal 0
The stdout should include 'Error'
The stdout should include '"Attributes" does not exist or is null. You may need to update the BIOS/firmware'
The lines of stdout should equal 3
End

# getting pending changes should return an error if the Bios/Settings.Attributes does not exist and be valid json
It "--config ${GRU_CONF} --pending 127.0.0.1:5000 --json"
When call ./gru get bios --config "${GRU_CONF}" --pending 127.0.0.1:5000 --json
The status should equal 0
The stdout should include 'Error'
The stdout should include '\"Attributes\" does not exist or is null. You may need to update the BIOS/firmware'
The stdout should be_json
End

# getting keys from a file should return those keys
It "--config ${GRU_CONF} --from-file ${GRU_BIOS_KV} 127.0.0.1:5000"
When call ./gru get bios --config "${GRU_CONF}" --from-file "${GRU_BIOS_KV}" 127.0.0.1:5000
The status should equal 0
The stdout should include 'BootTimeout'
The stdout should include 'SRIOVEnable'
The lines of stdout should equal 4
End

# getting keys from a file should return those keys and be valid json
It "--config ${GRU_CONF} --from-file ${GRU_BIOS_KV} 127.0.0.1:5000 --json"
When call ./gru get bios --config "${GRU_CONF}" --from-file "${GRU_BIOS_KV}" 127.0.0.1:5000 --json
The status should equal 0
The stdout should include 'BootTimeout'
The stdout should include 'SRIOVEnable'
The stdout should be_json
End

# passing a shortcut should return a limited set of pre-defined keys
It "--config ${GRU_CONF} --virt 127.0.0.1:5003"
When call ./gru get bios --config "${GRU_CONF}" --virt 127.0.0.1:5003
The status should equal 0
The stdout should include 'ProcAmdIOMMU'
The stdout should include 'Sriov'
The stdout should include 'ProcAmdVirtualization'
The lines of stdout should equal 6
End

# passing a shortcut should return a limited set of pre-defined keys and be valid json
It "--config ${GRU_CONF} --virt 127.0.0.1:5003 --json"
When call ./gru get bios --config "${GRU_CONF}" --virt 127.0.0.1:5003 --json
The status should equal 0
The stdout should include 'ProcAmdIOMMU'
The stdout should include 'ProcAmdVirtualization'
The stdout should include 'Sriov'
The stdout should be_json
End

End
44 changes: 44 additions & 0 deletions spec/functional/bios_set_attributes_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env sh
# MIT License
#
# (C) Copyright 2023 Hewlett Packard Enterprise Development LP
#
# Permissioff is hereby granted, free of charge, to any persoff obtaining a
# copy of this software and associated documentatioff files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permissioff notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTIoff OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTIoff WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

Describe 'gru set bios'

BeforeAll use_valid_config

# FIXME: the simulator has a limitation and returns 405 for PATCH ops
# # setting specific keys should work
# It "--config ${GRU_CONF} --attributes ProcessorHyperThreadingDisable=0,SRIOVEnable=0 127.0.0.1:5000"
# When call ./gru set bios --config "${GRU_CONF}" --attributes ProcessorHyperThreadingDisable=0,SRIOVEnable=0 127.0.0.1:5000
# The status should equal 0
# The stdout should include 'BIOS change(s) may be applied at: ["Immediate","OnReset","AtMaintenanceWindowStart","InMaintenanceWindowOnReset"]'
# The lines of stdout should equal 3
# End

# it should error if no attributes are passed to the flag
It "--config ${GRU_CONF} --attributes 127.0.0.1:5000"
When call ./gru set bios --config "${GRU_CONF}" --attributes 127.0.0.1:5000
The status should equal 1
The stderr should include 'requires at least 1 arg(s), only received 0'
End

End
124 changes: 124 additions & 0 deletions spec/functional/bios_set_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#!/usr/bin/env sh
# MIT License
#
# (C) Copyright 2023 Hewlett Packard Enterprise Development LP
#
# Permissioff is hereby granted, free of charge, to any persoff obtaining a
# copy of this software and associated documentatioff files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permissioff notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTIoff OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTIoff WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.


Describe 'gru set bios'

BeforeAll use_valid_config
BeforeAll use_valid_bios_attributes_file

# setting without flags should fail
It "--config ${GRU_CONF} 127.0.0.1:5000"
When call ./gru set bios --config "${GRU_CONF}" 127.0.0.1:5000
The status should equal 1
The stderr should include 'An error occurred: at least one of the flags in the group [attributes from-file virt defaults] is required'
End

# neglecting to add a host as an arg should fail with instructions
It "--config ${GRU_CONF}"
When call ./gru --config "${GRU_CONF}" set bios
The status should equal 1
The stderr should include 'Error: requires at least 1 arg(s), only received 0'
End

# FIXME: the emulator does not support PATCH ops. Once it does, uncomment, adjust if needed
# # restoring defaults
# It "--config ${GRU_CONF} --defaults 127.0.0.1:5000"
# When call ./gru set bios --config "${GRU_CONF}" --defaults 127.0.0.1:5000
# The status should equal 0
# The stdout should include 'Error'
# The stdout should include 'BIOS reset failure: unable to execute request, no target provided'
# The lines of stdout should equal 3
# End

# # restoring defaults and be valid json
# It "--config ${GRU_CONF} --defaults 127.0.0.1:5000 --json"
# When call ./gru set bios --config "${GRU_CONF}" --defaults 127.0.0.1:5000 --json
# The status should equal 0
# The stdout should include 'Error'
# The stdout should include 'BIOS reset failure: unable to execute request, no target provided'
# The stdout should be_json
# End

# # setting keys from a file should return those keys
# It "--config ${GRU_CONF} --from-file ${GRU_BIOS_KV} 127.0.0.1:5000"
# When call ./gru set bios --config "${GRU_CONF}" --from-file "${GRU_BIOS_KV}" 127.0.0.1:5000
# The status should equal 0
# The stdout should include 'Pending'
# The stdout should include 'Attributes'
# The stdout should include 'BootMode'
# The stdout should include 'BootTimeout'
# The stdout should include 'ProcessorHyperThreadingDisable'
# The stdout should include 'ProcessorVmxEnable'
# The stdout should include 'ProcessorX2apic'
# The stdout should include 'SRIOVEnable'
# The stdout should include 'SvrMngmntAcpiIpmi'
# The stdout should include 'VTdSupport'
# The lines of stdout should equal 3
# End

# # setting keys from a file should return those keys and be valid json
# It "--config ${GRU_CONF} --from-file ${GRU_BIOS_KV} 127.0.0.1:5000 --json"
# When call ./gru set bios --config "${GRU_CONF}" --from-file "${GRU_BIOS_KV}" 127.0.0.1:5000 --json
# The status should equal 0
# The stdout should include 'Pending'
# The stdout should include 'Attributes'
# The stdout should include 'BootMode'
# The stdout should include 'BootTimeout'
# The stdout should include 'ProcessorHyperThreadingDisable'
# The stdout should include 'ProcessorVmxEnable'
# The stdout should include 'ProcessorX2apic'
# The stdout should include 'SRIOVEnable'
# The stdout should include 'SvrMngmntAcpiIpmi'
# The stdout should include 'VTdSupport'
# The stdout should be_json
# End

# # passing a shortcut should return a limited set of pre-defined keys
# It "--config ${GRU_CONF} --virt 127.0.0.1:5000"
# When call ./gru set bios --config "${GRU_CONF}" --virt 127.0.0.1:5000
# The status should equal 0
# The stdout should include 'BootMode'
# The stdout should include 'ProcessorHyperThreadingDisable'
# The stdout should include 'ProcessorVmxEnable'
# The stdout should include 'ProcessorX2apic'
# The stdout should include 'SRIOVEnable'
# The stdout should include 'SvrMngmntAcpiIpmi'
# The stdout should include 'VTdSupport'
# End

# # passing a shortcut should return a limited set of pre-defined keys and be valid json
# It "--config ${GRU_CONF} --virt 127.0.0.1:5000 --json"
# When call ./gru set bios --config "${GRU_CONF}" --virt 127.0.0.1:5000 --json
# The status should equal 0
# The stdout should include 'BootMode'
# The stdout should include 'ProcessorHyperThreadingDisable'
# The stdout should include 'ProcessorVmxEnable'
# The stdout should include 'ProcessorX2apic'
# The stdout should include 'SRIOVEnable'
# The stdout should include 'SvrMngmntAcpiIpmi'
# The stdout should include 'VTdSupport'
# The stdout should be_json
# End

End
Loading

0 comments on commit eb77326

Please sign in to comment.