|
| 1 | +#!/bin/sh |
| 2 | +#set -x |
| 3 | + |
| 4 | +# Adapted from t4001-match-allocate.t |
| 5 | + |
| 6 | +test_description='Test the basic functionality of resource-match-without-allocating' |
| 7 | + |
| 8 | +. `dirname $0`/sharness.sh |
| 9 | + |
| 10 | +grug="${SHARNESS_TEST_SRCDIR}/data/resource/grugs/tiny.graphml" |
| 11 | +jobspec="${SHARNESS_TEST_SRCDIR}/data/resource/jobspecs/basics/test001.yaml" |
| 12 | +malform="${SHARNESS_TEST_SRCDIR}/data/resource/jobspecs/basics/bad.yaml" |
| 13 | +duration_too_large="${SHARNESS_TEST_SRCDIR}/data/resource/jobspecs/duration/test001.yaml" |
| 14 | +duration_negative="${SHARNESS_TEST_SRCDIR}/data/resource/jobspecs/duration/test002.yaml" |
| 15 | +query="../../resource/utilities/resource-query" |
| 16 | + |
| 17 | +test_under_flux 1 |
| 18 | + |
| 19 | +test_debug ' |
| 20 | + echo ${grug} && |
| 21 | + echo ${jobspec} && |
| 22 | + echo ${malform} |
| 23 | +' |
| 24 | + |
| 25 | +test_expect_success 'loading resource module with a tiny machine config works' ' |
| 26 | + load_resource \ |
| 27 | +load-file=${grug} prune-filters=ALL:core \ |
| 28 | +load-format=grug subsystems=containment policy=high |
| 29 | +' |
| 30 | + |
| 31 | +# Ignore starttime and expiration because they can change during the test |
| 32 | +# Match-without-allocating must choose resources deterministically |
| 33 | +test_expect_success 'match-without-allocating works with a 1-node, 1-socket jobspec' ' |
| 34 | + flux ion-resource match without_allocating ${jobspec} | grep -o "{.*starttime" > match1.out && |
| 35 | + flux ion-resource match without_allocating ${jobspec} | grep -o "{.*starttime" > match2.out && |
| 36 | + flux ion-resource match without_allocating ${jobspec} | grep -o "{.*starttime" > match3.out && |
| 37 | + flux ion-resource match without_allocating ${jobspec} | grep -o "{.*starttime" > match4.out && |
| 38 | + flux ion-resource match without_allocating ${jobspec} | grep -o "{.*starttime" > match5.out && |
| 39 | + diff match1.out match2.out && |
| 40 | + diff match2.out match3.out && |
| 41 | + diff match3.out match4.out && |
| 42 | + diff match4.out match5.out |
| 43 | +' |
| 44 | + |
| 45 | +test_expect_success 'JOBID of match_without_allocating request get tracked as MATCHED' ' |
| 46 | + flux ion-resource info 0 | grep MATCHED |
| 47 | +' |
| 48 | + |
| 49 | +test_expect_success 'match-allocate works (all resources)' ' |
| 50 | + flux ion-resource match allocate ${jobspec} && |
| 51 | + flux ion-resource match allocate ${jobspec} && |
| 52 | + flux ion-resource match allocate ${jobspec} && |
| 53 | + flux ion-resource match allocate ${jobspec} |
| 54 | +' |
| 55 | + |
| 56 | +test_expect_success 'match-allocate fails when all resources are allocated' ' |
| 57 | + test_expect_code 16 flux ion-resource match allocate ${jobspec} |
| 58 | +' |
| 59 | + |
| 60 | +# match-without-allocating will search ahead in time |
| 61 | +test_expect_success 'match-without-allocating succeeds when all resources are allocated' ' |
| 62 | + flux ion-resource match without_allocating ${jobspec} |
| 63 | +' |
| 64 | + |
| 65 | +test_expect_success 'detecting of a non-existent jobspec file works' ' |
| 66 | + test_expect_code 3 flux ion-resource match without_allocating foo |
| 67 | +' |
| 68 | + |
| 69 | +test_expect_success 'handling of a malformed jobspec works' ' |
| 70 | + test_expect_code 2 flux ion-resource match without_allocating ${malform} |
| 71 | +' |
| 72 | + |
| 73 | +test_expect_success 'handling of an invalid resource type works' ' |
| 74 | + test_expect_code 1 flux ion-resource match without_allocating \ |
| 75 | + "${SHARNESS_TEST_SRCDIR}/data/resource/jobspecs/basics/bad_res_type.yaml" |
| 76 | +' |
| 77 | + |
| 78 | +test_expect_success 'invalid duration is caught' ' |
| 79 | + test_must_fail flux ion-resource match without_allocating ${duration_too_large} && |
| 80 | + test_must_fail flux ion-resource match without_allocating ${duration_negative} |
| 81 | +' |
| 82 | + |
| 83 | +test_expect_success 'removing resource works' ' |
| 84 | + remove_resource |
| 85 | +' |
| 86 | + |
| 87 | +test_expect_success 'loading resource module with policy=low works' ' |
| 88 | + load_resource \ |
| 89 | +load-file=${grug} prune-filters=ALL:core \ |
| 90 | +load-format=grug subsystems=containment policy=low |
| 91 | +' |
| 92 | + |
| 93 | +test_expect_success 'match-without-allocating matches different resources with policy=low' ' |
| 94 | + flux ion-resource match without_allocating ${jobspec} | grep -o "{.*starttime" > matchlow.out && |
| 95 | + test_expect_code 1 diff match1.out matchlow.out |
| 96 | +' |
| 97 | + |
| 98 | +test_expect_success 'removing resource works' ' |
| 99 | + remove_resource |
| 100 | +' |
| 101 | + |
| 102 | +test_expect_success 'resource-query can perform match-without-allocating' ' |
| 103 | + ${query} -L ${grug} -S CA -t rq.out <<-'EOF' && |
| 104 | + match without_allocating ${jobspec} |
| 105 | + match allocate ${jobspec} |
| 106 | + match allocate ${jobspec} |
| 107 | + match allocate ${jobspec} |
| 108 | + match allocate ${jobspec} |
| 109 | + match without_allocating ${jobspec} |
| 110 | + quit |
| 111 | + EOF |
| 112 | + (( $(grep MATCHED <rq.out | wc -l) == 2 )) && |
| 113 | + (( $(grep ALLOCATED <rq.out | wc -l) == 4 )) && |
| 114 | + grep "SCHEDULED AT" rq.out | sed -ne "6p" | grep 3600 |
| 115 | +' |
| 116 | + |
| 117 | +test_done |
0 commit comments