Skip to content

Commit

Permalink
final testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Pankhuri-Rajesh committed Dec 5, 2024
1 parent d792730 commit 892636a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion goss-testing/scripts/check_iuf_abort.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
# OTHER DEALINGS IN THE SOFTWARE.
#

/opt/cray/tests/install/ncn/scripts/python/iuf_run /opt/cray/tests/install/ncn/scripts/iuf_run_setup test-activity & \
/opt/cray/tests/install/ncn/scripts/python/iuf_run /opt/cray/tests/install/ncn/scripts/iuf_run_setup test-activity && \
sleep 10 && \
iuf -a test-activity abort -f
4 changes: 2 additions & 2 deletions goss-testing/tests/ncn/goss-iuf-invalid-log-dir.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ command:
"{{$iuf_pre_checks}}" "{{ index $pre_checks 0 }}" "{{ index $pre_checks 1 }}" "{{ index $pre_checks 2 }}" "{{ index $pre_checks 3 }}" "{{ index $pre_checks 4 }}" "{{ index $pre_checks 5 }}" && \
# Run the main IUF run step and check for exit code 1
"{{$iuf_run}}" "{{$media_dir}}" "{{ index $activity 0 }}" "{{ index $logdir 0 }}"
"{{$iuf_run}}" "{{$media_dir}}" "{{ index $activity 2 }}" "{{ index $logdir 0 }}"
# Capture the exit code of the previous step
run_exit_code=$?
# Run cleanup step
"{{$iuf_cleanup}}" "{{ index $activity 0 }}"
"{{$iuf_cleanup}}" "{{ index $activity 2 }}"
# Exit with code 1 if the iuf_run command failed
if [ $run_exit_code -eq 1 ]; then
Expand Down
4 changes: 2 additions & 2 deletions goss-testing/tests/ncn/goss-iuf-invalid-media.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ command:
"{{$iuf_pre_checks}}" "{{ index $pre_checks 0 }}" "{{ index $pre_checks 1 }}" "{{ index $pre_checks 2 }}" "{{ index $pre_checks 3 }}" "{{ index $pre_checks 4 }}" "{{ index $pre_checks 5 }}" && \
# Run IUF activity
/usr/bin/iuf -a "{{ index $activity 0 }}" -m "{{$media_dir}}" run -rv "{{$media_dir}}/product_vars.yaml" -r process-media
/usr/bin/iuf -a "{{ index $activity 2 }}" -m "{{$media_dir}}" run -rv "{{$media_dir}}/product_vars.yaml" -r process-media
# Capture the exit code of the previous step
run_exit_code=$?
# Run cleanup step
"{{$iuf_cleanup}}" "{{ index $activity 0 }}"
"{{$iuf_cleanup}}" "{{ index $activity 2 }}"
# Exit with code 1 if the iuf_run command failed
if [ $run_exit_code -eq 1 ]; then
Expand Down
4 changes: 2 additions & 2 deletions goss-testing/tests/ncn/goss-iuf-no-media.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ command:
"{{$iuf_pre_checks}}" "{{ index $pre_checks 0 }}" "{{ index $pre_checks 1 }}" "{{ index $pre_checks 2 }}" "{{ index $pre_checks 3 }}" "{{ index $pre_checks 4 }}" "{{ index $pre_checks 5 }}" && \
# Run IUF
/usr/bin/iuf -a "{{ index $activity 0 }}" run -rv "{{$media_dir}}/product_vars.yaml" -r process-media
/usr/bin/iuf -a "{{ index $activity 2 }}" run -rv "{{$media_dir}}/product_vars.yaml" -r process-media
run_exit_code=$?
# Run cleanup step
"{{$iuf_cleanup}}" "{{ index $activity 0 }}"
"{{$iuf_cleanup}}" "{{ index $activity 2 }}"
# Exit with code 1 if the iuf_run command failed
if [ $run_exit_code -eq 1 ]; then
Expand Down
4 changes: 2 additions & 2 deletions src/csm_testing/lib/iuf_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def get_nexus_credentials(namespace="nexus", secret_name="nexus-admin-credential
run_command(f"kubectl get secret -n {namespace} {secret_name}")

# Retrieve and decode credentials
username_base64 = run_command(f"kubectl get secret -n {namespace} {secret_name} --template={{{{.data.username}}}}")
password_base64 = run_command(f"kubectl get secret -n {namespace} {secret_name} --template={{{{.data.password}}}}")
username_base64, _ = run_command(f"kubectl get secret -n {namespace} {secret_name} --template={{{{.data.username}}}}")
password_base64, _ = run_command(f"kubectl get secret -n {namespace} {secret_name} --template={{{{.data.password}}}}")

if username_base64 and password_base64:
username = base64.b64decode(username_base64).decode()
Expand Down
20 changes: 10 additions & 10 deletions src/csm_testing/tests/iuf_stages/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def process_media(*args):
sys.exit(1)

check_configmap_command = f"kubectl get configmap {ACTIVITY_NAME} -n argo"
configmap_output = run_command(check_configmap_command)
configmap_output, _ = run_command(check_configmap_command)

if configmap_output:
print(f"TEST CASE: ConfigMap found.")
Expand Down Expand Up @@ -178,7 +178,7 @@ def deliver_product(ACTIVITY_NAME):
test_cases += 5
print("INFO: Checking cm...")
check_configmap_command = f"kubectl get configmap {CONFIGMAP_NAME} -n {NAMESPACE} -o json"
configmap_output = run_command(check_configmap_command)
configmap_output, _ = run_command(check_configmap_command)
if configmap_output:
print(f"INFO: ConfigMap found. Checking for entry 'dummy' in the product name...")

Expand Down Expand Up @@ -219,8 +219,8 @@ def update_vcs_config(ACTIVITY_NAME):
command = f"iuf -a {ACTIVITY_NAME} -m {MEDIA_DIR} run -rv {MEDIA_DIR}/product_vars.yaml -bm {MEDIA_DIR}/management-bootprep.yaml -r update-vcs-config"
run_command(command)

vcs_user = run_command("kubectl get secret -n services vcs-user-credentials --template={{.data.vcs_username}} | base64 --decode")
vcs_password = run_command("kubectl get secret -n services vcs-user-credentials --template={{.data.vcs_password}} | base64 --decode")
vcs_user, _ = run_command("kubectl get secret -n services vcs-user-credentials --template={{.data.vcs_username}} | base64 --decode")
vcs_password, _ = run_command("kubectl get secret -n services vcs-user-credentials --template={{.data.vcs_password}} | base64 --decode")

configmap_name = 'cray-configmap-ca-public-key'
gitea_base_url="https://api-gw-service-nmn.local/vcs"
Expand Down Expand Up @@ -289,7 +289,7 @@ def update_cfs_config(ACTIVITY_NAME):
'["sat-bootprep-run"].script_stdout' + "' | xargs -0 echo -e"
)

