@@ -18,11 +18,15 @@ def __init__(
18
18
* ,
19
19
client : docker .DockerClient ,
20
20
container_name : str ,
21
- output_path : pathlib .Path ,
21
+ workdir : pathlib .Path ,
22
+ output_file_name : pathlib .Path ,
23
+ commands_file_name : pathlib .Path ,
22
24
) -> None :
23
25
self ._client = client
24
26
self ._container_name = container_name
25
- self ._output_path = output_path
27
+ self ._workdir = workdir
28
+ self ._output_file_name = output_file_name
29
+ self ._commands_file_name = commands_file_name
26
30
27
31
@property
28
32
def container (self ) -> Container :
@@ -34,20 +38,32 @@ def stop(self) -> None:
34
38
def wait_for_complete (self ) -> None :
35
39
try :
36
40
logger .info ("Waiting for container to complete" )
37
- self .container .wait ()
41
+ _ , output = self .container .exec_run (
42
+ f"parallel --jobs 16 --bar -a { self ._commands_file_name .as_posix ()} " ,
43
+ tty = True ,
44
+ stream = True ,
45
+ user = "testssl_user" ,
46
+ workdir = self ._workdir .as_posix (),
47
+ )
48
+ for line in output :
49
+ logger .info (line .decode ("utf-8" ).strip ())
50
+ logger .info ("Finished executing commands" )
38
51
except requests .exceptions .ReadTimeout :
39
52
logger .error ("Container timeout" )
40
53
self .container .kill ()
41
54
42
55
def get_json (self ) -> list [TestSSLRecord ]:
43
- tar_gz , _ = self .container .get_archive (self ._output_path , encode_stream = True )
56
+ logger .info (self ._workdir / self ._output_file_name .name )
57
+ tar_gz , _ = self .container .get_archive (
58
+ self ._workdir / self ._output_file_name .name , encode_stream = True
59
+ )
44
60
45
61
with tarfile .open (
46
62
fileobj = io .BytesIO (b"" .join (tar_gz )),
47
63
mode = "r" ,
48
64
) as tar :
49
65
try :
50
- if _file := tar .extractfile (self ._output_path .name ):
66
+ if _file := tar .extractfile (self ._output_file_name .name ):
51
67
json_bytes = _file .read ()
52
68
else :
53
69
raise KeyError
0 commit comments