Performance Checks
Defining Metrics
buildtest provides a method to define test metrics in the buildspecs which can be used to
store arbitrary content from the output/error file or an arbitrary file into named metric. The
metrics
property is used to define a list of metric names using regular expression to assign a value
to the metric. In this example, we have two tests that define metrics hpcg_rate_stream
, hpcg_state_stream
in the first test and hpcg_rate_file
, hpcg_state_file
in the second test. The stream
property is used
to read from stdout/stderr and apply the regular expression defined by exp
, whereas file_regex
is used
to define metrics from an arbitrary file where file
is the path to file.
buildspecs:
metric_regex_example:
executor: generic.local.bash
type: script
description: capture result metric from output
run: echo "HPCG result is VALID with a GFLOP/s rating of=63.6515"
tags: tutorials
metrics:
hpcg_rating_stream:
type: float
regex:
exp: '(\d+\.\d+)$'
stream: stdout
hpcg_state_stream:
type: str
regex:
exp: '(VALID)'
stream: stdout
metric_file_regex:
executor: generic.local.bash
type: script
description: capture result metric from file path
run: echo "HPCG result is VALID with a GFLOP/s rating of=63.6515" > hpcg.txt
tags: tutorials
metrics:
hpcg_rating_file:
type: float
file_regex:
exp: '(\d+\.\d+)$'
file: hpcg.txt
hpcg_state_file:
type: str
file_regex:
exp: '(VALID)'
file: hpcg.txt
The metrics can be used with Comparison Operators for performing more sophisticated status checks.
By default, a metric will be an empty dictionary if there is no metrics
property. If we fail to match
a regular expression, the metric will be defined as an empty string (''
).
Note
If your regular expression contains an escape character \
you must surround your
string in single quotes '
as pose to double quotes "
Let’s build this test.
buildtest build -b tutorials/metrics/metrics_regex.yml
$ buildtest build -b tutorials/metrics/metrics_regex.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│ │
│ User: docs │
│ Hostname: build-22529915-project-280831-buildtest │
│ Platform: Linux │
│ Current Time: 2023/11/13 01:35:56 │
│ buildtest path: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version: 1.7 │
│ python path: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version: 3.8.18 │
│ Configuration File: /tmp/tmptsqn67rj/config.yml │
│ Test Directory: /tmp/tmptsqn67rj/var/tests │
│ Report File: /tmp/tmptsqn67rj/var/report.json │
│ Command: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
─────────────────────────── Discovering Buildspecs ────────────────────────────
Discovered buildspecs
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/v1.7/tu ║
║ torials/metrics/metrics_regex.yml ║
╚══════════════════════════════════════════════════════════════════════════════╝
Total Discovered Buildspecs: 1
Total Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/v1.7/tutorials/metrics/metrics_regex.yml: VALID
Total builder objects created: 2
Builders by type=script
┏━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━┓
┃ ┃ ┃ ┃ ┃ ┃ ┃ descript ┃ buildsp ┃
┃ builder ┃ type ┃ executor ┃ compiler ┃ nodes ┃ procs ┃ ion ┃ ecs ┃
┡━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━┩
│ metric_r │ script │ generic. │ None │ None │ None │ capture │ /home/d │
│ egex_exa │ │ local.ba │ │ │ │ result │ ocs/che │
│ mple/d92 │ │ sh │ │ │ │ metric │ ckouts/ │
│ eb253 │ │ │ │ │ │ from │ readthe │
│ │ │ │ │ │ │ output │ docs.or │
│ │ │ │ │ │ │ │ g/user_ │
│ │ │ │ │ │ │ │ builds/ │
│ │ │ │ │ │ │ │ buildte │
│ │ │ │ │ │ │ │ st/chec │
│ │ │ │ │ │ │ │ kouts/v │
│ │ │ │ │ │ │ │ 1.7/tut │
│ │ │ │ │ │ │ │ orials/ │
│ │ │ │ │ │ │ │ metrics │
│ │ │ │ │ │ │ │ /metric │
│ │ │ │ │ │ │ │ s_regex │
│ │ │ │ │ │ │ │ .yml │
├──────────┼────────┼──────────┼──────────┼───────┼───────┼──────────┼─────────┤
│ metric_f │ script │ generic. │ None │ None │ None │ capture │ /home/d │
│ ile_rege │ │ local.ba │ │ │ │ result │ ocs/che │
│ x/4f49a0 │ │ sh │ │ │ │ metric │ ckouts/ │
│ a7 │ │ │ │ │ │ from │ readthe │
│ │ │ │ │ │ │ file │ docs.or │
│ │ │ │ │ │ │ path │ g/user_ │
│ │ │ │ │ │ │ │ builds/ │
│ │ │ │ │ │ │ │ buildte │
│ │ │ │ │ │ │ │ st/chec │
│ │ │ │ │ │ │ │ kouts/v │
│ │ │ │ │ │ │ │ 1.7/tut │
│ │ │ │ │ │ │ │ orials/ │
│ │ │ │ │ │ │ │ metrics │
│ │ │ │ │ │ │ │ /metric │
│ │ │ │ │ │ │ │ s_regex │
│ │ │ │ │ │ │ │ .yml │
└──────────┴────────┴──────────┴──────────┴───────┴───────┴──────────┴─────────┘
──────────────────────────────── Building Test ─────────────────────────────────
metric_regex_example/d92eb253: Creating test directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_regex_example/d92eb253
metric_regex_example/d92eb253: Creating the stage directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_regex_example/d92eb253/stage
metric_regex_example/d92eb253: Writing build script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_regex_example/d92eb253/metric_regex_example_build.sh
metric_file_regex/4f49a0a7: Creating test directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_file_regex/4f49a0a7
metric_file_regex/4f49a0a7: Creating the stage directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_file_regex/4f49a0a7/stage
metric_file_regex/4f49a0a7: Writing build script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_file_regex/4f49a0a7/metric_file_regex_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
metric_regex_example/d92eb253 does not have any dependencies adding test to queue
metric_file_regex/4f49a0a7 does not have any dependencies adding test to queue
Builders Eligible to Run
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Builder ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ metric_regex_example/d92eb253 │
│ metric_file_regex/4f49a0a7 │
└───────────────────────────────┘
metric_regex_example/d92eb253: Current Working Directory : /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_regex_example/d92eb253/stage
metric_regex_example/d92eb253: Running Test via command: bash --norc --noprofile -eo pipefail metric_regex_example_build.sh
metric_regex_example/d92eb253: Test completed in 0.006255 seconds
metric_regex_example/d92eb253: Test completed with returncode: 0
metric_regex_example/d92eb253: Writing output file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_regex_example/d92eb253/metric_regex_example.out
metric_regex_example/d92eb253: Writing error file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_regex_example/d92eb253/metric_regex_example.err
metric_file_regex/4f49a0a7: Current Working Directory : /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_file_regex/4f49a0a7/stage
metric_file_regex/4f49a0a7: Running Test via command: bash --norc --noprofile -eo pipefail metric_file_regex_build.sh
metric_file_regex/4f49a0a7: Test completed in 0.005875 seconds
metric_file_regex/4f49a0a7: Test completed with returncode: 0
metric_file_regex/4f49a0a7: Writing output file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_file_regex/4f49a0a7/metric_file_regex.out
metric_file_regex/4f49a0a7: Writing error file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_file_regex/4f49a0a7/metric_file_regex.err
Test Summary
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ ┃ ┃ ┃ checks ┃ ┃ ┃
┃ ┃ ┃ ┃ (ReturnCode, ┃ ┃ ┃
┃ ┃ ┃ ┃ Regex, ┃ ┃ ┃
┃ builder ┃ executor ┃ status ┃ Runtime) ┃ returncode ┃ runtime ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ metric_file_ │ generic.loca │ PASS │ None None │ 0 │ 0.005875 │
│ regex/4f49a0 │ l.bash │ │ None │ │ │
│ a7 │ │ │ │ │ │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ metric_regex │ generic.loca │ PASS │ None None │ 0 │ 0.006255 │
│ _example/d92 │ l.bash │ │ None │ │ │
│ eb253 │ │ │ │ │ │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘
Passed Tests: 2/2 Percentage: 100.000%
Failed Tests: 0/2 Percentage: 0.000%
Adding 2 test results to /tmp/tmptsqn67rj/var/report.json
Writing Logfile to: /tmp/tmptsqn67rj/var/logs/buildtest_1b7z3c2i.log
The metrics are captured in the test report which can
be queried via buildtest report
or buildtest inspect query
. Metrics can be seen in the test metadata,
for instance you can run buildtest inspect query
and you will see metrics shown in table output.
buildtest inspect query metric_regex_example metric_file_regex
$ buildtest inspect query metric_regex_example metric_file_regex
────────── metric_regex_example/d92eb253-7c3b-43a8-89c8-fa1746ef1cef ───────────
Executor: generic.local.bash
Description: capture result metric from output
State: PASS
Returncode: 0
Runtime: 0.006255 sec
Starttime: 2023/11/13 01:35:56
Endtime: 2023/11/13 01:35:56
Command: bash --norc --noprofile -eo pipefail metric_regex_example_build.sh
Test Script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_regex_example/d92eb253/metric_regex_example.sh
Build Script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_regex_example/d92eb253/metric_regex_example_build.sh
Output File: /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_regex_example/d92eb253/metric_regex_example.out
Error File: /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_regex_example/d92eb253/metric_regex_example.err
Log File: /tmp/tmptsqn67rj/var/logs/buildtest_1b7z3c2i.log
Metrics
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┓
┃ Name ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━┩
│ hpcg_rating_stream │ 63.6515 │
│ hpcg_state_stream │ VALID │
└────────────────────┴─────────┘
──────────── metric_file_regex/4f49a0a7-c634-434b-8ca5-6d273aed3568 ────────────
Executor: generic.local.bash
Description: capture result metric from file path
State: PASS
Returncode: 0
Runtime: 0.005875 sec
Starttime: 2023/11/13 01:35:56
Endtime: 2023/11/13 01:35:56
Command: bash --norc --noprofile -eo pipefail metric_file_regex_build.sh
Test Script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_file_regex/4f49a0a7/metric_file_regex.sh
Build Script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_file_regex/4f49a0a7/metric_file_regex_build.sh
Output File: /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_file_regex/4f49a0a7/metric_file_regex.out
Error File: /tmp/tmptsqn67rj/var/tests/generic.local.bash/metrics_regex/metric_file_regex/4f49a0a7/metric_file_regex.err
Log File: /tmp/tmptsqn67rj/var/logs/buildtest_1b7z3c2i.log
Metrics
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┓
┃ Name ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━━━┩
│ hpcg_rating_file │ 63.6515 │
│ hpcg_state_file │ VALID │
└──────────────────┴─────────┘
We can query the metrics via buildtest report
which will display all metrics as a comma seperated
Key/Value pair. We can use buildtest report --format metrics
to extract all metrics for a test.
Internally, we store the metrics as a dictionary but when we print them out via buildtest report
we
join them together into a single string. Shown below is the metrics for the previous build.
buildtest report --filter buildspec=tutorials/metrics/metrics_regex.yml --format name,metrics
$ buildtest report --filter buildspec=tutorials/metrics/metrics_regex.yml --format name,metrics
Report File: /tmp/tmptsqn67rj/var/report.json
┏━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ name ┃ metrics ┃
┡━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ metric_file_regex │ hpcg_rating_file=63.6515,hpcg_state_file=VALID │
├───────────────────────┼──────────────────────────────────────────────────────┤
│ metric_regex_example │ hpcg_rating_stream=63.6515,hpcg_state_stream=VALID │
└───────────────────────┴──────────────────────────────────────────────────────┘
Invalid Metrics
We will discuss a few edge-cases when defining metrics that can lead to validation error. The file_regex and
regex property can’t be declared at the same time when defining a metric. In example below
we have defined a metric named hello
that uses both regex
and file_regex
.
buildspecs:
metrics_with_regex_and_file_regex_not_allowed:
type: script
executor: generic.local.bash
description: This is an invalid metric because 'file_regex' and 'regex' are both specified
run: echo "hello" > file.txt
metrics:
hello:
type: str
file_regex:
file: file.txt
exp: "BAR"
regex:
stream: stdout
exp: "BAR"
If we try to validate this buildspec, we will get an error message that regex
and file_regex
can’t be specified
at the same time.
buildtest buildspec validate -b tutorials/metrics/invalid_metrics.yml
$ buildtest buildspec validate -b tutorials/metrics/invalid_metrics.yml
─ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/v1.7/t… ─
{'type': 'str', 'file_regex': {'file': 'file.txt', 'exp': 'BAR'}, 'regex': {'stream': 'stdout', 'exp': 'BAR'}} is valid under each of {'required': ['file_regex']}, {'required': ['regex']}
Failed validating 'oneOf' in schema['properties']['metrics']['additionalProperties']:
{'additionalProperties': False,
'oneOf': [{'required': ['regex']}, {'required': ['file_regex']}],
'properties': {'file_regex': {'$ref': '#/definitions/file_regex_in_metrics'},
'regex': {'$ref': '#/definitions/regex'},
'type': {'description': 'Specify python data-type '
'(str, int, float) to convert '
'metric. ',
'enum': ['str', 'int', 'float'],
'type': 'string'}},
'required': ['type'],
'type': 'object'}
On instance['metrics']['hello']:
{'file_regex': {'exp': 'BAR', 'file': 'file.txt'},
'regex': {'exp': 'BAR', 'stream': 'stdout'},
'type': 'str'}
1 buildspecs failed to validate
When defining a metrics, you must specify regex
or file_regex
property in order to capture metric. If its not
specified, you will run into validation error. In this example, we define a metrics named foo
, but we don’t
specify the regex
or file_regex
property therefore, this metric is invalid.
buildspecs:
required_property_in_metrics:
type: script
executor: generic.local.bash
description: metrics must have a file_regex or regex property to define how to capture metric
run: echo "hello"
metrics:
foo:
type: str
The metrics must follow a pattern, this is typically alphanumeric characters including dot (.
), hypen (-
)
and underscore (_
). In this example below, we have an invalid metric that doesn’t conform to pattern.
buildspecs:
invalid_metrics_name:
type: script
executor: generic.local.bash
description: "Metrics name does not follow pattern"
run: echo "hello" > file.txt
metrics:
(foo-bar:
type: str
regex:
stream: stdout
exp: "BAR"
Let’s try validating the buildspec to see the error message.
buildtest buildspec validate -b tutorials/metrics/invalid_metric_name.yml
$ buildtest buildspec validate -b tutorials/metrics/invalid_metric_name.yml
─ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/v1.7/t… ─
'(foo-bar' does not match '^[A-Za-z0-9_.-]+$'
Failed validating 'pattern' in schema['properties']['metrics']['propertyNames']:
{'pattern': '^[A-Za-z0-9_.-]+$'}
On instance['metrics']:
'(foo-bar'
1 buildspecs failed to validate
Comparison Operators
buildtest supports several comparison operators as part of status check such as >, >=, <=, <, ==, !=. Each metric is compared with a reference value that can be useful when running performance checks. In this section we will cover the following comparison:
Greater Equal
buildtest can determine status check based on performance check. In this next example, we will run the
STREAM memory benchmark and capture metrics named copy
, scale
add
and triad
from the output and perform an Assertion Greater Equal (assert_ge
) with a reference value.
The assert_ge
contains a list of assertions in the comparisons
property where each metric name is
referenced via name
that is compared with the reference value defined by ref
property. The comparison
is metric_value >= ref
, where metric_value is the value assigned to the metric name captured by the regular
expression. The type
field in the metric section is used for the type conversion which can be float, int, or string.
The item
is a numeric field used in match.group to retrieve the output
from the regular expression search. The item must be non-negative number.
1buildspecs:
2 stream_test:
3 type: script
4 executor: generic.local.bash
5 description: Run stream test with metrics example using assert greater equal
6 env:
7 OMP_NUM_THREADS: 4
8 run: |
9 wget https://raw.githubusercontent.com/jeffhammond/STREAM/master/stream.c
10 gcc -openmp -o stream stream.c
11 ./stream
12 metrics:
13 copy:
14 type: float
15 regex:
16 exp: 'Copy:\s+(\S+)\s+.*'
17 stream: stdout
18 item: 1
19 scale:
20 type: float
21 regex:
22 exp: 'Scale:\s+(\S+)\s+.*'
23 stream: stdout
24 item: 1
25 add:
26 type: float
27 regex:
28 exp: 'Add:\s+(\S+)\s+.*'
29 stream: stdout
30 item: 1
31 triad:
32 type: float
33 regex:
34 exp: 'Triad:\s+(\S+)\s+.*'
35 stream: stdout
36 item: 1
37 status:
38 assert_ge:
39 mode: and
40 comparisons:
41 - name: copy
42 ref: 5000
43 - name: scale
44 ref: 5500
45 - name: add
46 ref: 6000
47 - name: triad
48 ref: 6500
buildtest will evaluate each assertion in the list and use a logical AND to determine the final
status of assert_ge
. The keyword mode
is used to determine whether to perform a logical
OR / AND operation when evaluating the final expression. The mode
can be any of the
values: [AND
, OR
, and
, or
]. If mode
is ommitted the default is logical AND.
Let’s build this test, take a close look at the output of buildtest build
and take note of the assertion
statement.
buildtest build -b tutorials/perf_checks/assert_ge.yml
$ buildtest build -b tutorials/perf_checks/assert_ge.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│ │
│ User: docs │
│ Hostname: build-22529915-project-280831-buildtest │
│ Platform: Linux │
│ Current Time: 2023/11/13 01:35:59 │
│ buildtest path: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version: 1.7 │
│ python path: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version: 3.8.18 │
│ Configuration File: /tmp/tmptsqn67rj/config.yml │
│ Test Directory: /tmp/tmptsqn67rj/var/tests │
│ Report File: /tmp/tmptsqn67rj/var/report.json │
│ Command: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
─────────────────────────── Discovering Buildspecs ────────────────────────────
Discovered buildspecs
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/v1.7/tu ║
║ torials/perf_checks/assert_ge.yml ║
╚══════════════════════════════════════════════════════════════════════════════╝
Total Discovered Buildspecs: 1
Total Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/v1.7/tutorials/perf_checks/assert_ge.yml: VALID
Total builder objects created: 1
Builders by type=script
┏━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━┓
┃ ┃ ┃ ┃ ┃ ┃ ┃ descript ┃ buildsp ┃
┃ builder ┃ type ┃ executor ┃ compiler ┃ nodes ┃ procs ┃ ion ┃ ecs ┃
┡━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━┩
│ stream_t │ script │ generic. │ None │ None │ None │ Run │ /home/d │
│ est/61bc │ │ local.ba │ │ │ │ stream │ ocs/che │
│ 1eff │ │ sh │ │ │ │ test │ ckouts/ │
│ │ │ │ │ │ │ with │ readthe │
│ │ │ │ │ │ │ metrics │ docs.or │
│ │ │ │ │ │ │ example │ g/user_ │
│ │ │ │ │ │ │ using │ builds/ │
│ │ │ │ │ │ │ assert │ buildte │
│ │ │ │ │ │ │ greater │ st/chec │
│ │ │ │ │ │ │ equal │ kouts/v │
│ │ │ │ │ │ │ │ 1.7/tut │
│ │ │ │ │ │ │ │ orials/ │
│ │ │ │ │ │ │ │ perf_ch │
│ │ │ │ │ │ │ │ ecks/as │
│ │ │ │ │ │ │ │ sert_ge │
│ │ │ │ │ │ │ │ .yml │
└──────────┴────────┴──────────┴──────────┴───────┴───────┴──────────┴─────────┘
──────────────────────────────── Building Test ─────────────────────────────────
stream_test/61bc1eff: Creating test directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ge/stream_test/61bc1eff
stream_test/61bc1eff: Creating the stage directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ge/stream_test/61bc1eff/stage
stream_test/61bc1eff: Writing build script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ge/stream_test/61bc1eff/stream_test_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
stream_test/61bc1eff does not have any dependencies adding test to queue
Builders Eligible to Run
┏━━━━━━━━━━━━━━━━━━━━━━┓
┃ Builder ┃
┡━━━━━━━━━━━━━━━━━━━━━━┩
│ stream_test/61bc1eff │
└──────────────────────┘
stream_test/61bc1eff: Current Working Directory : /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ge/stream_test/61bc1eff/stage
stream_test/61bc1eff: Running Test via command: bash --norc --noprofile -eo pipefail stream_test_build.sh
stream_test/61bc1eff: Test completed in 2.075482 seconds
stream_test/61bc1eff: Test completed with returncode: 0
stream_test/61bc1eff: Writing output file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ge/stream_test/61bc1eff/stream_test.out
stream_test/61bc1eff: Writing error file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ge/stream_test/61bc1eff/stream_test.err
stream_test/61bc1eff: testing metric: copy if 5872.6 >= 5000.0 - Check: True
stream_test/61bc1eff: testing metric: scale if 6676.4 >= 5500.0 - Check: True
stream_test/61bc1eff: testing metric: add if 8719.1 >= 6000.0 - Check: True
stream_test/61bc1eff: testing metric: triad if 8464.2 >= 6500.0 - Check: True
stream_test/61bc1eff: Greater Equal Check: True
Test Summary
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ ┃ ┃ ┃ checks ┃ ┃ ┃
┃ ┃ ┃ ┃ (ReturnCode, ┃ ┃ ┃
┃ ┃ ┃ ┃ Regex, ┃ ┃ ┃
┃ builder ┃ executor ┃ status ┃ Runtime) ┃ returncode ┃ runtime ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ stream_test/ │ generic.loca │ PASS │ None None │ 0 │ 2.075482 │
│ 61bc1eff │ l.bash │ │ None │ │ │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘
Passed Tests: 1/1 Percentage: 100.000%
Failed Tests: 0/1 Percentage: 0.000%
Adding 1 test results to /tmp/tmptsqn67rj/var/report.json
Writing Logfile to: /tmp/tmptsqn67rj/var/logs/buildtest_nf03msz0.log
Let’s run buildtest inspect query -o stream_test
to retrieve the test details and output of STREAM test.
buildtest inspect query -o stream_test
$ buildtest inspect query -o stream_test
─────────────── stream_test/61bc1eff-f244-4a52-b88f-00d4c27e5397 ───────────────
Executor: generic.local.bash
Description: Run stream test with metrics example using assert greater equal
State: PASS
Returncode: 0
Runtime: 2.075482 sec
Starttime: 2023/11/13 01:35:59
Endtime: 2023/11/13 01:36:01
Command: bash --norc --noprofile -eo pipefail stream_test_build.sh
Test Script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ge/stream_test/61bc1eff/stream_test.sh
Build Script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ge/stream_test/61bc1eff/stream_test_build.sh
Output File: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ge/stream_test/61bc1eff/stream_test.out
Error File: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ge/stream_test/61bc1eff/stream_test.err
Log File: /tmp/tmptsqn67rj/var/logs/buildtest_nf03msz0.log
Metrics
┏━━━━━━━┳━━━━━━━━┓
┃ Name ┃ Value ┃
┡━━━━━━━╇━━━━━━━━┩
│ copy │ 5872.6 │
│ scale │ 6676.4 │
│ add │ 8719.1 │
│ triad │ 8464.2 │
└───────┴────────┘
─ Output File: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ge/stream… ─
-------------------------------------------------------------
STREAM version $Revision: 5.10 $
-------------------------------------------------------------
This system uses 8 bytes per array element.
-------------------------------------------------------------
Array size = 10000000 (elements), Offset = 0 (elements)
Memory per array = 76.3 MiB (= 0.1 GiB).
Total memory required = 228.9 MiB (= 0.2 GiB).
Each kernel will be executed 10 times.
The *best* time for each kernel (excluding the first iteration)
will be used to compute the reported bandwidth.
-------------------------------------------------------------
Your clock granularity/precision appears to be 1 microseconds.
Each test below will take on the order of 24885 microseconds.
(= 24885 clock ticks)
Increase the size of the arrays if this shows that
you are not getting at least 20 clock ticks per test.
-------------------------------------------------------------
WARNING -- The above is only a rough guideline.
For best results, please be sure you know the
precision of your system timer.
-------------------------------------------------------------
Function Best Rate MB/s Avg time Min time Max time
Copy: 5872.6 0.027409 0.027245 0.027559
Scale: 6676.4 0.024176 0.023965 0.024586
Add: 8719.1 0.027693 0.027526 0.027950
Triad: 8464.2 0.028571 0.028355 0.028857
-------------------------------------------------------------
Solution Validates: avg error less than 1.000000e-13 on all three arrays
-------------------------------------------------------------
Greater Than
In this example, we perform a > operation, this can be done via assert_gt
property
1buildspecs:
2 assert_gt_example:
3 type: script
4 executor: generic.local.bash
5 description: Run stream test with metrics example using assert greater than.
6 env:
7 OMP_NUM_THREADS: 4
8 run: |
9 wget https://raw.githubusercontent.com/jeffhammond/STREAM/master/stream.c
10 gcc -openmp -o stream stream.c
11 ./stream
12 metrics:
13 copy:
14 type: float
15 regex:
16 exp: 'Copy:\s+(\S+)\s+.*'
17 stream: stdout
18 item: 1
19 scale:
20 type: float
21 regex:
22 exp: 'Scale:\s+(\S+)\s+.*'
23 stream: stdout
24 item: 1
25 add:
26 type: float
27 regex:
28 exp: 'Add:\s+(\S+)\s+.*'
29 stream: stdout
30 item: 1
31 triad:
32 type: float
33 regex:
34 exp: 'Triad:\s+(\S+)\s+.*'
35 stream: stdout
36 item: 1
37 status:
38 assert_gt:
39 comparisons:
40 - name: copy
41 ref: 5000
42 - name: scale
43 ref: 5500
44 - name: add
45 ref: 6000
46 - name: triad
47 ref: 6500
Less Than Equal
In this example, we perform a <= operation, this can be done via assert_le
property
1buildspecs:
2 assert_le_example:
3 type: script
4 executor: generic.local.bash
5 description: Run stream test with metrics example using assert less than equal
6 env:
7 OMP_NUM_THREADS: 4
8 run: |
9 wget https://raw.githubusercontent.com/jeffhammond/STREAM/master/stream.c
10 gcc -openmp -o stream stream.c
11 ./stream
12 metrics:
13 copy:
14 type: float
15 regex:
16 exp: 'Copy:\s+(\S+)\s+.*'
17 stream: stdout
18 item: 1
19 scale:
20 type: float
21 regex:
22 exp: 'Scale:\s+(\S+)\s+.*'
23 stream: stdout
24 item: 1
25 add:
26 type: float
27 regex:
28 exp: 'Add:\s+(\S+)\s+.*'
29 stream: stdout
30 item: 1
31 triad:
32 type: float
33 regex:
34 exp: 'Triad:\s+(\S+)\s+.*'
35 stream: stdout
36 item: 1
37 status:
38 assert_le:
39 comparisons:
40 - name: copy
41 ref: 5000
42 - name: scale
43 ref: 5500
44 - name: add
45 ref: 6000
46 - name: triad
47 ref: 6500
Less Than
In this example, we perform a < operation, this can be done via assert_lt
property
1buildspecs:
2 assert_lt_example:
3 type: script
4 executor: generic.local.bash
5 description: Run stream test with metrics example using assert less than
6 env:
7 OMP_NUM_THREADS: 4
8 run: |
9 wget https://raw.githubusercontent.com/jeffhammond/STREAM/master/stream.c
10 gcc -openmp -o stream stream.c
11 ./stream
12 metrics:
13 copy:
14 type: float
15 regex:
16 exp: 'Copy:\s+(\S+)\s+.*'
17 stream: stdout
18 item: 1
19 scale:
20 type: float
21 regex:
22 exp: 'Scale:\s+(\S+)\s+.*'
23 stream: stdout
24 item: 1
25 add:
26 type: float
27 regex:
28 exp: 'Add:\s+(\S+)\s+.*'
29 stream: stdout
30 item: 1
31 triad:
32 type: float
33 regex:
34 exp: 'Triad:\s+(\S+)\s+.*'
35 stream: stdout
36 item: 1
37 status:
38 assert_lt:
39 comparisons:
40 - name: copy
41 ref: 5000
42 - name: scale
43 ref: 5500
44 - name: add
45 ref: 6000
46 - name: triad
47 ref: 6500
Assert Equal
buildtest can perform assert equality check with metrics to determine status of test. In this next example, we define
four metrics x, y, first, and last which will be compared with its reference value. We introduce a new
property assert_eq
which is composed of list of assertions. Each reference is converted to its appropriate
type (int
, float
, str
).
1buildspecs:
2 assert_eq_example:
3 type: script
4 executor: generic.local.bash
5 description: Test for assert equality
6 vars:
7 X: 1
8 Y: 1.5
9 first: John
10 last: Smith
11 run: |
12 echo "X: $X"
13 echo "Y: $Y"
14 echo "Name: $first $last"
15 metrics:
16 x:
17 type: int
18 regex:
19 stream: stdout
20 exp: 'X:\s+(\S+)\s+.*'
21 item: 1
22 y:
23 type: float
24 regex:
25 stream: stdout
26 exp: 'Y:\s+(\S+)\s+.*'
27 item: 1
28 first:
29 type: str
30 regex:
31 stream: stdout
32 exp: 'Name:\s+(\S+)\s+.*'
33 item: 1
34 last:
35 type: str
36 regex:
37 stream: stdout
38 exp: '(Smith)$'
39 item: 1
40 status:
41 assert_eq:
42 comparisons:
43 - name: x
44 ref: 1
45 - name: y
46 ref: 1.5
47 - name: first
48 ref: John
49 - name: last
50 ref: Smith
This test is expected to pass where all assertions are True. Let’s build the test and see the output
buildtest build -b tutorials/perf_checks/assert_eq.yml
$ buildtest build -b tutorials/perf_checks/assert_eq.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│ │
│ User: docs │
│ Hostname: build-22529915-project-280831-buildtest │
│ Platform: Linux │
│ Current Time: 2023/11/13 01:36:02 │
│ buildtest path: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version: 1.7 │
│ python path: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version: 3.8.18 │
│ Configuration File: /tmp/tmptsqn67rj/config.yml │
│ Test Directory: /tmp/tmptsqn67rj/var/tests │
│ Report File: /tmp/tmptsqn67rj/var/report.json │
│ Command: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
─────────────────────────── Discovering Buildspecs ────────────────────────────
Discovered buildspecs
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/v1.7/tu ║
║ torials/perf_checks/assert_eq.yml ║
╚══════════════════════════════════════════════════════════════════════════════╝
Total Discovered Buildspecs: 1
Total Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/v1.7/tutorials/perf_checks/assert_eq.yml: VALID
Total builder objects created: 1
Builders by type=script
┏━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━┓
┃ ┃ ┃ ┃ ┃ ┃ ┃ descript ┃ buildsp ┃
┃ builder ┃ type ┃ executor ┃ compiler ┃ nodes ┃ procs ┃ ion ┃ ecs ┃
┡━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━┩
│ assert_e │ script │ generic. │ None │ None │ None │ Test for │ /home/d │
│ q_exampl │ │ local.ba │ │ │ │ assert │ ocs/che │
│ e/6127b2 │ │ sh │ │ │ │ equality │ ckouts/ │
│ 91 │ │ │ │ │ │ │ readthe │
│ │ │ │ │ │ │ │ docs.or │
│ │ │ │ │ │ │ │ g/user_ │
│ │ │ │ │ │ │ │ builds/ │
│ │ │ │ │ │ │ │ buildte │
│ │ │ │ │ │ │ │ st/chec │
│ │ │ │ │ │ │ │ kouts/v │
│ │ │ │ │ │ │ │ 1.7/tut │
│ │ │ │ │ │ │ │ orials/ │
│ │ │ │ │ │ │ │ perf_ch │
│ │ │ │ │ │ │ │ ecks/as │
│ │ │ │ │ │ │ │ sert_eq │
│ │ │ │ │ │ │ │ .yml │
└──────────┴────────┴──────────┴──────────┴───────┴───────┴──────────┴─────────┘
──────────────────────────────── Building Test ─────────────────────────────────
assert_eq_example/6127b291: Creating test directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq/assert_eq_example/6127b291
assert_eq_example/6127b291: Creating the stage directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq/assert_eq_example/6127b291/stage
assert_eq_example/6127b291: Writing build script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq/assert_eq_example/6127b291/assert_eq_example_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
assert_eq_example/6127b291 does not have any dependencies adding test to queue
Builders Eligible to Run
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Builder ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ assert_eq_example/6127b291 │
└────────────────────────────┘
assert_eq_example/6127b291: Current Working Directory : /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq/assert_eq_example/6127b291/stage
assert_eq_example/6127b291: Running Test via command: bash --norc --noprofile -eo pipefail assert_eq_example_build.sh
assert_eq_example/6127b291: Test completed in 0.006131 seconds
assert_eq_example/6127b291: Test completed with returncode: 0
assert_eq_example/6127b291: Writing output file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq/assert_eq_example/6127b291/assert_eq_example.out
assert_eq_example/6127b291: Writing error file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq/assert_eq_example/6127b291/assert_eq_example.err
assert_eq_example/6127b291: testing metric: x if 1 == 1 - Check: True
assert_eq_example/6127b291: testing metric: y if 1.5 == 1.5 - Check: True
assert_eq_example/6127b291: testing metric: first if John == John - Check: True
assert_eq_example/6127b291: testing metric: last if Smith == Smith - Check: True
assert_eq_example/6127b291: Equality Check: True
Test Summary
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ ┃ ┃ ┃ checks ┃ ┃ ┃
┃ ┃ ┃ ┃ (ReturnCode, ┃ ┃ ┃
┃ ┃ ┃ ┃ Regex, ┃ ┃ ┃
┃ builder ┃ executor ┃ status ┃ Runtime) ┃ returncode ┃ runtime ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ assert_eq_ex │ generic.loca │ PASS │ None None │ 0 │ 0.006131 │
│ ample/6127b2 │ l.bash │ │ None │ │ │
│ 91 │ │ │ │ │ │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘
Passed Tests: 1/1 Percentage: 100.000%
Failed Tests: 0/1 Percentage: 0.000%
Adding 1 test results to /tmp/tmptsqn67rj/var/report.json
Writing Logfile to: /tmp/tmptsqn67rj/var/logs/buildtest_3pbb3rd2.log
buildtest inspect query -o assert_eq_example
$ buildtest inspect query -o assert_eq_example
──────────── assert_eq_example/6127b291-5d72-4c58-ba39-489a99b8b5a5 ────────────
Executor: generic.local.bash
Description: Test for assert equality
State: PASS
Returncode: 0
Runtime: 0.006131 sec
Starttime: 2023/11/13 01:36:02
Endtime: 2023/11/13 01:36:02
Command: bash --norc --noprofile -eo pipefail assert_eq_example_build.sh
Test Script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq/assert_eq_example/6127b291/assert_eq_example.sh
Build Script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq/assert_eq_example/6127b291/assert_eq_example_build.sh
Output File: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq/assert_eq_example/6127b291/assert_eq_example.out
Error File: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq/assert_eq_example/6127b291/assert_eq_example.err
Log File: /tmp/tmptsqn67rj/var/logs/buildtest_3pbb3rd2.log
Metrics
┏━━━━━━━┳━━━━━━━┓
┃ Name ┃ Value ┃
┡━━━━━━━╇━━━━━━━┩
│ x │ 1 │
│ y │ 1.5 │
│ first │ John │
│ last │ Smith │
└───────┴───────┘
─ Output File: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq/assert… ─
X: 1
Y: 1.5
Name: John Smith
In the next example, we have two tests to highlight some exceptions. In the first test, we define an invalid metric name invalid_metric
in assert_eq
since this metric was not defined in metrics
field, therefore this test will fail. The second test will fail because we have
a mismatch in value captured by metric x
which is 1 however the reference value is 2.
1buildspecs:
2 assert_eq_invalid_metric:
3 type: script
4 executor: generic.local.bash
5 description: An invalid metric name will cause failure
6 vars:
7 X: 1
8 run: |
9 echo "X: $X"
10 metrics:
11 x:
12 type: int
13 regex:
14 stream: stdout
15 exp: 'X:\s+(\S+)\s+.*'
16 item: 1
17 status:
18 assert_eq:
19 comparisons:
20 - name: x
21 ref: 1
22 - name: invalid_metric
23 ref: 'hello'
24 assert_eq_mismatch:
25 type: script
26 executor: generic.local.bash
27 description: This test will fail because there is a mismatch in metric x assert equality
28 vars:
29 X: 1
30 run: |
31 echo "X: $X"
32 metrics:
33 x:
34 type: int
35 regex:
36 stream: stdout
37 exp: 'X:\s+(\S+)\s+.*'
38 item: 1
39 status:
40 assert_eq:
41 comparisons:
42 - name: x
43 ref: 2
Let’s build this test and see the output.
buildtest build -b tutorials/perf_checks/assert_eq_exceptions.yml
$ buildtest build -b tutorials/perf_checks/assert_eq_exceptions.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│ │
│ User: docs │
│ Hostname: build-22529915-project-280831-buildtest │
│ Platform: Linux │
│ Current Time: 2023/11/13 01:36:03 │
│ buildtest path: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version: 1.7 │
│ python path: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version: 3.8.18 │
│ Configuration File: /tmp/tmptsqn67rj/config.yml │
│ Test Directory: /tmp/tmptsqn67rj/var/tests │
│ Report File: /tmp/tmptsqn67rj/var/report.json │
│ Command: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
─────────────────────────── Discovering Buildspecs ────────────────────────────
Discovered buildspecs
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/v1.7/tu ║
║ torials/perf_checks/assert_eq_exceptions.yml ║
╚══════════════════════════════════════════════════════════════════════════════╝
Total Discovered Buildspecs: 1
Total Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/v1.7/tutorials/perf_checks/assert_eq_exceptions.yml: VALID
Total builder objects created: 2
Builders by type=script
┏━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━┓
┃ ┃ ┃ ┃ ┃ ┃ ┃ descript ┃ buildsp ┃
┃ builder ┃ type ┃ executor ┃ compiler ┃ nodes ┃ procs ┃ ion ┃ ecs ┃
┡━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━┩
│ assert_e │ script │ generic. │ None │ None │ None │ An │ /home/d │
│ q_invali │ │ local.ba │ │ │ │ invalid │ ocs/che │
│ d_metric │ │ sh │ │ │ │ metric │ ckouts/ │
│ /6cb9629 │ │ │ │ │ │ name │ readthe │
│ a │ │ │ │ │ │ will │ docs.or │
│ │ │ │ │ │ │ cause │ g/user_ │
│ │ │ │ │ │ │ failure │ builds/ │
│ │ │ │ │ │ │ │ buildte │
│ │ │ │ │ │ │ │ st/chec │
│ │ │ │ │ │ │ │ kouts/v │
│ │ │ │ │ │ │ │ 1.7/tut │
│ │ │ │ │ │ │ │ orials/ │
│ │ │ │ │ │ │ │ perf_ch │
│ │ │ │ │ │ │ │ ecks/as │
│ │ │ │ │ │ │ │ sert_eq │
│ │ │ │ │ │ │ │ _except │
│ │ │ │ │ │ │ │ ions.ym │
│ │ │ │ │ │ │ │ l │
├──────────┼────────┼──────────┼──────────┼───────┼───────┼──────────┼─────────┤
│ assert_e │ script │ generic. │ None │ None │ None │ This │ /home/d │
│ q_mismat │ │ local.ba │ │ │ │ test │ ocs/che │
│ ch/9ece0 │ │ sh │ │ │ │ will │ ckouts/ │
│ 1c6 │ │ │ │ │ │ fail │ readthe │
│ │ │ │ │ │ │ because │ docs.or │
│ │ │ │ │ │ │ there is │ g/user_ │
│ │ │ │ │ │ │ a │ builds/ │
│ │ │ │ │ │ │ mismatch │ buildte │
│ │ │ │ │ │ │ in │ st/chec │
│ │ │ │ │ │ │ metric x │ kouts/v │
│ │ │ │ │ │ │ assert │ 1.7/tut │
│ │ │ │ │ │ │ equality │ orials/ │
│ │ │ │ │ │ │ │ perf_ch │
│ │ │ │ │ │ │ │ ecks/as │
│ │ │ │ │ │ │ │ sert_eq │
│ │ │ │ │ │ │ │ _except │
│ │ │ │ │ │ │ │ ions.ym │
│ │ │ │ │ │ │ │ l │
└──────────┴────────┴──────────┴──────────┴───────┴───────┴──────────┴─────────┘
──────────────────────────────── Building Test ─────────────────────────────────
assert_eq_invalid_metric/6cb9629a: Creating test directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq_exceptions/assert_eq_invalid_metric/6cb9629a
assert_eq_invalid_metric/6cb9629a: Creating the stage directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq_exceptions/assert_eq_invalid_metric/6cb9629a/stage
assert_eq_invalid_metric/6cb9629a: Writing build script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq_exceptions/assert_eq_invalid_metric/6cb9629a/assert_eq_invalid_metric_build.sh
assert_eq_mismatch/9ece01c6: Creating test directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq_exceptions/assert_eq_mismatch/9ece01c6
assert_eq_mismatch/9ece01c6: Creating the stage directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq_exceptions/assert_eq_mismatch/9ece01c6/stage
assert_eq_mismatch/9ece01c6: Writing build script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq_exceptions/assert_eq_mismatch/9ece01c6/assert_eq_mismatch_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
assert_eq_invalid_metric/6cb9629a does not have any dependencies adding test to queue
assert_eq_mismatch/9ece01c6 does not have any dependencies adding test to queue
Builders Eligible to Run
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Builder ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ assert_eq_invalid_metric/6cb9629a │
│ assert_eq_mismatch/9ece01c6 │
└───────────────────────────────────┘
assert_eq_invalid_metric/6cb9629a: Current Working Directory : /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq_exceptions/assert_eq_invalid_metric/6cb9629a/stage
assert_eq_invalid_metric/6cb9629a: Running Test via command: bash --norc --noprofile -eo pipefail assert_eq_invalid_metric_build.sh
assert_eq_invalid_metric/6cb9629a: Test completed in 0.006367 seconds
assert_eq_invalid_metric/6cb9629a: Test completed with returncode: 0
assert_eq_invalid_metric/6cb9629a: Writing output file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq_exceptions/assert_eq_invalid_metric/6cb9629a/assert_eq_invalid_metric.out
assert_eq_invalid_metric/6cb9629a: Writing error file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq_exceptions/assert_eq_invalid_metric/6cb9629a/assert_eq_invalid_metric.err
assert_eq_invalid_metric/6cb9629a: testing metric: x if 1 == 1 - Check: True
assert_eq_invalid_metric/6cb9629a: Unable to find metric: invalid_metric. List of valid metrics are the following: ['x']
assert_eq_invalid_metric/6cb9629a: Equality Check: False
assert_eq_mismatch/9ece01c6: Current Working Directory : /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq_exceptions/assert_eq_mismatch/9ece01c6/stage
assert_eq_mismatch/9ece01c6: Running Test via command: bash --norc --noprofile -eo pipefail assert_eq_mismatch_build.sh
assert_eq_mismatch/9ece01c6: Test completed in 0.005848 seconds
assert_eq_mismatch/9ece01c6: Test completed with returncode: 0
assert_eq_mismatch/9ece01c6: Writing output file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq_exceptions/assert_eq_mismatch/9ece01c6/assert_eq_mismatch.out
assert_eq_mismatch/9ece01c6: Writing error file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_eq_exceptions/assert_eq_mismatch/9ece01c6/assert_eq_mismatch.err
assert_eq_mismatch/9ece01c6: testing metric: x if 1 == 2 - Check: False
assert_eq_mismatch/9ece01c6: Equality Check: False
Test Summary
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ ┃ ┃ ┃ checks ┃ ┃ ┃
┃ ┃ ┃ ┃ (ReturnCode, ┃ ┃ ┃
┃ ┃ ┃ ┃ Regex, ┃ ┃ ┃
┃ builder ┃ executor ┃ status ┃ Runtime) ┃ returncode ┃ runtime ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ assert_eq_mi │ generic.loca │ FAIL │ None None │ 0 │ 0.005848 │
│ smatch/9ece0 │ l.bash │ │ None │ │ │
│ 1c6 │ │ │ │ │ │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ assert_eq_in │ generic.loca │ FAIL │ None None │ 0 │ 0.006367 │
│ valid_metric │ l.bash │ │ None │ │ │
│ /6cb9629a │ │ │ │ │ │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘
Passed Tests: 0/2 Percentage: 0.000%
Failed Tests: 2/2 Percentage: 100.000%
Adding 2 test results to /tmp/tmptsqn67rj/var/report.json
Writing Logfile to: /tmp/tmptsqn67rj/var/logs/buildtest_ji9j0_g7.log
Assert Not Equal
In this section, we will discuss the inverse equality operation Not Equal check (!=) with reference value.
We can use assert_ne
property to perform != check, it works similar to assert_eq with data types int,
float and str. In this example, we check the metrics x
, y
, first
and last
and each metric
should pass. The reference value is converted to the data-type (type
field) for each metrics
1buildspecs:
2 assert_ne_example:
3 type: script
4 executor: generic.local.bash
5 description: Test for assert not equal
6 vars:
7 X: 1
8 Y: 1.5
9 first: John
10 last: Smith
11 run: |
12 echo "X: $X"
13 echo "Y: $Y"
14 echo "Name: $first $last"
15 metrics:
16 x:
17 type: int
18 regex:
19 stream: stdout
20 exp: 'X:\s+(\S+)\s+.*'
21 item: 1
22 y:
23 type: float
24 regex:
25 stream: stdout
26 exp: 'Y:\s+(\S+)\s+.*'
27 item: 1
28 first:
29 type: str
30 regex:
31 stream: stdout
32 exp: 'Name:\s+(\S+)\s+.*'
33 item: 1
34 last:
35 type: str
36 regex:
37 stream: stdout
38 exp: '(Smith)$'
39 item: 1
40 status:
41 assert_ne:
42 comparisons:
43 - name: x
44 ref: 2
45 - name: y
46 ref: 2.5
47 - name: first
48 ref: Robert
49 - name: last
50 ref: Brown
We expect this test to pass. In order to run this test, you can do the following
buildtest build -b tutorials/perf_checks/assert_ne.yml
$ buildtest build -b tutorials/perf_checks/assert_ne.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│ │
│ User: docs │
│ Hostname: build-22529915-project-280831-buildtest │
│ Platform: Linux │
│ Current Time: 2023/11/13 01:36:04 │
│ buildtest path: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version: 1.7 │
│ python path: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version: 3.8.18 │
│ Configuration File: /tmp/tmptsqn67rj/config.yml │
│ Test Directory: /tmp/tmptsqn67rj/var/tests │
│ Report File: /tmp/tmptsqn67rj/var/report.json │
│ Command: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
─────────────────────────── Discovering Buildspecs ────────────────────────────
Discovered buildspecs
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/v1.7/tu ║
║ torials/perf_checks/assert_ne.yml ║
╚══════════════════════════════════════════════════════════════════════════════╝
Total Discovered Buildspecs: 1
Total Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/v1.7/tutorials/perf_checks/assert_ne.yml: VALID
Total builder objects created: 1
Builders by type=script
┏━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━┓
┃ ┃ ┃ ┃ ┃ ┃ ┃ descript ┃ buildsp ┃
┃ builder ┃ type ┃ executor ┃ compiler ┃ nodes ┃ procs ┃ ion ┃ ecs ┃
┡━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━┩
│ assert_n │ script │ generic. │ None │ None │ None │ Test for │ /home/d │
│ e_exampl │ │ local.ba │ │ │ │ assert │ ocs/che │
│ e/875f95 │ │ sh │ │ │ │ not │ ckouts/ │
│ 5b │ │ │ │ │ │ equal │ readthe │
│ │ │ │ │ │ │ │ docs.or │
│ │ │ │ │ │ │ │ g/user_ │
│ │ │ │ │ │ │ │ builds/ │
│ │ │ │ │ │ │ │ buildte │
│ │ │ │ │ │ │ │ st/chec │
│ │ │ │ │ │ │ │ kouts/v │
│ │ │ │ │ │ │ │ 1.7/tut │
│ │ │ │ │ │ │ │ orials/ │
│ │ │ │ │ │ │ │ perf_ch │
│ │ │ │ │ │ │ │ ecks/as │
│ │ │ │ │ │ │ │ sert_ne │
│ │ │ │ │ │ │ │ .yml │
└──────────┴────────┴──────────┴──────────┴───────┴───────┴──────────┴─────────┘
──────────────────────────────── Building Test ─────────────────────────────────
assert_ne_example/875f955b: Creating test directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ne/assert_ne_example/875f955b
assert_ne_example/875f955b: Creating the stage directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ne/assert_ne_example/875f955b/stage
assert_ne_example/875f955b: Writing build script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ne/assert_ne_example/875f955b/assert_ne_example_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
assert_ne_example/875f955b does not have any dependencies adding test to queue
Builders Eligible to Run
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Builder ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ assert_ne_example/875f955b │
└────────────────────────────┘
assert_ne_example/875f955b: Current Working Directory : /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ne/assert_ne_example/875f955b/stage
assert_ne_example/875f955b: Running Test via command: bash --norc --noprofile -eo pipefail assert_ne_example_build.sh
assert_ne_example/875f955b: Test completed in 0.006154 seconds
assert_ne_example/875f955b: Test completed with returncode: 0
assert_ne_example/875f955b: Writing output file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ne/assert_ne_example/875f955b/assert_ne_example.out
assert_ne_example/875f955b: Writing error file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_ne/assert_ne_example/875f955b/assert_ne_example.err
assert_ne_example/875f955b: testing metric: x if 1 != 2 - Check: True
assert_ne_example/875f955b: testing metric: y if 1.5 != 2.5 - Check: True
assert_ne_example/875f955b: testing metric: first if John != Robert - Check: True
assert_ne_example/875f955b: testing metric: last if Smith != Brown - Check: True
assert_ne_example/875f955b: Not Equal Check: True
Test Summary
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ ┃ ┃ ┃ checks ┃ ┃ ┃
┃ ┃ ┃ ┃ (ReturnCode, ┃ ┃ ┃
┃ ┃ ┃ ┃ Regex, ┃ ┃ ┃
┃ builder ┃ executor ┃ status ┃ Runtime) ┃ returncode ┃ runtime ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ assert_ne_ex │ generic.loca │ PASS │ None None │ 0 │ 0.006154 │
│ ample/875f95 │ l.bash │ │ None │ │ │
│ 5b │ │ │ │ │ │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘
Passed Tests: 1/1 Percentage: 100.000%
Failed Tests: 0/1 Percentage: 0.000%
Adding 1 test results to /tmp/tmptsqn67rj/var/report.json
Writing Logfile to: /tmp/tmptsqn67rj/var/logs/buildtest_hc6ympo1.log
Assert Range
The assert_range
property can be used to test performance for a metric given a lower and upper bound. This property expects
one to specify lower
and upper
field which must be an integer or floating point number to perform comparison. buildtest will
perform an assertion, if metric value is in the range specified by lower and upper, then test will pass. Shown below
is an example using the assert_range
property with stream benchmark.
1buildspecs:
2 assert_range_ex:
3 type: script
4 executor: generic.local.bash
5 description: Example on assert_range
6 env:
7 OMP_NUM_THREADS: 4
8 run: |
9 wget https://raw.githubusercontent.com/jeffhammond/STREAM/master/stream.c
10 gcc -openmp -o stream stream.c
11 ./stream
12 metrics:
13 copy:
14 type: float
15 regex:
16 exp: 'Copy:\s+(\S+)\s+.*'
17 stream: stdout
18 item: 1
19 scale:
20 type: float
21 regex:
22 exp: 'Scale:\s+(\S+)\s+.*'
23 stream: stdout
24 item: 1
25 add:
26 type: float
27 regex:
28 exp: 'Add:\s+(\S+)\s+.*'
29 stream: stdout
30 item: 1
31 triad:
32 type: float
33 regex:
34 exp: 'Triad:\s+(\S+)\s+.*'
35 stream: stdout
36 item: 1
37 status:
38 assert_range:
39 comparisons:
40 - name: copy
41 lower: 5000
42 upper: 20000
43 - name: scale
44 lower: 4500
45 upper: 20000
46 - name: add
47 lower: 4300
48 upper: 20000
49 - name: triad
50 lower: 5600
51 upper: 20000
Let’s build this test and see the output
buildtest build -b tutorials/perf_checks/assert_range.yml
$ buildtest build -b tutorials/perf_checks/assert_range.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│ │
│ User: docs │
│ Hostname: build-22529915-project-280831-buildtest │
│ Platform: Linux │
│ Current Time: 2023/11/13 01:36:04 │
│ buildtest path: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version: 1.7 │
│ python path: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version: 3.8.18 │
│ Configuration File: /tmp/tmptsqn67rj/config.yml │
│ Test Directory: /tmp/tmptsqn67rj/var/tests │
│ Report File: /tmp/tmptsqn67rj/var/report.json │
│ Command: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
─────────────────────────── Discovering Buildspecs ────────────────────────────
Discovered buildspecs
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/v1.7/tu ║
║ torials/perf_checks/assert_range.yml ║
╚══════════════════════════════════════════════════════════════════════════════╝
Total Discovered Buildspecs: 1
Total Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/v1.7/tutorials/perf_checks/assert_range.yml: VALID
Total builder objects created: 1
Builders by type=script
┏━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━┓
┃ ┃ ┃ ┃ ┃ ┃ ┃ descript ┃ buildsp ┃
┃ builder ┃ type ┃ executor ┃ compiler ┃ nodes ┃ procs ┃ ion ┃ ecs ┃
┡━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━┩
│ assert_r │ script │ generic. │ None │ None │ None │ Example │ /home/d │
│ ange_ex/ │ │ local.ba │ │ │ │ on │ ocs/che │
│ 148ec179 │ │ sh │ │ │ │ assert_r │ ckouts/ │
│ │ │ │ │ │ │ ange │ readthe │
│ │ │ │ │ │ │ │ docs.or │
│ │ │ │ │ │ │ │ g/user_ │
│ │ │ │ │ │ │ │ builds/ │
│ │ │ │ │ │ │ │ buildte │
│ │ │ │ │ │ │ │ st/chec │
│ │ │ │ │ │ │ │ kouts/v │
│ │ │ │ │ │ │ │ 1.7/tut │
│ │ │ │ │ │ │ │ orials/ │
│ │ │ │ │ │ │ │ perf_ch │
│ │ │ │ │ │ │ │ ecks/as │
│ │ │ │ │ │ │ │ sert_ra │
│ │ │ │ │ │ │ │ nge.yml │
└──────────┴────────┴──────────┴──────────┴───────┴───────┴──────────┴─────────┘
──────────────────────────────── Building Test ─────────────────────────────────
assert_range_ex/148ec179: Creating test directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_range/assert_range_ex/148ec179
assert_range_ex/148ec179: Creating the stage directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_range/assert_range_ex/148ec179/stage
assert_range_ex/148ec179: Writing build script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_range/assert_range_ex/148ec179/assert_range_ex_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
assert_range_ex/148ec179 does not have any dependencies adding test to queue
Builders Eligible to Run
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Builder ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ assert_range_ex/148ec179 │
└──────────────────────────┘
assert_range_ex/148ec179: Current Working Directory : /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_range/assert_range_ex/148ec179/stage
assert_range_ex/148ec179: Running Test via command: bash --norc --noprofile -eo pipefail assert_range_ex_build.sh
assert_range_ex/148ec179: Test completed in 1.396225 seconds
assert_range_ex/148ec179: Test completed with returncode: 0
assert_range_ex/148ec179: Writing output file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_range/assert_range_ex/148ec179/assert_range_ex.out
assert_range_ex/148ec179: Writing error file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/assert_range/assert_range_ex/148ec179/assert_range_ex.err
assert_range_ex/148ec179: testing metric: copy if 5000.0 <= 5896.3 <= 20000.0 - Check: True
assert_range_ex/148ec179: testing metric: scale if 4500.0 <= 6691.2 <= 20000.0 - Check: True
assert_range_ex/148ec179: testing metric: add if 4300.0 <= 8808.9 <= 20000.0 - Check: True
assert_range_ex/148ec179: testing metric: triad if 5600.0 <= 8474.3 <= 20000.0 - Check: True
assert_range_ex/148ec179: Range Check: True
Test Summary
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ ┃ ┃ ┃ checks ┃ ┃ ┃
┃ ┃ ┃ ┃ (ReturnCode, ┃ ┃ ┃
┃ ┃ ┃ ┃ Regex, ┃ ┃ ┃
┃ builder ┃ executor ┃ status ┃ Runtime) ┃ returncode ┃ runtime ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ assert_range │ generic.loca │ PASS │ None None │ 0 │ 1.396225 │
│ _ex/148ec179 │ l.bash │ │ None │ │ │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘
Passed Tests: 1/1 Percentage: 100.000%
Failed Tests: 0/1 Percentage: 0.000%
Adding 1 test results to /tmp/tmptsqn67rj/var/report.json
Writing Logfile to: /tmp/tmptsqn67rj/var/logs/buildtest_q2jeee3_.log
Note that performance results may vary on your system and depending on the metric value you may want to adjust the lower and upper bound to match your requirement.
Contains and Not Contains
Buildtest can perform status check with a list of reference values and check if metrics value is in the list. The
property contains
and not_contains
can be used to perform this type of check. The ref
property is a list of
reference values that a metric must have to pass metrics check.
In example below we have two tests, the first test perform contains
and not_contains
on metrics x. We expect both
status check will pass. The second test is expected to fail because metric x
will store integer value 1 but the list has
string equivalent ‘1’.
1buildspecs:
2 contains_and_not_contains:
3 type: script
4 executor: generic.local.bash
5 description: Status check based on contains and not contains where test pass
6 vars:
7 X: 1
8 run: |
9 echo "X: $X"
10 metrics:
11 x:
12 type: int
13 regex:
14 stream: stdout
15 exp: 'X:\s+(\S+)\s+.*'
16 item: 1
17 status:
18 contains:
19 comparisons:
20 - name: x
21 ref: [1, 2, 4, 8]
22 not_contains:
23 comparisons:
24 - name: x
25 ref: [2, 4]
26 assert_contains_fail:
27 type: script
28 executor: generic.local.bash
29 description: Status check based on contains where test fails
30 vars:
31 X: 1
32 run: |
33 echo "X: $X"
34 metrics:
35 x:
36 type: int
37 regex:
38 stream: stdout
39 exp: 'X:\s+(\S+)\s+.*'
40 item: 1
41 status:
42 contains:
43 comparisons:
44 - name: x
45 ref: ['1', 2, 4, 8]
You can run this test, by running the following command
buildtest build -b tutorials/perf_checks/contains.yml
$ buildtest build -b tutorials/perf_checks/contains.yml
╭───────────────────────────── buildtest summary ──────────────────────────────╮
│ │
│ User: docs │
│ Hostname: build-22529915-project-280831-buildtest │
│ Platform: Linux │
│ Current Time: 2023/11/13 01:36:06 │
│ buildtest path: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ buildtest version: 1.7 │
│ python path: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ python version: 3.8.18 │
│ Configuration File: /tmp/tmptsqn67rj/config.yml │
│ Test Directory: /tmp/tmptsqn67rj/var/tests │
│ Report File: /tmp/tmptsqn67rj/var/report.json │
│ Command: /home/docs/checkouts/readthedocs.org/user_builds/buildte │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
─────────────────────────── Discovering Buildspecs ────────────────────────────
Discovered buildspecs
╔══════════════════════════════════════════════════════════════════════════════╗
║ buildspec ║
╟──────────────────────────────────────────────────────────────────────────────╢
║ /home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/v1.7/tu ║
║ torials/perf_checks/contains.yml ║
╚══════════════════════════════════════════════════════════════════════════════╝
Total Discovered Buildspecs: 1
Total Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
────────────────────────────── Parsing Buildspecs ──────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/docs/checkouts/readthedocs.org/user_builds/buildtest/checkouts/v1.7/tutorials/perf_checks/contains.yml: VALID
Total builder objects created: 2
Builders by type=script
┏━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━┓
┃ ┃ ┃ ┃ ┃ ┃ ┃ descript ┃ buildsp ┃
┃ builder ┃ type ┃ executor ┃ compiler ┃ nodes ┃ procs ┃ ion ┃ ecs ┃
┡━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━┩
│ contains │ script │ generic. │ None │ None │ None │ Status │ /home/d │
│ _and_not │ │ local.ba │ │ │ │ check │ ocs/che │
│ _contain │ │ sh │ │ │ │ based on │ ckouts/ │
│ s/088476 │ │ │ │ │ │ contains │ readthe │
│ fa │ │ │ │ │ │ and not │ docs.or │
│ │ │ │ │ │ │ contains │ g/user_ │
│ │ │ │ │ │ │ where │ builds/ │
│ │ │ │ │ │ │ test │ buildte │
│ │ │ │ │ │ │ pass │ st/chec │
│ │ │ │ │ │ │ │ kouts/v │
│ │ │ │ │ │ │ │ 1.7/tut │
│ │ │ │ │ │ │ │ orials/ │
│ │ │ │ │ │ │ │ perf_ch │
│ │ │ │ │ │ │ │ ecks/co │
│ │ │ │ │ │ │ │ ntains. │
│ │ │ │ │ │ │ │ yml │
├──────────┼────────┼──────────┼──────────┼───────┼───────┼──────────┼─────────┤
│ assert_c │ script │ generic. │ None │ None │ None │ Status │ /home/d │
│ ontains_ │ │ local.ba │ │ │ │ check │ ocs/che │
│ fail/b8f │ │ sh │ │ │ │ based on │ ckouts/ │
│ 2170c │ │ │ │ │ │ contains │ readthe │
│ │ │ │ │ │ │ where │ docs.or │
│ │ │ │ │ │ │ test │ g/user_ │
│ │ │ │ │ │ │ fails │ builds/ │
│ │ │ │ │ │ │ │ buildte │
│ │ │ │ │ │ │ │ st/chec │
│ │ │ │ │ │ │ │ kouts/v │
│ │ │ │ │ │ │ │ 1.7/tut │
│ │ │ │ │ │ │ │ orials/ │
│ │ │ │ │ │ │ │ perf_ch │
│ │ │ │ │ │ │ │ ecks/co │
│ │ │ │ │ │ │ │ ntains. │
│ │ │ │ │ │ │ │ yml │
└──────────┴────────┴──────────┴──────────┴───────┴───────┴──────────┴─────────┘
──────────────────────────────── Building Test ─────────────────────────────────
contains_and_not_contains/088476fa: Creating test directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/contains/contains_and_not_contains/088476fa
contains_and_not_contains/088476fa: Creating the stage directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/contains/contains_and_not_contains/088476fa/stage
contains_and_not_contains/088476fa: Writing build script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/contains/contains_and_not_contains/088476fa/contains_and_not_contains_build.sh
assert_contains_fail/b8f2170c: Creating test directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/contains/assert_contains_fail/b8f2170c
assert_contains_fail/b8f2170c: Creating the stage directory: /tmp/tmptsqn67rj/var/tests/generic.local.bash/contains/assert_contains_fail/b8f2170c/stage
assert_contains_fail/b8f2170c: Writing build script: /tmp/tmptsqn67rj/var/tests/generic.local.bash/contains/assert_contains_fail/b8f2170c/assert_contains_fail_build.sh
──────────────────────────────── Running Tests ─────────────────────────────────
Spawning 1 processes for processing builders
───────────────────────────────── Iteration 1 ──────────────────────────────────
assert_contains_fail/b8f2170c does not have any dependencies adding test to queue
contains_and_not_contains/088476fa does not have any dependencies adding test to queue
Builders Eligible to Run
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Builder ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ assert_contains_fail/b8f2170c │
│ contains_and_not_contains/088476fa │
└────────────────────────────────────┘
assert_contains_fail/b8f2170c: Current Working Directory : /tmp/tmptsqn67rj/var/tests/generic.local.bash/contains/assert_contains_fail/b8f2170c/stage
assert_contains_fail/b8f2170c: Running Test via command: bash --norc --noprofile -eo pipefail assert_contains_fail_build.sh
assert_contains_fail/b8f2170c: Test completed in 0.006521 seconds
assert_contains_fail/b8f2170c: Test completed with returncode: 0
assert_contains_fail/b8f2170c: Writing output file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/contains/assert_contains_fail/b8f2170c/assert_contains_fail.out
assert_contains_fail/b8f2170c: Writing error file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/contains/assert_contains_fail/b8f2170c/assert_contains_fail.err
assert_contains_fail/b8f2170c: testing metric: x if 1 in ['1', 2, 4, 8] - Check: False
assert_contains_fail/b8f2170c: Contains Check: False
contains_and_not_contains/088476fa: Current Working Directory : /tmp/tmptsqn67rj/var/tests/generic.local.bash/contains/contains_and_not_contains/088476fa/stage
contains_and_not_contains/088476fa: Running Test via command: bash --norc --noprofile -eo pipefail contains_and_not_contains_build.sh
contains_and_not_contains/088476fa: Test completed in 0.006135 seconds
contains_and_not_contains/088476fa: Test completed with returncode: 0
contains_and_not_contains/088476fa: Writing output file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/contains/contains_and_not_contains/088476fa/contains_and_not_contains.out
contains_and_not_contains/088476fa: Writing error file - /tmp/tmptsqn67rj/var/tests/generic.local.bash/contains/contains_and_not_contains/088476fa/contains_and_not_contains.err
contains_and_not_contains/088476fa: testing metric: x if 1 in [1, 2, 4, 8] - Check: True
contains_and_not_contains/088476fa: Contains Check: True
contains_and_not_contains/088476fa: testing metric: x if 1 not in [2, 4] - Check: True
contains_and_not_contains/088476fa: Not Contains Check: True
Test Summary
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ ┃ ┃ ┃ checks ┃ ┃ ┃
┃ ┃ ┃ ┃ (ReturnCode, ┃ ┃ ┃
┃ ┃ ┃ ┃ Regex, ┃ ┃ ┃
┃ builder ┃ executor ┃ status ┃ Runtime) ┃ returncode ┃ runtime ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ assert_conta │ generic.loca │ FAIL │ None None │ 0 │ 0.006521 │
│ ins_fail/b8f │ l.bash │ │ None │ │ │
│ 2170c │ │ │ │ │ │
├──────────────┼──────────────┼────────┼───────────────┼────────────┼──────────┤
│ contains_and │ generic.loca │ PASS │ None None │ 0 │ 0.006135 │
│ _not_contain │ l.bash │ │ None │ │ │
│ s/088476fa │ │ │ │ │ │
└──────────────┴──────────────┴────────┴───────────────┴────────────┴──────────┘
Passed Tests: 1/2 Percentage: 50.000%
Failed Tests: 1/2 Percentage: 50.000%
Adding 2 test results to /tmp/tmptsqn67rj/var/report.json
Writing Logfile to: /tmp/tmptsqn67rj/var/logs/buildtest_f1tpahzz.log