(hq_env: HqEnv)
| 52 | |
| 53 | |
| 54 | def test_coupling_alloc1(hq_env: HqEnv): |
| 55 | hq_env.start_server() |
| 56 | |
| 57 | hq_env.command( |
| 58 | [ |
| 59 | "submit", |
| 60 | "--array=1-50", |
| 61 | "--cpus=1", |
| 62 | "--resource=foo=3 compact!", |
| 63 | "--", |
| 64 | *bash('echo "$HQ_RESOURCE_VALUES_cpus;$HQ_RESOURCE_VALUES_foo"'), |
| 65 | ] |
| 66 | ) |
| 67 | |
| 68 | hq_env.command( |
| 69 | [ |
| 70 | "submit", |
| 71 | "--array=1-50", |
| 72 | "--cpus=1", |
| 73 | "--resource=foo=1 compact!", |
| 74 | "--", |
| 75 | *bash('echo "$HQ_RESOURCE_VALUES_cpus;$HQ_RESOURCE_VALUES_foo"'), |
| 76 | ] |
| 77 | ) |
| 78 | |
| 79 | hq_env.start_worker( |
| 80 | cpus="[[1, 2, 3], [4, 5, 6]]", |
| 81 | args=[ |
| 82 | "--coupling=cpus[0]:foo[0],cpus[1]:foo[1]", |
| 83 | "--resource=ddd=sum(123)", |
| 84 | "--resource=foo=[[10,20,30,40],[50,60,70,80]]", |
| 85 | ], |
| 86 | ) |
| 87 | |
| 88 | wait_for_job_state(hq_env, [1, 2], "FINISHED") |
| 89 | |
| 90 | def get_groups(data): |
| 91 | cpus, foos = (x.split(",") for x in data.rstrip().split(";")) |
| 92 | g = set() |
| 93 | for c in cpus: |
| 94 | g.add(int(c) // 4) |
| 95 | for f in foos: |
| 96 | g.add(int(f) // 50) |
| 97 | return g |
| 98 | |
| 99 | for i in range(1, 51): |
| 100 | with open(default_task_output(job_id=1, task_id=i), "r") as f: |
| 101 | assert len(get_groups(f.read())) == 1 |
| 102 | for i in range(1, 51): |
| 103 | with open(default_task_output(job_id=2, task_id=i), "r") as f: |
| 104 | assert len(get_groups(f.read())) == 1 |
| 105 | |
| 106 | |
| 107 | def test_coupling_alloc2(hq_env: HqEnv): |
nothing calls this directly
no test coverage detected