11# Built-in Imports
22import os
3+ import sys
34
45# Cloudify Imports
56from ecosystem_tests import (
7+ PasswordFilter ,
68 EcosystemTestBase ,
79 utils as eco_utils )
810
911
1012class TestAWS (EcosystemTestBase ):
1113
1214 def setUp (self ):
15+ if self .password not in self .sensitive_data :
16+ self .sensitive_data .append (self .password )
17+ sys .stdout = PasswordFilter (self .sensitive_data , sys .stdout )
18+ sys .stderr = PasswordFilter (self .sensitive_data , sys .stderr )
19+ self .cfy_local = self .setup_cfy_local ()
1320 os .environ ['AWS_DEFAULT_REGION' ] = self .inputs .get ('ec2_region_name' )
14- super (TestAWS , self ).setUp ()
21+ if 'ECOSYSTEM_SESSION_MANAGER_IP' in os .environ :
22+ self .manager_ip = \
23+ os .environ ['ECOSYSTEM_SESSION_MANAGER_IP' ]
24+ else :
25+ self .install_manager ()
26+ self .initialize_manager_profile ()
27+
28+ @property
29+ def node_type_prefix (self ):
30+ return 'cloudify.nodes.aws'
31+
32+ @property
33+ def plugin_mapping (self ):
34+ return 'awssdk'
1535
1636 @property
1737 def blueprint_file_name (self ):
@@ -74,17 +94,18 @@ def secrets_to_check(self):
7494
7595 def test_secrets (self ):
7696 for secret in self .secrets_to_check :
77- self .assertNotNone (eco_utils .get_secrets (secret ))
97+ self .assertIsNotNone (eco_utils .get_secrets (secret ))
7898
7999 def test_blueprints (self ):
80100 for blueprint in self .blueprints_to_check :
81- self .assertEqual (
82- 0 ,
101+ try :
83102 eco_utils .get_client_response (
84103 'blueprints' ,
85104 'get' ,
86105 {'blueprint_id' : blueprint })
87- )
106+ except :
107+ self .fail (
108+ 'Blueprint {0} does not exist' .format (blueprint ))
88109
89110 def test_network_deployment (self ):
90111 self .addCleanup (self .cleanup_deployment , 'aws-example-network' )
@@ -103,19 +124,37 @@ def test_network_deployment(self):
103124class TestAzure (EcosystemTestBase ):
104125
105126 def setUp (self ):
106- super (TestAzure , self ).setUp ()
127+ if self .password not in self .sensitive_data :
128+ self .sensitive_data .append (self .password )
129+ sys .stdout = PasswordFilter (self .sensitive_data , sys .stdout )
130+ sys .stderr = PasswordFilter (self .sensitive_data , sys .stderr )
131+ self .cfy_local = self .setup_cfy_local ()
132+ if 'ECOSYSTEM_SESSION_MANAGER_IP' in os .environ :
133+ self .manager_ip = \
134+ os .environ ['ECOSYSTEM_SESSION_MANAGER_IP' ]
135+ else :
136+ self .install_manager ()
137+ self .initialize_manager_profile ()
138+
139+ @property
140+ def node_type_prefix (self ):
141+ return 'cloudify.azure.nodes'
142+
143+ @property
144+ def plugin_mapping (self ):
145+ return 'pkg'
107146
108147 @property
109148 def blueprint_file_name (self ):
110149 return 'azure.yaml'
111150
112151 @property
113152 def external_id_key (self ):
114- return 'name '
153+ return 'public_ip '
115154
116155 @property
117156 def server_ip_property (self ):
118- return 'ip '
157+ return 'cloudify_host '
119158
120159 @property
121160 def sensitive_data (self ):
@@ -132,7 +171,7 @@ def inputs(self):
132171 return {
133172 'password' : self .password ,
134173 'location' : 'westus' ,
135- 'resource_prefix' : 'trammell ' ,
174+ 'resource_prefix' : 'ecotest ' ,
136175 'resource_suffix' : self .application_prefix ,
137176 'subscription_id' : os .environ ['AZURE_SUB_ID' ],
138177 'tenant_id' : os .environ ['AZURE_TEN_ID' ],
@@ -190,7 +229,13 @@ def secrets_to_check(self):
190229 def test_network_deployment (self ):
191230 self .addCleanup (self .cleanup_deployment , 'azure-example-network' )
192231 # Create Deployment (Blueprint already uploaded.)
193- if eco_utils .create_deployment ('azure-example-network' ):
232+ _inputs = {
233+ 'resource_prefix' : 'ecotestnet' ,
234+ 'resource_suffix' : self .application_prefix
235+ }
236+ if eco_utils .create_deployment (
237+ 'azure-example-network' ,
238+ inputs = _inputs ):
194239 raise Exception (
195240 'Deployment azure-example-network failed.' )
196241 # Install Deployment.
@@ -202,35 +247,54 @@ def test_network_deployment(self):
202247
203248 def test_blueprints (self ):
204249 for blueprint in self .blueprints_to_check :
205- self .assertEqual (
206- 0 ,
250+ try :
207251 eco_utils .get_client_response (
208252 'blueprints' ,
209253 'get' ,
210254 {'blueprint_id' : blueprint })
211- )
255+ except :
256+ self .fail (
257+ 'Blueprint {0} does not exist' .format (blueprint ))
212258
213259 def test_secrets (self ):
214260 for secret in self .secrets_to_check :
215- self .assertNotNone (eco_utils .get_secrets (secret ))
261+ self .assertIsNotNone (eco_utils .get_secrets (secret ))
216262
217263
218264class TestGCP (EcosystemTestBase ):
219265
220266 def setUp (self ):
221- super (TestGCP , self ).setUp ()
267+ if self .password not in self .sensitive_data :
268+ self .sensitive_data .append (self .password )
269+ sys .stdout = PasswordFilter (self .sensitive_data , sys .stdout )
270+ sys .stderr = PasswordFilter (self .sensitive_data , sys .stderr )
271+ self .cfy_local = self .setup_cfy_local ()
272+ if 'ECOSYSTEM_SESSION_MANAGER_IP' in os .environ :
273+ self .manager_ip = \
274+ os .environ ['ECOSYSTEM_SESSION_MANAGER_IP' ]
275+ else :
276+ self .install_manager ()
277+ self .initialize_manager_profile ()
278+
279+ @property
280+ def node_type_prefix (self ):
281+ return 'cloudify.gcp.nodes'
282+
283+ @property
284+ def plugin_mapping (self ):
285+ return 'gcp_plugin'
222286
223287 @property
224288 def blueprint_file_name (self ):
225289 return 'gcp.yaml'
226290
227291 @property
228292 def external_id_key (self ):
229- return 'name '
293+ return 'natIP '
230294
231295 @property
232296 def server_ip_property (self ):
233- return 'ip '
297+ return 'cloudify_host '
234298
235299 @property
236300 def sensitive_data (self ):
@@ -240,7 +304,7 @@ def sensitive_data(self):
240304 os .environ ['GCP_CLIENT_ID' ],
241305 os .environ ['GCP_PRIVATE_PROJECT_ID' ],
242306 os .environ ['GCP_PRIVATE_KEY_ID' ],
243- os .environ ['GCP_PRIVATE_KEY' ]
307+ os .environ ['GCP_PRIVATE_KEY' ]. decode ( 'string_escape' )
244308 ]
245309
246310 @property
@@ -256,7 +320,8 @@ def inputs(self):
256320 'client_id' : os .environ ['GCP_CLIENT_ID' ],
257321 'project_id' : os .environ ['GCP_PRIVATE_PROJECT_ID' ],
258322 'private_key_id' : os .environ ['GCP_PRIVATE_KEY_ID' ],
259- 'private_key' : os .environ ['GCP_PRIVATE_KEY' ],
323+ 'private_key' :
324+ os .environ ['GCP_PRIVATE_KEY' ].decode ('string_escape' ),
260325 }
261326 except KeyError :
262327 raise
@@ -299,24 +364,39 @@ def secrets_to_check(self):
299364 'client_x509_cert_url'
300365 ]
301366
367+ def get_manager_ip (self ):
368+ for instance in self .node_instances :
369+ if instance .node_id == self .server_ip_property :
370+ props = instance .runtime_properties
371+ nic = props ['networkInterfaces' ][0 ]
372+ return nic ['accessConfigs' ][0 ][self .external_id_key ]
373+ raise Exception ('No manager IP found.' )
374+
302375 def test_blueprints (self ):
303376 for blueprint in self .blueprints_to_check :
304- self .assertEqual (
305- 0 ,
377+ try :
306378 eco_utils .get_client_response (
307379 'blueprints' ,
308380 'get' ,
309381 {'blueprint_id' : blueprint })
310- )
382+ except :
383+ self .fail (
384+ 'Blueprint {0} does not exist' .format (blueprint ))
311385
312386 def test_secrets (self ):
313387 for secret in self .secrets_to_check :
314- self .assertNotNone (eco_utils .get_secrets (secret ))
388+ self .assertIsNotNone (eco_utils .get_secrets (secret ))
315389
316390 def test_network_deployment (self ):
391+ _inputs = {
392+ 'resource_prefix' : 'ecotestnet' ,
393+ 'resource_suffix' : self .application_prefix
394+ }
317395 self .addCleanup (self .cleanup_deployment , 'gcp-example-network' )
318396 # Create Deployment (Blueprint already uploaded.)
319- if eco_utils .create_deployment ('gcp-example-network' ):
397+ if eco_utils .create_deployment (
398+ 'gcp-example-network' ,
399+ inputs = _inputs ):
320400 raise Exception (
321401 'Deployment gcp-example-network failed.' )
322402 # Install Deployment.
0 commit comments