kubectl_output = run_command(kubectl_command)
kubectl_output, _ = run_command(kubectl_command)

if not kubectl_output:
print(f"ERROR: The output for cfs configurations is null or empty in the {ACTIVITY_NAME} configmap.")
Expand All @@ -300,7 +300,7 @@ def update_cfs_config(ACTIVITY_NAME):
test_cases += 1

cfs_command = "cray cfs configurations list | grep 'config-minimal-management-dummy-1.0.0'"
cfs_output = run_command(cfs_command)
cfs_output, _ = run_command(cfs_command)
if not cfs_output:
print("ERROR: No configuration found in cfs")
print(f"INFO: Total test cases executed for stage operations: {test_cases}")
Expand All @@ -324,7 +324,7 @@ def prepare_images(ACTIVITY_NAME):
'["prepare-images"]["prepare-management-images"]'
'["sat-bootprep-run"].script_stdout' + "' | xargs -0 echo -e"
)
kubectl_output = run_command(kubectl_command)
kubectl_output, _ = run_command(kubectl_command)

if not kubectl_output:
print("Error: The output for configmap entry of images is null or empty.")
Expand All @@ -340,7 +340,7 @@ def prepare_images(ACTIVITY_NAME):
| jq -r '.operation_outputs.stage_params["prepare-images"]["prepare-management-images"]["sat-bootprep-run"].script_stdout | fromjson | .images[] | "\(.name):\(.final_image_id)"'
"""

images_name_and_ids = run_command(images_info_cmd)
images_name_and_ids, _ = run_command(images_info_cmd)

if images_name_and_ids:
image_lines = images_name_and_ids.splitlines()
Expand All @@ -351,7 +351,7 @@ def prepare_images(ACTIVITY_NAME):

print(f"INFO: Checking cray ims images for image Name: {name.strip()} with image ID: {final_image_id.strip()}")
check_ims_cmd=f"cray ims images describe {final_image_id.strip()}"
ims_info = run_command(check_ims_cmd)
ims_info, _ = run_command(check_ims_cmd)
if not ims_info:
print(f"ERROR: Could not find ims image for {name}")
print(f"INFO: Total test cases executed for stage operations: {test_cases}")
Expand All @@ -363,7 +363,7 @@ def prepare_images(ACTIVITY_NAME):
name, final_image_id = image.split(':')
print(f"INFO: Checking cray artifacts boot-images for image Name: {name.strip()}")
check_boot_images_cmd=f"cray artifacts describe boot-images {final_image_id.strip()}/manifest.json "
boot_images_info = run_command(check_boot_images_cmd)
boot_images_info, _ = run_command(check_boot_images_cmd)
if not boot_images_info:
print(f"ERROR: Could not find boot-image for {name}")
print(f"INFO: Total test cases executed for stage operations: {test_cases}")
Expand Down
6 changes: 3 additions & 3 deletions src/csm_testing/tests/iuf_stages_cleanup/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def cleanup_deliver_product():

def cleanup_vcs_branch():
# getting vcs creds
vcs_user = run_command("kubectl get secret -n services vcs-user-credentials --template={{.data.vcs_username}} | base64 --decode")
vcs_password = run_command("kubectl get secret -n services vcs-user-credentials --template={{.data.vcs_password}} | base64 --decode")
vcs_user, _ = run_command("kubectl get secret -n services vcs-user-credentials --template={{.data.vcs_username}} | base64 --decode")
vcs_password, _ = run_command("kubectl get secret -n services vcs-user-credentials --template={{.data.vcs_password}} | base64 --decode")

configmap_name = 'cray-configmap-ca-public-key'
gitea_base_url="https://api-gw-service-nmn.local/vcs"
Expand Down Expand Up @@ -120,7 +120,7 @@ def cleanup_vcs_branch():

def cleanup_cfs_configurations():
cfs_delete_command = "cray cfs configurations delete config-minimal-management-dummy-1.0.0"
cfs_delete_output = run_command(cfs_delete_command)
run_command(cfs_delete_command)
print("INFO: Cleanup complete for UPDATE-CFS-CONFIG stage!")

def cleanup_prepared_images():
Expand Down

0 comments on commit 892636a

Please sign in to comment.