Skip to content

Commit

Permalink
- Fixes for missing import, dump path and binary location
Browse files Browse the repository at this point in the history
  • Loading branch information
jitendra-nvi authored and afsanac-nv committed Mar 13, 2024
1 parent ddbf348 commit 733bd80
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 46 deletions.
4 changes: 0 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ RUN apt-get update

RUN apt-get install python3-pip zlib1g-dev scons -y

ARG LOCAL_DIR

ENV LOCAL_DIR_ENV=$LOCAL_DIR

WORKDIR /app

COPY . /app
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ DOCKER_IMAGE_TAG=pyinstaller-ctam
DOCKER_CONTAINER_NAME=build-ctam

build_image:
docker build --tag $(DOCKER_IMAGE_TAG) --build-arg LOCAL_DIR=$(PWD) .
docker build --tag $(DOCKER_IMAGE_TAG) .
docker run -it --name $(DOCKER_CONTAINER_NAME) $(DOCKER_IMAGE_TAG)
docker cp $(DOCKER_CONTAINER_NAME):/app/dist ./dist
docker rm -f $(DOCKER_CONTAINER_NAME)
Expand Down
8 changes: 1 addition & 7 deletions build_scripts/build_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@
# LICENSE file in the root directory of this source tree.
#

# get current directory
export current_dir="$LOCAL_DIR_ENV"

# path to binary
dist_dir="${current_dir}/dist"

# pyinstaller command to make binary
pyinstaller_cmd="pyinstaller --add-data=/app/ctam:. --name ctam.build --paths=/app/ctam --onefile ctam/ctam.py --runtime-tmpdir ${dist_dir}"
pyinstaller_cmd="pyinstaller --add-data=/app/ctam:. --name ctam.build --paths=/app/ctam --onefile ctam/ctam.py --workpath /tmp --distpath dist --exclude-module sqlite3"

# static to make one executable
staticx_cmd="staticx ./dist/ctam.build ./dist/ctam"
Expand Down
5 changes: 3 additions & 2 deletions ctam/ctam.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def parse_args():
help="Display current version of ctam",
action="store_true",
)

return parser.parse_args()

def get_exception_details(exec: Exception = ""):
Expand All @@ -93,6 +92,7 @@ def get_exception_details(exec: Exception = ""):
"""
exc_type, exc_obj, exc_tb = sys.exc_info()
temp = exc_tb

traceback_details = {}
while temp:
f_name = os.path.split(temp.tb_frame.f_code.co_filename)[1]
Expand Down Expand Up @@ -136,7 +136,7 @@ def main():
]

missing_files = [
file for file in required_workspace_files if not os.path.isfile(os.path.join(args.workspace, file))
file_name for file_name in required_workspace_files if not os.path.isfile(os.path.join(args.workspace, file_name))
]

if missing_files:
Expand Down Expand Up @@ -260,3 +260,4 @@ def main():
print(f"Log Directory: {log_directory}")
print("\n*Note: Return/Status Codes - PASS(0): All tests passed, FAIL(1): Execution/runtime failure or test failure\n")
exit(status_code)

21 changes: 8 additions & 13 deletions ctam/interfaces/comptool_dut.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import shlex
from os import path
from alive_progress import alive_bar
# import pandas as pd
import pandas as pd

from prettytable import PrettyTable
from ocptv.output import Metadata
Expand Down Expand Up @@ -80,7 +80,7 @@ def __init__(
self.logger_path = logger_path
self.test_info_logger = test_info_logger
self.test_uri_response_check = test_uri_response_check
self.cwd = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
self.cwd = self.get_cwd()
super().__init__(id, name, metadata)
self.connection_ip_address = config["properties"]["ConnectionIPAddress"][
"value"
Expand All @@ -103,7 +103,12 @@ def __init__(

self.redfish_ifc = None
self.redfish_auth = config["properties"].get("AuthenticationRequired", {}).get("value", False)


def get_cwd(self):
cwd = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
return "" if cwd == "/tmp" else cwd


def set_up_connection(self):
"""
This method sets up connection to the DUT,
Expand Down Expand Up @@ -437,13 +442,3 @@ def GetSystemDetails(self, print_details=0): # FIXME: Use logging method and fix
print("[FATAL] Exception occurred during system discovery. Please see below exception...")
print(str(e))
return ["[FATAL] Exception occurred during system discovery. Please see below exception...",str(e)], False










