Skip to content

Commit 13c5ded

Browse files
committed
Get tests on Perlmutter passing
1 parent a886a61 commit 13c5ded

File tree

3 files changed

+26
-33
lines changed

3 files changed

+26
-33
lines changed

tests/scripts/database_corruption.bash

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# TODO: Run the unit tests on Perlmutter
2-
31
setup()
42
{
53
echo "##########################################################################################################"

tests/test_check.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,18 @@ def testCheckKeepTars(self):
184184
"{}zstash extract --hpss={}".format(zstash_path, self.hpss_path)
185185
)
186186
# Run `zstash check`
187-
output, err = run_cmd(
188-
"{}zstash check --hpss={}".format(zstash_path, self.hpss_path)
189-
)
190-
self.assertEqualOrStop(
191-
output + err,
192-
'For help, please see https://e3sm-project.github.io/zstash. Ask questions at https://github.com/E3SM-Project/zstash/discussions/categories/q-a.\nINFO: zstash/000000.tar exists. Checking expected size matches actual size.\nINFO: Opening tar archive {}/000000.tar\nINFO: Checking file1.txt\nINFO: Checking file2.txt\nINFO: No failures detected when checking the files. If you have a log file, run "grep -i Exception <log-file>" to double check.\n'.format(
193-
self.cache
194-
),
195-
)
187+
zstash_cmd: str = f"{zstash_path}zstash check --hpss={self.hpss_path}"
188+
output, err = run_cmd(zstash_cmd)
189+
expected_present = [
190+
"For help, please see https://e3sm-project.github.io/zstash. Ask questions at https://github.com/E3SM-Project/zstash/discussions/categories/q-a.",
191+
"INFO: zstash/000000.tar exists. Checking expected size matches actual size.",
192+
f"INFO: Opening tar archive {self.cache}/000000.tar",
193+
"INFO: Checking file1.txt",
194+
"INFO: Checking file2.txt",
195+
'INFO: No failures detected when checking the files. If you have a log file, run "grep -i Exception <log-file>" to double check.',
196+
]
197+
expected_absent = []
198+
self.check_strings(zstash_cmd, output + err, expected_present, expected_absent)
196199
# Check that tar and db files were not deleted
197200
files = os.listdir("{}/".format(self.cache))
198201
if not compare(files, ["000000.tar", "index.db"]):

tests/test_extract_parallel.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
2+
import re
23
import shutil
34
import unittest
5+
from typing import List
46

57
from tests.base import (
68
HPSS_ARCHIVE,
@@ -72,18 +74,7 @@ def helperExtractParallel(self, test_name, hpss_path, zstash_path=ZSTASH_PATH):
7274
expected_present.append("Transferring file from HPSS")
7375
expected_absent = ["ERROR", "Not extracting"]
7476
self.check_strings(cmd, output + err, expected_present, expected_absent)
75-
# Checking that the printing was done in order.
76-
tar_order = []
77-
console_output = output + err
78-
for word in console_output.replace("\n", " ").split(" "):
79-
if ".tar" in word:
80-
word = word.replace("{}/".format(self.cache), "")
81-
tar_order.append(word)
82-
if tar_order != sorted(tar_order):
83-
error_message = "The tars were printed in this order: {}\nWhen it should have been in this order: {}".format(
84-
tar_order, sorted(tar_order)
85-
)
86-
self.stop(error_message)
77+
self.compare_tar_orders(output + err)
8778

8879
# Run again, without verbose option.
8980
shutil.rmtree(self.test_dir)
@@ -99,17 +90,18 @@ def helperExtractParallel(self, test_name, hpss_path, zstash_path=ZSTASH_PATH):
9990
output, err = run_cmd(cmd)
10091
os.chdir(TOP_LEVEL)
10192
self.check_strings(cmd, output + err, expected_present, expected_absent)
102-
# Checking that the printing was done in order.
103-
tar_order = []
104-
console_output = output + err
93+
self.compare_tar_orders(output + err)
94+
95+
def compare_tar_orders(self, console_output: str):
96+
printed_tar_order: List[int] = []
10597
for word in console_output.replace("\n", " ").split(" "):
106-
if ".tar" in word:
107-
word = word.replace("{}/".format(self.cache), "")
108-
tar_order.append(word)
109-
if tar_order != sorted(tar_order):
110-
error_message = "The tars were printed in this order: {}\nWhen it should have been in this order: {}".format(
111-
tar_order, sorted(tar_order)
112-
)
98+
match_object = re.match(r"([0-9a-fA-F]+)\.tar", word)
99+
if match_object:
100+
hex_value: int = int(match_object.group(1), 16)
101+
printed_tar_order.append(hex_value)
102+
sorted_tar_order: List[int] = sorted(printed_tar_order)
103+
if printed_tar_order != sorted_tar_order:
104+
error_message = f"Actual tar order={printed_tar_order}. Expected tar order={sorted_tar_order}"
113105
self.stop(error_message)
114106

115107
def testExtractParallel(self):

0 commit comments

Comments
 (0)