Skip to content

Commit 7af3fa8

Browse files
committed
Add test for dakota parent/child portal relationship
1 parent 1037dbe commit 7af3fa8

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

tests/dakota/test_dakota.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import shutil
44
import glob
55
import sys
6+
import json
67
import pytest
78
from ipsframework import ips_dakota_dynamic
89

@@ -48,6 +49,44 @@ def test_dakota(tmpdir):
4849

4950
assert float(X) == pytest.approx(0.5, rel=1e-4)
5051

52+
# Check PARENT CHILD relationship
53+
# Get parent PORTAL_RUNID
54+
json_files = glob.glob(str(tmpdir.join("DAKOTA_Gaussian_TEST_1").join("simulation_log").join("*.json")))
55+
assert len(json_files) == 1
56+
57+
with open(json_files[0], 'r') as json_file:
58+
lines = json_file.readlines()
59+
60+
lines = [json.loads(line.strip()) for line in lines]
61+
assert len(lines) == 9
62+
63+
# get portal_runid event
64+
portal_runid = lines[0]['portal_runid']
65+
sim_name, host, user, _ = portal_runid.rsplit('_', maxsplit=3)
66+
assert sim_name == "DAKOTA_Gaussian_TEST_1"
67+
assert host == "workstation"
68+
assert user == "user"
69+
70+
# Check child run
71+
json_files = glob.glob(str(tmpdir.join("DAKOTA_Gaussian_TEST_1").join("simulation_*_0000").join("simulation_log").join("*.json")))
72+
assert len(json_files) == 1
73+
with open(json_files[0], 'r') as json_file:
74+
lines = json_file.readlines()
75+
76+
lines = [json.loads(line.strip()) for line in lines]
77+
assert len(lines) == 8
78+
child_portal_runid = lines[0]['portal_runid']
79+
assert child_portal_runid != portal_runid
80+
81+
sim_name, host, user, _ = child_portal_runid.rsplit('_', maxsplit=3)
82+
assert sim_name.startswith("DAKOTA_Gaussian_TEST_1")
83+
assert len(sim_name) > len("DAKOTA_Gaussian_TEST_1")
84+
assert host == "workstation"
85+
assert user == "user"
86+
87+
parent_portal_runid = lines[0]['parent_portal_runid']
88+
assert parent_portal_runid == portal_runid
89+
5190

5291
@mock.patch('ipsframework.ips_dakota_dynamic.DakotaDynamic')
5392
def test_dakota_main(MockDakotaDynamic):

tests/dakota/workstation.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
HOST = my_laptop
1+
HOST = workstation
2+
USER = user
23
MPIRUN = eval
34

45
#######################################

0 commit comments

Comments
 (0)