11 changes: 6 additions & 5 deletions ctam/interfaces/functional_ifc.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def __init__(self):
Default init for now
"""
pass


def get_JSONFWFilePayload_file(self, image_type="default", corrupted_component_id=None):
"""
Expand Down Expand Up @@ -263,7 +264,6 @@ def get_JSONFWFilePayload_file(self, image_type="default", corrupted_component_i
elif image_type == "negate":
self.test_run().add_log(LogSeverity.INFO, "Negative Test Case")
json_fw_file_payload = ""

return json_fw_file_payload

def get_PLDMPkgJson_file(self, image_type="default"):
Expand Down Expand Up @@ -308,7 +308,6 @@ def get_PLDMPkgJson_file(self, image_type="default"):
self.dut().package_config.get("GPU_FW_IMAGE_CORRUPT_COMPONENT", {}).get("Path", ""),
self.dut().package_config.get("GPU_FW_IMAGE_CORRUPT_COMPONENT", {}).get("JSON", ""),
)

return pldm_json_file

def ctam_getfi(self, expanded=0):
Expand Down Expand Up @@ -491,7 +490,9 @@ def NodeACReset(self):
return
self.test_run().add_log(LogSeverity.INFO, json.dumps(command_to_run, indent=4))
arguments = shlex.split(command_to_run)
subprocess.check_output(arguments, cwd=os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
cwd_path = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
cwd_path = None if cwd_path == "/tmp" else cwd_path
subprocess.check_output(arguments, cwd=cwd_path)
time.sleep(self.dut().dut_config.get("PowerOffWaitTime", {}).get("value", 60))
self.test_run().add_log(LogSeverity.INFO, "Power Off wait time done")
command_to_run = self.dut().dut_config.get("PowerOnCommand", {}).get("value", "")
Expand All @@ -500,7 +501,7 @@ def NodeACReset(self):
return
self.test_run().add_log(LogSeverity.INFO, json.dumps(command_to_run, indent=4))
arguments = shlex.split(command_to_run)
subprocess.check_output(arguments, cwd=os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
subprocess.check_output(arguments, cwd=cwd_path)
time.sleep(self.dut().dut_config.get("PowerOnWaitTime", {}).get("value", 300))
self.test_run().add_log(LogSeverity.INFO, "Power ON wait time done")
return
Expand Down Expand Up @@ -874,4 +875,4 @@ def ctam_redfish_GET_status_ok(self, uri):
else:
self.test_run().add_log(LogSeverity.FATAL, "GET request Failed: {} : {}".format(uri, JSONData))
result = False
return result
return result
2 changes: 1 addition & 1 deletion ctam/interfaces/fw_update_ifc.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,4 +645,4 @@ def ctam_get_version_from_bundle(self, image_type):





12 changes: 5 additions & 7 deletions ctam/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,11 @@ def __init__(
self.console_log = True
self.progress_bar = False
self.package_config = package_info_json_file

runner_config = self._get_test_runner_config(test_runner_json_file)

with open(dut_info_json_file) as dut_info_json:
self.dut_config = json.load(dut_info_json)

# with open(package_info_json_file) as package_info_json:
# self.package_config = json.load(package_info_json)


with open(redfish_uri_config_file) as redfish_uri:
self.redfish_uri_config = json.load(redfish_uri)

Expand Down Expand Up @@ -243,10 +240,10 @@ def _start(self, testrun_name="initialization"):
self.cwd = os.path.dirname(os.path.dirname(__file__))
self.dt = datetime.now().strftime("%m_%d_%Y_%H_%M_%S")
if self.workspace_dir:
print("Output Dir is : ", self.output_dir)
self.output_dir = os.path.join(
self.workspace_dir, self.output_dir, "TestRuns", testrun_name+"_{}".format(self.dt)
)
print("Output Dir is : ", self.output_dir)
else:
self.output_dir = os.path.join(
"workspace", "TestRuns", testrun_name+"_{}".format(self.dt)
Expand All @@ -269,7 +266,8 @@ def _start(self, testrun_name="initialization"):
self.test_result_file = os.path.join(self.output_dir, "TestReport_{}.log".format(self.dt))
self.test_uri_response_check = None
if self.response_check_name:
self.test_uri_response_check = os.path.join(self.cwd, "workspace", self.response_check_name)
cwd = "" if self.cwd == "/tmp" else self.cwd
self.test_uri_response_check = os.path.join(cwd, "workspace", self.response_check_name)

self.comp_tool_dut = CompToolDut(
id="actDut",
Expand Down
12 changes: 6 additions & 6 deletions json_spec/input/.netrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<IP ADDRESS 1>
<USERNAME 1>
<PASSWORD 1>
machine <IP ADDRESS 1>
login <USERNAME 1>
password <PASSWORD 1>

<IP ADDRESS 2>
<USERNAME 2>
<PASSWORD 2>
machine <IP ADDRESS 2>
login <USERNAME 2>
password <PASSWORD 2>
1 change: 1 addition & 0 deletions pip-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ redfish
regex
mypy
isort
pandas
pip-tools
pytest
pytest-cov
Expand Down

0 comments on commit 733bd80

Please sign in to comment.