33
44import os
55import sys
6- from idp_cli .service .install_service import InstallService
7- from idp_cli .util .codepipeline_util import CodePipelineUtil
6+ from idpcli .service .install_service import InstallService
7+ from idpcli .util .codepipeline_util import CodePipelineUtil
88import typer
9- from idp_cli .service .uninstall_service import UninstallService
10- from idp_cli .service .smoketest_service import SmokeTestService
9+ from idpcli .service .uninstall_service import UninstallService
10+ from idpcli .service .smoketest_service import SmokeTestService
11+ from idpcli .service .smoketest_idp_cli_service import SmokeTestIdpCliService
1112from dotenv import load_dotenv
1213
1314from loguru import logger
@@ -28,7 +29,6 @@ def install(
2829 account_id : str = typer .Option (..., "--account-id" , help = "AWS Account ID" ),
2930 cfn_prefix : str = typer .Option ("idp-dev" , "--cfn-prefix" , help = "An identifier to prefix the stack" ),
3031 admin_email : str = typer .Option (..., "--admin-email" , help = "The admin email" ),
31- idp_pattern : str = typer .Option ("Pattern1 - Packet or Media processing with Bedrock Data Automation (BDA)" , "--idp-pattern" , help = "The IDP Pattern to install" ),
3232 cwd : str = typer .Option ("./" , "--cwd" , help = "Current working directory" ),
3333 debug : bool = typer .Option (False , "--debug" , help = "Enable debug mode" ),
3434 publish : bool = typer .Option (True , "--publish" , help = "Control publishing" ),
@@ -43,27 +43,35 @@ def install(
4343 service .publish ()
4444
4545 if deploy :
46- service .install (admin_email = admin_email , idp_pattern = idp_pattern )
47- typer .echo ("Install Complete!" )
46+ all_patterns_succeeded = service .install (admin_email = admin_email )
47+ if all_patterns_succeeded :
48+ typer .echo ("Install Complete!" )
49+ else :
50+ typer .echo ("Install failed!" , err = True )
51+ sys .exit (1 )
4852
4953
5054@app .command ()
5155def uninstall (
52- stack_name : str = typer .Option (..., "--stack-name" , help = "Name of the stack to uninstall" ),
56+ stack_name_prefix : str = typer .Option (..., "--stack-name-prefix " , help = "Prefix of the stacks to uninstall" ),
5357 account_id : str = typer .Option (..., "--account-id" , help = "AWS Account ID" ),
5458 cfn_prefix : str = typer .Option ("idp-dev" , "--cfn-prefix" , help = "An identifier to prefix the stack" )
5559):
5660 """
5761 Uninstall IDP Accelerator
5862 """
5963 try :
60- typer .echo (f"Uninstalling stack: { stack_name } " )
61-
62- service = UninstallService (stack_name = stack_name , account_id = account_id , cfn_prefix = cfn_prefix )
64+ typer .echo (f"Uninstalling stacks with prefix: { stack_name_prefix } " )
6365
64- service . uninstall ( )
66+ service = UninstallService ( stack_name_prefix = stack_name_prefix , account_id = account_id , cfn_prefix = cfn_prefix )
6567
66- typer .echo ("Uninstall Complete!" )
68+ all_patterns_succeeded = service .uninstall ()
69+
70+ if all_patterns_succeeded :
71+ typer .echo ("Uninstall Complete!" )
72+ else :
73+ typer .echo ("Uninstall failed!" , err = True )
74+ sys .exit (1 )
6775 except Exception as e :
6876 logger .exception (f"Error during uninstall process: { str (e )} " )
6977 typer .echo (f"Uninstall failed: { str (e )} " , err = True )
@@ -72,26 +80,26 @@ def uninstall(
7280
7381@app .command ()
7482def smoketest (
75- stack_name : str = typer .Option ("idp-Stack" , "--stack-name" , help = "Name of the deployed stack to test" ),
83+ stack_name_prefix : str = typer .Option ("idp-Stack" , "--stack-name-prefix " , help = "Prefix of the deployed stacks to test" ),
7684 file_path : str = typer .Option ("../../../samples/lending_package.pdf" , "--file-path" , help = "Path to the test file" ),
7785 verify_string : str = typer .Option ("ANYTOWN, USA 12345" , "--verify-string" , help = "String to verify in the processed output" )
7886):
7987 """
80- Run a smoke test on the deployed IDP Accelerator
88+ Run a smoke test on both deployed IDP patterns
8189 """
8290 try :
83- typer .echo (f"Running smoke test on stack : { stack_name } " )
91+ typer .echo (f"Running smoke test on stacks with prefix : { stack_name_prefix } " )
8492
8593 service = SmokeTestService (
86- stack_name = stack_name ,
94+ stack_name_prefix = stack_name_prefix ,
8795 file_path = file_path ,
8896 verify_string = verify_string
8997 )
9098
9199 result = service .do_smoketest ()
92100
93101 if result :
94- typer .echo ("Smoke test passed successfully!" )
102+ typer .echo ("All smoke tests passed successfully!" )
95103 else :
96104 typer .echo ("Smoke test failed!" , err = True )
97105 sys .exit (1 )
@@ -100,6 +108,38 @@ def smoketest(
100108 typer .echo (f"Smoke test failed: { str (e )} " , err = True )
101109 sys .exit (1 )
102110
111+ @app .command ()
112+ def idp_cli_smoketest (
113+ cfn_prefix : str = typer .Option (..., "--cfn-prefix" , help = "CloudFormation prefix for stack naming" ),
114+ admin_email : str = typer .Option (..., "--admin-email" , help = "Admin email for deployment" ),
115+ account_id : str = typer .Option (..., "--account-id" , help = "AWS account ID" ),
116+ cwd : str = typer .Option ("../../../" , "--cwd" , help = "Working directory path" )
117+ ):
118+ """
119+ End-to-end smoketest: install CLI, deploy stack, run inference, verify results
120+ """
121+ try :
122+ typer .echo (f"Running IDP CLI smoketest with prefix: { cfn_prefix } " )
123+
124+ service = SmokeTestIdpCliService (
125+ cfn_prefix = cfn_prefix ,
126+ admin_email = admin_email ,
127+ account_id = account_id ,
128+ cwd = cwd
129+ )
130+
131+ result = service .do_smoketest ()
132+
133+ if result :
134+ typer .echo ("IDP CLI smoketest passed successfully!" )
135+ else :
136+ typer .echo ("IDP CLI smoketest failed!" , err = True )
137+ sys .exit (1 )
138+ except Exception as e :
139+ logger .exception (f"Error during IDP CLI smoketest: { str (e )} " )
140+ typer .echo (f"IDP CLI smoketest failed: { str (e )} " , err = True )
141+ sys .exit (1 )
142+
103143@app .command ()
104144def monitor_pipeline (
105145 pipeline_name : str = typer .Option (..., "--pipeline-name" , help = "Name of the CodePipeline to monitor" ),
0 commit comments