@@ -24,8 +24,11 @@ def rewrite_variables_overrides(variable_overrides_dict):
24
24
new_args_str = new_variable_overrides [f"PR_POSITIONAL_ARGS" ] = " " .join (new_args )
25
25
new_variable_overrides ["PR_POSITIONAL_ARGS" ] = variable_overrides_dict ["PR_POSITIONAL_ARG_0" ]
26
26
logging .info (f"New args to execute on the jump host: { new_args_str } " )
27
+
28
+ idx = 0
27
29
for idx , value in enumerate (new_args ):
28
30
new_variable_overrides [f"PR_POSITIONAL_ARG_{ idx + 1 } " ] = value
31
+ next_pr_positional_arg_count = idx + 2
29
32
30
33
for k , v in variable_overrides_dict .items ():
31
34
if k .startswith ("PR_POSITIONAL_ARG" ): continue
@@ -44,7 +47,7 @@ def rewrite_variables_overrides(variable_overrides_dict):
44
47
new_variable_overrides [k ] = v
45
48
logging .info (f"Passing '{ k } : { v } ' to the new variables overrides" )
46
49
47
- return new_variable_overrides
50
+ return new_variable_overrides , next_pr_positional_arg_count
48
51
49
52
50
53
def jump_ci (command ):
@@ -72,8 +75,6 @@ def do_jump_ci(cluster=None, project=None, test_args=None):
72
75
TOPSAIL_JUMP_CI = "true" ,
73
76
TOPSAIL_JUMP_CI_INSIDE_JUMP_HOST = "true" ,
74
77
)
75
- if step_dir := os .environ .get ("TOPSAIL_OPENSHIFT_CI_STEP_DIR" ):
76
- extra_env ["TOPSAIL_OPENSHIFT_CI_STEP_DIR" ] = f"{ step_dir } /test-artifacts" # see "jump_ci retrieve_artifacts" below
77
78
78
79
env_pass_lists = config .project .get_config ("env.pass_lists" , print = False )
79
80
@@ -112,51 +113,70 @@ def do_jump_ci(cluster=None, project=None, test_args=None):
112
113
variables_overrides_dict [f"PR_POSITIONAL_ARG_{ idx + 1 } " ] = arg
113
114
114
115
config .project .set_config ("overrides" , variables_overrides_dict )
115
-
116
+ next_pr_positional_arg_count = idx + 2
116
117
else :
117
118
if not os .environ .get ("OPENSHIFT_CI" ) == "true" :
118
119
logging .fatal ("Not running in OpenShift CI. Don't know how to rewrite the variable_overrides_file. Aborting." )
119
120
raise SystemExit (1 )
120
121
121
122
project = config .project .get_config ("overrides.PR_POSITIONAL_ARG_2" )
122
123
123
- variables_overrides_dict = rewrite_variables_overrides (
124
+ variables_overrides_dict , next_pr_positional_arg_count = rewrite_variables_overrides (
124
125
config .project .get_config ("overrides" )
125
126
)
126
127
127
- run .run_toolbox (
128
- "jump_ci" , "prepare_step" ,
129
- cluster = cluster ,
130
- lock_owner = utils .get_lock_owner (),
131
- project = project ,
132
- step = command ,
133
- env_file = env_fd_path ,
134
- variables_overrides_dict = variables_overrides_dict ,
135
- secrets_path_env_key = secrets_path_env_key ,
136
- )
128
+ for idx , multi_run_args in enumerate ((config .project .get_config ("multi_run.args" ) or [...])):
129
+ test_artifacts_dirname = "test-artifacts"
130
+ multi_run_args_dict = {}
131
+ if multi_run_args is not ...:
132
+ test_artifacts_dirname = f"test-artifacts-{ idx :03d} "
133
+ with open (env .ARTIFACTS_DIR / "multi_run_args.list" , "a+" ) as f :
134
+ print (f"{ test_artifacts_dirname } : { multi_run_args } " )
135
+ for idx , multi_run_arg in enumerate ((multi_run_args if isinstance (multi_run_args , list ) else [multi_run_args ])):
136
+ variables_overrides_dict [f"PR_POSITIONAL_ARG_{ next_pr_positional_arg_count + idx } " ] = multi_run_arg
137
+ else :
138
+ test_artifacts_dirname = "test-artifacts"
139
+
140
+ if step_dir := os .environ .get ("TOPSAIL_OPENSHIFT_CI_STEP_DIR" ):
141
+ # see "jump_ci retrieve_artifacts" below
142
+ extra_env ["TOPSAIL_OPENSHIFT_CI_STEP_DIR" ] = f"{ step_dir } /{ test_artifacts_dirname } "
143
+
144
+ run .run_toolbox (
145
+ "jump_ci" , "prepare_step" ,
146
+ cluster = cluster ,
147
+ lock_owner = utils .get_lock_owner (),
148
+ project = project ,
149
+ step = command ,
150
+ env_file = env_fd_path ,
151
+ variables_overrides_dict = (variables_overrides_dict | multi_run_args_dict ),
152
+ secrets_path_env_key = secrets_path_env_key ,
153
+ )
137
154
138
- try :
139
- tunnelling .run_with_ansible_ssh_conf (f"bash { cluster_lock_dir } /test/{ command } /entrypoint.sh" )
140
- logging .info (f"Test step '{ command } ' on cluster '{ cluster } ' succeeded." )
141
- failed = False
142
- except subprocess .CalledProcessError as e :
143
- logging .fatal (f"Test step '{ command } ' on cluster '{ cluster } ' FAILED." )
144
- failed = True
145
- except run .SignalError as e :
146
- logging .error (f"Caught signal { e .sig } . Aborting." )
147
- raise
148
- finally :
149
- # always run the cleanup to be sure that the container doesn't stay running
150
- tunnelling .run_with_ansible_ssh_conf (f"bash { cluster_lock_dir } /test/{ command } /entrypoint.sh cleanup" )
151
-
152
- run .run_toolbox (
153
- "jump_ci" , "retrieve_artifacts" ,
154
- cluster = cluster ,
155
- lock_owner = utils .get_lock_owner (),
156
- remote_dir = f"test/{ command } /artifacts" ,
157
- local_dir = f"../test-artifacts" , # copy to the main artifact directory
158
- mute_stdout = True ,
159
- )
155
+ try :
156
+ tunnelling .run_with_ansible_ssh_conf (f"bash { cluster_lock_dir } /test/{ command } /entrypoint.sh" )
157
+ logging .info (f"Test step '{ command } ' on cluster '{ cluster } ' succeeded." )
158
+ failed = False
159
+ except subprocess .CalledProcessError as e :
160
+ logging .fatal (f"Test step '{ command } ' on cluster '{ cluster } ' FAILED." )
161
+ failed = True
162
+ except run .SignalError as e :
163
+ logging .error (f"Caught signal { e .sig } . Aborting." )
164
+ raise
165
+ finally :
166
+ # always run the cleanup to be sure that the container doesn't stay running
167
+ tunnelling .run_with_ansible_ssh_conf (f"bash { cluster_lock_dir } /test/{ command } /entrypoint.sh cleanup" )
168
+
169
+ run .run_toolbox (
170
+ "jump_ci" , "retrieve_artifacts" ,
171
+ cluster = cluster ,
172
+ lock_owner = utils .get_lock_owner (),
173
+ remote_dir = f"test/{ command } /artifacts" ,
174
+ local_dir = f"../{ test_artifacts_dirname } " , # copy to the main artifact directory
175
+ mute_stdout = True ,
176
+ )
177
+
178
+ if failed and config .project .get_config ("multi_run.stop_on_error" ):
179
+ break
160
180
161
181
jump_ci_artifacts = env .ARTIFACT_DIR / "jump-ci-artifacts"
162
182
jump_ci_artifacts .mkdir (parents = True , exist_ok = True )
0 commit comments