@@ -17,44 +17,16 @@ use containers::common qw(install_packages);
1717my $pytest_args = " -vv --capture=tee-sys -o junit_logging=all --junit-xml" ;
1818my $runtime ;
1919my $socat = 0;
20+ my $target ;
2021my $timeout = 3600;
2122
22- sub docker_tests {
23- my @targets = (
24- " unit" ,
25- " integration"
26- );
27-
28- foreach my $target (@targets ) {
29- record_info " TEST" , " $target " ;
30- script_run " pytest $pytest_args $target .xml tests/$target |& tee $target .txt" , timeout => $timeout ;
31- parse_extra_log(' XUnit' , " $target .xml" );
32- upload_logs(" $target .txt" );
33- }
34- }
35-
36- sub podman_tests {
37- my @targets = (
38- " unit" ,
39- " integration"
40- );
41-
42- foreach my $target (@targets ) {
43- record_info " TEST" , " $target " ;
44- script_run " pytest $pytest_args $target .xml podman/tests/$target |& tee $target .txt" , timeout => $timeout ;
45- parse_extra_log(' XUnit' , " $target .xml" );
46- upload_logs(" $target .txt" );
47- }
48- }
49-
50-
51- sub run {
52- my ($self , $args ) = @_ ;
53- $runtime = $args -> {runtime };
23+ sub setup {
24+ my $runtime = shift ;
5425
55- my @pkgs = ($runtime , " python3-$runtime " );
56- push @pkgs , qw( git-core jq python3-pytest) ;
57- push @pkgs , ($runtime eq " podman" ) ? qw( python3-fixtures python3-requests-mock) : qw( password-store python3-paramiko socat) ;
26+ my $python3 = " python3" ;
27+ my @pkgs = ($runtime , " $python3 -$runtime " );
28+ push @pkgs , qq( git-core jq $python3 -pytest) ;
29+ push @pkgs , ($runtime eq " podman" ) ? qq( $python3 -fixtures $python3 -requests-mock) : qq( password-store $python3 -paramiko socat) ;
5830 install_packages(@pkgs );
5931
6032 select_serial_terminal;
@@ -87,7 +59,6 @@ sub run {
8759 assert_script_run " chmod +x /usr/local/bin/docker-credential-pass" ;
8860 }
8961
90- my $python3 = " python3" ;
9162 my $version = script_output " $python3 -c 'import $runtime ; print($runtime .__version__)'" ;
9263 record_info(" Version" , $version );
9364 my $branch = ($runtime eq " podman" ) ? " v$version " : $version ;
@@ -107,21 +78,40 @@ sub run {
10778 assert_script_run " git clone --depth 1 --branch $branch https://github.com/$github_org /$runtime -py" ;
10879 assert_script_run " cd $runtime -py" ;
10980
110- if ($runtime eq " podman" ) {
111- podman_tests;
112- } else {
81+ if ($runtime eq " docker" ) {
11382 # Fill credentials store
11483 assert_script_run " gpg2 --import ./tests/gpg-keys/secret" ;
11584 assert_script_run " gpg2 --import-ownertrust ./tests/gpg-keys/ownertrust" ;
11685 assert_script_run " yes | pass init \$ (gpg2 --no-auto-check-trustdb --list-secret-key | awk '/^sec/{getline; \$ 1=\$ 1; print}')" ;
11786 assert_script_run " gpg2 --check-trustdb" ;
118- docker_tests;
11987 }
12088}
12189
122- 1;
90+ sub test {
91+ my $target = shift ;
92+
93+ # Tests directory
94+ my $tests = ($runtime eq " podman" ) ? " podman/tests" : " tests" ;
95+
96+ script_run " pytest $pytest_args $target .xml $tests /$target |& tee $target .txt" , timeout => $timeout ;
97+ parse_extra_log(' XUnit' , " $target .xml" );
98+ upload_logs(" $target .txt" );
99+ }
100+
101+ sub run {
102+ my ($self , $args ) = @_ ;
103+ $runtime = $args -> {runtime };
104+ $target = $args -> {target };
105+ if ($target eq " setup" ) {
106+ setup;
107+ } else {
108+ test $args -> {target };
109+ }
110+ }
123111
124112sub cleanup () {
113+ # FIXME: We need this
114+ return ;
125115 script_run " kill -9 $socat " ;
126116 script_run " cd / ; rm -rf /root/$runtime -py" ;
127117}
@@ -137,3 +127,5 @@ sub post_run_hook {
137127 cleanup;
138128 $self -> SUPER::post_run_hook;
139129}
130+
131+ 1;
0 commit comments