Skip to content

Use rk in CI

rk run-flow and rk run-suite are built for pipelines. Each run ends with an exit code for the job's result, and can write a JSON or JUnit report for the details.

A CI step

Shell
  • The exit code decides the job: 0 passes; 1 (a failed check) and 3 (unsupported) are test results; 2, 4 and 5 mean the run itself didn't happen.
  • -output json|junit selects the report format; text is the default. Machine reports need the licence feature report.machine, which the community allowance includes.
  • -output-file <path> writes the report to a file:

    • the file is truncated when the run starts, so an old report is never left behind;
    • a human summary still goes to stdout.

    Without -output-file, a JSON or JUnit report is the only thing on stdout. Progress and logs always go to stderr.

  • In text mode, -output-file is ignored, and rk prints a note to stderr.
  • An unwritable -output-file is a usage error (exit 2).

JUnit layout

A flow run is one <testsuite> with these test cases:

  • flow: <name>: an error if the run errored, a failure if any check failed;
  • verdict: <name>: a failure for verdict fail, skipped for unsupported;
  • check: <name> for each post-check, and final: <name> for each final check;
  • step N: <field> <op> for each check inside the flow.

A suite run is one <testsuite> per cycle, named (cycle i/n) when there are several. It has one case per step (<step> (<flow>)), then the suite's final checks, plus a suite aborted case if the suite stopped early.

JSON

  • A flow run is one object; the fields to act on are verdict (pass, fail or unsupported) and verdict_reasons.
  • A suite run is one object per cycle, or an array when there are several cycles; the field to act on is outcome.

See Reports for the fields.

Read verdict, not all_passed. all_passed only means that no check failed: a run can have no failed checks and still not pass.

Check the setup before the run

  • rk check -c lab.yaml probes the wire before a run:

    • an SCTP connect from every gNB to every AMF;
    • a Diameter CER/CEA with every peer.

    It exits 1 if a probe fails, and doesn't probe SBI, REST, PFCP or GTP-U.

  • rk lint -flow <file> and rk lint -suite <file> -templates <dir> check flows and suites without running them. They exit 0 when valid, 1 when not.
  • rk validate -flow <name> -templates <dir> -c <env> checks that a flow, its bindings to the environment, and your licence fit together.