@@ -18,9 +18,9 @@ def __init__(
1818 ipAddress ,
1919 username ,
2020 password ,
21- key ,
2221 configuration ,
23- module ,
22+ key = "" ,
23+ serialNumber = "" ,
2424 version = "3.8" ,
2525 ):
2626 """The init method for Testcontainers."""
@@ -46,8 +46,8 @@ def __init__(
4646 "USERNAME" : username ,
4747 "PASSWORD" : password ,
4848 "KEY" : key ,
49+ "SERIALNUMBER" : serialNumber ,
4950 "CONFIG" : configuration ,
50- "MODULE" : module ,
5151 },
5252 )
5353
@@ -57,10 +57,11 @@ def exec_cmd_stream(self, command):
5757 for data in stream :
5858 print (data .decode (), end = "" )
5959
60- def exec_cmd (self , command ):
60+ def exec_cmd (self , command , verbose = True ):
6161 """Execute a command and validate return code."""
6262 result , output = self .container .exec_run (cmd = command )
63- print (output .decode ())
63+ if verbose :
64+ print (output .decode ())
6465 if result != 0 :
6566 exit (1 )
6667
@@ -76,37 +77,72 @@ def remove(self):
7677 help = "list of Python versions to test with" ,
7778 default = '["3.8", "3.9", "3.10", "3.11", "3.12"]' ,
7879)
79- parser .add_argument ("-c" , "--config " , help = "config of E3DC" , default = "{}" )
80+ parser .add_argument ("-c" , "--configuration " , help = "configuration of E3DC" , default = "{}" )
8081parser .add_argument (
8182 "-m" ,
8283 "--module" ,
83- help = "E3DC module source to use for test" ,
84- choices = ["source" , "default" ],
85- default = "source" ,
84+ help = "specify E3DC module version to be installed for tests. Use local to install from sources" ,
85+ default = "local" ,
8686)
87- requiredNamed = parser .add_argument_group ("required named arguments" )
88- requiredNamed .add_argument (
89- "-i" , "--ipaddress" , help = "IP address of E3DC" , required = True
87+ parser .add_argument (
88+ "-v" ,
89+ "--verbose" ,
90+ action = "store_true" ,
91+ help = "use local E3DC module for test" ,
9092)
93+ requiredNamed = parser .add_argument_group ("required named arguments" )
9194requiredNamed .add_argument ("-u" , "--username" , help = "username of E3DC" , required = True )
9295requiredNamed .add_argument ("-p" , "--password" , help = "password of E3DC" , required = True )
93- requiredNamed .add_argument ("-k" , "--key" , help = "key of E3DC" , required = True )
96+
97+ requiredNamedLocal = parser .add_argument_group (
98+ "required named arguments for local connection"
99+ )
100+ requiredNamedLocal .add_argument ("-i" , "--ipaddress" , help = "IP address of E3DC" )
101+ requiredNamedLocal .add_argument ("-k" , "--key" , help = "rscp key of E3DC" )
102+
103+ requiredNamedWeb = parser .add_argument_group (
104+ "required named arguments for web connection"
105+ )
106+ requiredNamedWeb .add_argument ("-s" , "--serialnumber" , help = "serialnumber of E3DC" )
107+
108+ args = vars (parser .parse_args ())
109+
110+ if args ["serialnumber" ] and (args ["ipaddress" ] or args ["key" ]):
111+ print ("either provide require arguments for web or local connection" )
112+ exit (2 )
113+ elif args ["serialnumber" ] is None and not (args ["ipaddress" ] and args ["key" ]):
114+ print ("for local connection ipaddress and key are required" )
115+ exit (2 )
116+
94117args = vars (parser .parse_args ())
95118
96119for version in json .loads (args ["list" ]):
97- print ("Starting test on Python " + version + ":" )
120+ if args ["verbose" ]:
121+ print ("Starting test on Python " + version + ":" )
98122 testcontainers = Testcontainers (
99123 ipAddress = args ["ipaddress" ],
100124 username = args ["username" ],
101125 password = args ["password" ],
102126 key = args ["key" ],
103- configuration = args ["config " ],
104- module = args ["module " ],
127+ configuration = args ["configuration " ],
128+ serialNumber = args ["serialnumber " ],
105129 version = version ,
106130 )
107- testcontainers .exec_cmd ("pip install ." )
108- testcontainers .exec_cmd (
109- "sh -c 'python tools/tests.py -i $IPADDRESS -u $USERNAME -p $PASSWORD -k $KEY -c $CONFIG -m $MODULE'"
110- )
131+ cmd = "sh -c 'python tools/tests.py -u $USERNAME -p $PASSWORD -c $CONFIG"
132+ if args ["module" ] == "local" :
133+ testcontainers .exec_cmd ("pip install ." , args ["verbose" ])
134+ else :
135+ testcontainers .exec_cmd (
136+ "pip install pye3dc=={}" .format (args ["module" ]), args ["verbose" ]
137+ )
138+ cmd = cmd + " -m"
139+ if args ["key" ]:
140+ cmd = cmd + " -i $IPADDRESS -k $KEY"
141+ else :
142+ cmd = cmd + " -s $SERIALNUMBER"
143+ if args ["verbose" ]:
144+ cmd = cmd + " -v'"
145+ else :
146+ cmd = cmd + "'"
147+ testcontainers .exec_cmd (cmd )
111148 testcontainers .remove ()
112- print ()
0 commit comments