@@ -91,7 +91,8 @@ def _deploy_app_prod(project,
9191 deployment_bucket ,
9292 yaml_paths ,
9393 package_zip_paths ,
94- deploy_appengine = True ):
94+ deploy_appengine = True ,
95+ test_deployment = False ):
9596 """Deploy app in production."""
9697 if deploy_appengine :
9798 services = _get_services (yaml_paths )
@@ -109,9 +110,13 @@ def _deploy_app_prod(project,
109110
110111 if package_zip_paths :
111112 for package_zip_path in package_zip_paths :
112- _deploy_zip (deployment_bucket , package_zip_path )
113+ _deploy_zip (
114+ deployment_bucket , package_zip_path , test_deployment = test_deployment )
113115
114- _deploy_manifest (deployment_bucket , constants .PACKAGE_TARGET_MANIFEST_PATH )
116+ _deploy_manifest (
117+ deployment_bucket ,
118+ constants .PACKAGE_TARGET_MANIFEST_PATH ,
119+ test_deployment = test_deployment )
115120
116121
117122def _deploy_app_staging (project , yaml_paths ):
@@ -212,22 +217,31 @@ def find_file_exceeding_limit(path, limit):
212217 return None
213218
214219
215- def _deploy_zip (bucket_name , zip_path ):
220+ def _deploy_zip (bucket_name , zip_path , test_deployment = False ):
216221 """Deploy zip to GCS."""
217- common .execute ('gsutil cp %s gs://%s/%s' % (zip_path , bucket_name ,
218- os .path .basename (zip_path )))
222+ if test_deployment :
223+ common .execute (f'gsutil cp { zip_path } gs://{ bucket_name } /test-deployment/'
224+ f'{ os .path .basename (zip_path )} ' )
225+ else :
226+ common .execute ('gsutil cp %s gs://%s/%s' % (zip_path , bucket_name ,
227+ os .path .basename (zip_path )))
219228
220229
221- def _deploy_manifest (bucket_name , manifest_path ):
230+ def _deploy_manifest (bucket_name , manifest_path , test_deployment = False ):
222231 """Deploy source manifest to GCS."""
223232 if sys .version_info .major == 3 :
224233 manifest_suffix = '.3'
225234 else :
226235 manifest_suffix = ''
227236
228- common .execute ('gsutil cp %s '
229- 'gs://%s/clusterfuzz-source.manifest%s' %
230- (manifest_path , bucket_name , manifest_suffix ))
237+ if test_deployment :
238+ common .execute (f'gsutil cp { manifest_path } '
239+ f'gs://{ bucket_name } /test-deployment/'
240+ f'clusterfuzz-source.manifest{ manifest_suffix } ' )
241+ else :
242+ common .execute (f'gsutil cp { manifest_path } '
243+ f'gs://{ bucket_name } /'
244+ f'clusterfuzz-source.manifest{ manifest_suffix } ' )
231245
232246
233247def _update_deployment_manager (project , name , config_path ):
@@ -385,7 +399,8 @@ def _prod_deployment_helper(config_dir,
385399 package_zip_paths ,
386400 deploy_appengine = True ,
387401 deploy_k8s = True ,
388- python3 = True ):
402+ python3 = True ,
403+ test_deployment = False ):
389404 """Helper for production deployment."""
390405 config = local_config .Config ()
391406 deployment_bucket = config .get ('project.deployment.bucket' )
@@ -415,11 +430,12 @@ def _prod_deployment_helper(config_dir,
415430 deployment_bucket ,
416431 yaml_paths ,
417432 package_zip_paths ,
418- deploy_appengine = deploy_appengine )
433+ deploy_appengine = deploy_appengine ,
434+ test_deployment = test_deployment )
419435
420436 if deploy_appengine :
421- common .execute ('python butler.py run setup --config-dir {config_dir} '
422- ' --non-dry-run'. format ( config_dir = config_dir ) )
437+ common .execute (
438+ f'python butler.py run setup --config-dir { config_dir } --non-dry-run' )
423439
424440 if deploy_k8s :
425441 _deploy_terraform (config_dir )
@@ -515,6 +531,12 @@ def execute(args):
515531 deploy_zips = 'zips' in args .targets
516532 deploy_appengine = 'appengine' in args .targets
517533 deploy_k8s = 'k8s' in args .targets
534+ test_deployment = 'test_deployment' in args .targets
535+
536+ if test_deployment :
537+ deploy_appengine = False
538+ deploy_k8s = False
539+ deploy_zips = True
518540
519541 is_python3 = sys .version_info .major == 3
520542 package_zip_paths = []
@@ -546,7 +568,8 @@ def execute(args):
546568 package_zip_paths ,
547569 deploy_appengine ,
548570 deploy_k8s ,
549- python3 = is_python3 )
571+ python3 = is_python3 ,
572+ test_deployment = test_deployment )
550573
551574 with open (constants .PACKAGE_TARGET_MANIFEST_PATH ) as f :
552575 print ('Source updated to %s' % f .read ())
0 commit comments