19
19
20
20
import pytest
21
21
import redis
22
- from rq .job import Job
22
+ import rq
23
+
24
+ from common import config_utils , yaml_utils
25
+ from experiment .build import docker_images
26
+
27
+
28
+ @pytest .fixture (scope = 'class' )
29
+ def experiment_config ():
30
+ """Returns the default configuration for end-to-end testing."""
31
+ return config_utils .validate_and_expand (
32
+ yaml_utils .read ('fuzzbench/test_e2e/end-to-end-test-config.yaml' ))
23
33
24
34
25
35
@pytest .fixture (scope = 'class' )
@@ -31,17 +41,32 @@ def redis_connection():
31
41
# pylint: disable=no-self-use
32
42
@pytest .mark .skipif ('E2E_INTEGRATION_TEST' not in os .environ ,
33
43
reason = 'Not running end-to-end test.' )
34
- @pytest .mark .usefixtures ('redis_connection' )
44
+ @pytest .mark .usefixtures ('redis_connection' , 'experiment_config' )
35
45
class TestEndToEndRunResults :
36
46
"""Checks the result of a test experiment run."""
37
47
38
- def test_jobs_dependency (self ): # pylint: disable=redefined-outer-name
48
+ def test_jobs_dependency (self , experiment_config , redis_connection ): # pylint: disable=redefined-outer-name
39
49
"""Tests that jobs dependency preserves during working."""
40
- assert True
50
+ all_images = docker_images .get_images_to_build (
51
+ experiment_config ['fuzzers' ], experiment_config ['benchmarks' ])
52
+ jobs = {
53
+ name : rq .job .Job .fetch (name , connection = redis_connection )
54
+ for name in all_images
55
+ }
56
+ for name , image in all_images .items ():
57
+ if 'depends_on' in image :
58
+ for dep in image ['depends_on' ]:
59
+ assert jobs [dep ].ended_at <= jobs [name ].started_at
41
60
42
- def test_all_jobs_finished_successfully (self , redis_connection ): # pylint: disable=redefined-outer-name
61
+ def test_all_jobs_finished_successfully (
62
+ self ,
63
+ experiment_config , # pylint: disable=redefined-outer-name
64
+ redis_connection ): # pylint: disable=redefined-outer-name
43
65
"""Tests all jobs finished successully."""
44
- jobs = Job .fetch_many (['base-image' ], connection = redis_connection )
66
+ all_images = docker_images .get_images_to_build (
67
+ experiment_config ['fuzzers' ], experiment_config ['benchmarks' ])
68
+ jobs = rq .job .Job .fetch_many (all_images .keys (),
69
+ connection = redis_connection )
45
70
for job in jobs :
46
71
assert job .get_status () == 'finished'
47
72
0 commit comments