forked from SNIA/Swordfish-API-Emulator
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into agent-aggregation-source
- Loading branch information
Showing
77 changed files
with
36 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
name: Testing OFMF | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: master | ||
pull_request: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
|
||
*.pyc | ||
__pycache__/* |
Binary file not shown.
Binary file removed
BIN
-1.23 KB
api_emulator/redfish/templates/__pycache__/CompositionService.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-3.25 KB
api_emulator/redfish/templates/__pycache__/ComputerSystem.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.13 KB
api_emulator/redfish/templates/__pycache__/Connection.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-1.13 KB
api_emulator/redfish/templates/__pycache__/Endpoint0.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.16 KB
api_emulator/redfish/templates/__pycache__/EndpointGroup3.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.2 KB
api_emulator/redfish/templates/__pycache__/EthernetInterface0.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.38 KB
api_emulator/redfish/templates/__pycache__/EthernetInterface6.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.47 KB
api_emulator/redfish/templates/__pycache__/EventService.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-1.21 KB
api_emulator/redfish/templates/__pycache__/LogEntry0.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-1.17 KB
api_emulator/redfish/templates/__pycache__/NetworkAdapter.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.31 KB
api_emulator/redfish/templates/__pycache__/NetworkDeviceFunction.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-946 Bytes
api_emulator/redfish/templates/__pycache__/ResetActionInfo_template.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.22 KB
api_emulator/redfish/templates/__pycache__/ResourceBlock.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.41 KB
api_emulator/redfish/templates/__pycache__/ResourceZone.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.14 KB
api_emulator/redfish/templates/__pycache__/ServiceRoot.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.17 KB
api_emulator/redfish/templates/__pycache__/SessionService.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-1.07 KB
api_emulator/redfish/templates/__pycache__/Storage0.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.17 KB
api_emulator/redfish/templates/__pycache__/StorageController0.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-2.46 KB
api_emulator/redfish/templates/__pycache__/StorageServices.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-2.28 KB
api_emulator/redfish/templates/__pycache__/StorageSystems.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.14 KB
api_emulator/redfish/templates/__pycache__/Subscription.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-200 Bytes
api_emulator/redfish/templates/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.12 KB
api_emulator/redfish/templates/__pycache__/c_memory.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-2.14 KB
api_emulator/redfish/templates/__pycache__/classesofservice.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.08 KB
api_emulator/redfish/templates/__pycache__/collection.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.2 KB
api_emulator/redfish/templates/__pycache__/connections.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-2.42 KB
api_emulator/redfish/templates/__pycache__/dataprotectionloscapabilities.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.83 KB
api_emulator/redfish/templates/__pycache__/datasecurityloscapabilities.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.49 KB
api_emulator/redfish/templates/__pycache__/datastorageloscapabilities.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-1.21 KB
api_emulator/redfish/templates/__pycache__/eg_resource.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.16 KB
api_emulator/redfish/templates/__pycache__/eg_subresource.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.17 KB
api_emulator/redfish/templates/__pycache__/endpointgroups.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.53 KB
api_emulator/redfish/templates/__pycache__/endpoints.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.85 KB
api_emulator/redfish/templates/__pycache__/ethernetinterface.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.41 KB
api_emulator/redfish/templates/__pycache__/fabric_adapter_port.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.54 KB
api_emulator/redfish/templates/__pycache__/fabric_switch_port.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-2.37 KB
api_emulator/redfish/templates/__pycache__/fabricadapters.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-2.38 KB
api_emulator/redfish/templates/__pycache__/filesystems.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.33 KB
api_emulator/redfish/templates/__pycache__/ioconnectivityloscapabilities.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.91 KB
api_emulator/redfish/templates/__pycache__/ioperformanceloscapabilities.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-1.19 KB
api_emulator/redfish/templates/__pycache__/md_chunks.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.56 KB
api_emulator/redfish/templates/__pycache__/mediacontrollers.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-1.17 KB
api_emulator/redfish/templates/__pycache__/memory_domains.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.63 KB
api_emulator/redfish/templates/__pycache__/networkadapters.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.93 KB
api_emulator/redfish/templates/__pycache__/networkdevicefunctions.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-1.71 KB
api_emulator/redfish/templates/__pycache__/pcie_switch.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-1.67 KB
api_emulator/redfish/templates/__pycache__/processor.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-2.38 KB
api_emulator/redfish/templates/__pycache__/redfish_computer_system.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-1.51 KB
api_emulator/redfish/templates/__pycache__/simplestorage.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.44 KB
api_emulator/redfish/templates/__pycache__/storagecontrollers.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.85 KB
api_emulator/redfish/templates/__pycache__/storagegroups.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.9 KB
api_emulator/redfish/templates/__pycache__/storagepools.cpython-310.pyc
Binary file not shown.
Binary file removed
BIN
-1.59 KB
api_emulator/redfish/templates/__pycache__/switches.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,34 @@ | ||
import json | ||
import pprint | ||
import requests | ||
import test_templates | ||
import sys | ||
|
||
def send_post(url, payload): | ||
headers = {'Content-type':'application/json', 'Accept':'text/plain'} | ||
resp = requests.post (url, data = json.dumps(payload), headers = headers) | ||
|
||
return resp.status_code | ||
|
||
def send_get(url): | ||
resp = requests.get(url) | ||
|
||
return resp.status_code, resp.json() | ||
|
||
def send_delete(url): | ||
resp = requests.delete(url) | ||
|
||
return resp.status_code | ||
|
||
def test_create_chassis(url): | ||
chassis_url = f"{url}/Chassis" | ||
ret_code = send_post(chassis_url, test_templates.test_chassis) | ||
|
||
if ret_code == 200: | ||
return True | ||
else: | ||
return False | ||
|
||
def test_create_computer_system(url): | ||
# I am assuming we have already created the target Chassis | ||
system_url = f"{url}/Systems" | ||
ret_code = send_post(system_url, test_templates.test_system) | ||
|
||
if ret_code == 200: | ||
return True | ||
else: | ||
return False | ||
|
||
|
||
def test_create_computer_system_duplicate_id(): | ||
# To Be Implemented | ||
pass | ||
|
||
|
||
def main(): | ||
url = "http://localhost:5000/redfish/v1" | ||
|
||
print("##### Starting test Suite #####") | ||
print() | ||
print ("Testing creating a Chassis...") | ||
if test_create_chassis(url): | ||
print ("PASSED") | ||
else: | ||
print ("FAILED") | ||
sys.exit(1) | ||
|
||
print("Testing creating a ComputerSystem...") | ||
if test_create_computer_system(url): | ||
print ("PASSED") | ||
else: | ||
print ("FAILED") | ||
sys.exit(1) | ||
|
||
import unittest | ||
from api_emulator.resource_manager import ResourceManager | ||
import g | ||
|
||
REST_BASE = '/redfish/v1' | ||
g.rest_base = REST_BASE | ||
|
||
class TestOFMF(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
global resource_manager | ||
global REST_BASE | ||
global TRAYS | ||
global SPEC | ||
resource_manager = ResourceManager(None, None, None, "Disable", None) | ||
g.app.testing = True | ||
cls.client = g.app.test_client() | ||
|
||
def test_create_computer_system(self): | ||
system_url = f"{REST_BASE}/Systems" | ||
response = self.client.post(system_url, json=test_templates.test_system) | ||
status_code = response.status_code | ||
self.assertEqual(status_code, 200) | ||
|
||
def test_create_chassis(self): | ||
chassis_url = f"{REST_BASE}/Chassis" | ||
response = self.client.post(chassis_url, json=test_templates.test_chassis) | ||
status_code = response.status_code | ||
self.assertEqual(status_code, 200) | ||
|
||
if __name__ == '__main__': | ||
main() | ||
unittest.main() | ||
# main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,12 @@ | ||
#!/bin/bash | ||
TIMEOUT=30 | ||
|
||
wait_ofmf () { | ||
NOW=0 | ||
ELAPSED=0 | ||
START=$(date +"%s") | ||
while [ $ELAPSED -lt $TIMEOUT ] | ||
do | ||
curl http://localhost:5000/redfish/v1 > /dev/null 2>&1 | ||
if [ $? -eq 0 ] | ||
then | ||
return 0 | ||
fi | ||
# No need to go crazy here, let's sleep for a while | ||
sleep 1 | ||
NOW=$(date +"%s") | ||
ELAPSED=$((${NOW} - ${START})) | ||
done | ||
|
||
return 1 | ||
} | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
echo "Script dir: $SCRIPT_DIR" | ||
|
||
${SCRIPT_DIR}/../setup.sh -w ./emul -n | ||
|
||
cp ${SCRIPT_DIR}/emulator-config-http.json ${SCRIPT_DIR}/../emul/emulator-config.json | ||
cd ${SCRIPT_DIR}/../emul | ||
./venv/bin/python emulator.py & | ||
cd - | ||
|
||
# wait for the OFMF service to be up of fail after TIMEOUT seconds | ||
wait_ofmf | ||
if [ $? -eq 1 ] | ||
then | ||
echo "Timing out, the OFMF failed to start" | ||
exit 1 | ||
fi | ||
source ./venv/bin/activate | ||
|
||
python ${SCRIPT_DIR}/test.py | ||
python -m unittest discover -s tests |