|
| 1 | +#!/bin/sh |
| 2 | +test_description='Test job ingest pipeline' |
| 3 | + |
| 4 | +. $(dirname $0)/sharness.sh |
| 5 | + |
| 6 | +rm -f $(pwd)/config/ingest.toml |
| 7 | +mkdir -p $(pwd)/config |
| 8 | + |
| 9 | +test_under_flux 1 full -o,--config-path=$(pwd)/config |
| 10 | + |
| 11 | +flux setattr log-stderr-level 1 |
| 12 | + |
| 13 | +test_expect_success HAVE_JQ 'no workers are running at the start' ' |
| 14 | + flux module stats job-ingest >stats.out && |
| 15 | + jq -e ".pipeline.frobnicator.running == 0" <stats.out && |
| 16 | + jq -e ".pipeline.validator.running == 0" <stats.out |
| 17 | +' |
| 18 | +test_expect_success 'run a job with no ingest configuration' ' |
| 19 | + flux mini run /bin/true |
| 20 | +' |
| 21 | +test_expect_success HAVE_JQ 'one validator, no frobnicator started' ' |
| 22 | + flux module stats job-ingest >stats2.out && |
| 23 | + jq -e ".pipeline.frobnicator.running == 0" <stats2.out && |
| 24 | + jq -e ".pipeline.validator.running == 1" <stats2.out |
| 25 | +' |
| 26 | +test_expect_success 'configure frobnicator' ' |
| 27 | + cat >config/ingest.toml <<-EOT && |
| 28 | + [policy.jobspec.defaults.system] |
| 29 | + duration = "10s" |
| 30 | + [ingest.frobnicator] |
| 31 | + plugins = [ "defaults" ] |
| 32 | + EOT |
| 33 | + flux config reload |
| 34 | +' |
| 35 | +test_expect_success 'run a job with unspecified duration' ' |
| 36 | + flux mini submit /bin/true >jobid1 |
| 37 | +' |
| 38 | +test_expect_success HAVE_JQ 'one validator, one frobnicator started' ' |
| 39 | + flux module stats job-ingest >stats3.out && |
| 40 | + jq -e ".pipeline.frobnicator.running == 1" <stats3.out && |
| 41 | + jq -e ".pipeline.validator.running == 1" <stats3.out |
| 42 | +' |
| 43 | +test_expect_success HAVE_JQ 'job duration was assigned from default' ' |
| 44 | + flux job info $(cat jobid1) jobspec >jobspec1 && |
| 45 | + jq -e ".attributes.system.duration == 10" <jobspec1 |
| 46 | +' |
| 47 | +test_expect_success HAVE_JQ 'run flux config reload' ' |
| 48 | + flux module stats job-ingest >stats4.out && |
| 49 | + jq -r ".pipeline.frobnicator.pids[0]" <stats4.out >frob.pid && |
| 50 | + jq -r ".pipeline.validator.pids[0]" <stats4.out >val.pid && |
| 51 | + flux config reload |
| 52 | +' |
| 53 | +test_expect_success 'run a job to trigger work crew with new config' ' |
| 54 | + flux mini submit /bin/true |
| 55 | +' |
| 56 | +test_expect_success HAVE_JQ 'workers were restarted' ' |
| 57 | + flux module stats job-ingest >stats5.out && |
| 58 | + jq -r ".pipeline.frobnicator.pids[0]" <stats5.out >frob2.pid && |
| 59 | + jq -r ".pipeline.validator.pids[0]" <stats5.out >val2.pid && |
| 60 | + test_must_fail test_cmp frob.pid frob2.pid && |
| 61 | + test_must_fail test_cmp val.pid val2.pid |
| 62 | +' |
| 63 | +test_expect_success HAVE_JQ 'run a job with novalidate flag' ' |
| 64 | + jq -r ".pipeline.frobnicator.requests" <stats5.out >frob.count && |
| 65 | + jq -r ".pipeline.validator.requests" <stats5.out >val.count && |
| 66 | + flux mini run --flags novalidate /bin/true |
| 67 | +' |
| 68 | +test_expect_success HAVE_JQ 'job was frobbed but not validated' ' |
| 69 | + flux module stats job-ingest >stats6.out && |
| 70 | + jq -r ".pipeline.frobnicator.requests" <stats6.out >frob2.count && |
| 71 | + jq -r ".pipeline.validator.requests" <stats6.out >val2.count && |
| 72 | + test_must_fail test_cmp frob.count frob2.count && |
| 73 | + test_cmp val.count val2.count |
| 74 | +' |
| 75 | +test_expect_success 'reconfig with null config' ' |
| 76 | + cat >config/ingest.toml <<-EOT && |
| 77 | + EOT |
| 78 | + flux config reload |
| 79 | +' |
| 80 | +test_expect_success HAVE_JQ 'run a job with novalidate flag' ' |
| 81 | + flux mini run --flags novalidate /bin/true |
| 82 | +' |
| 83 | +test_expect_success HAVE_JQ 'job was neither frobbed nor validated' ' |
| 84 | + flux module stats job-ingest >stats7.out && |
| 85 | + jq -r ".pipeline.frobnicator.requests" <stats7.out >frob3.count && |
| 86 | + jq -r ".pipeline.validator.requests" <stats7.out >val3.count && |
| 87 | + test_cmp frob2.count frob3.count && |
| 88 | + test_cmp val2.count val3.count |
| 89 | +' |
| 90 | +test_expect_success HAVE_JQ 'run a job' ' |
| 91 | + flux mini run /bin/true |
| 92 | +' |
| 93 | +test_expect_success HAVE_JQ 'job was validated but not frobbed' ' |
| 94 | + flux module stats job-ingest >stats8.out && |
| 95 | + jq -r ".pipeline.frobnicator.requests" <stats8.out >frob4.count && |
| 96 | + jq -r ".pipeline.validator.requests" <stats8.out >val4.count && |
| 97 | + test_cmp frob3.count frob4.count && |
| 98 | + test_must_fail test_cmp val3.count val4.count |
| 99 | +' |
| 100 | +test_done |
0 commit comments