Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit e54f00f

Browse files
author
earthmant
committed
adding tests
1 parent b54c441 commit e54f00f

4 files changed

Lines changed: 121 additions & 40 deletions

File tree

.circleci/config.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
command: pip install cloudify==4.3.2
4040
- run:
4141
name: install test requirements
42-
command: pip install nose https://github.com/cloudify-cosmo/cloudify-fabric-plugin/archive/1.5.1.zip https://github.com/cloudify-incubator/cloudify-utilities-plugin/archive/1.7.1.zip https://github.com/cloudify-incubator/cloudify-ecosystem-test/archive/2.0.zip
42+
command: pip install nose https://github.com/cloudify-incubator/cloudify-awssdk-plugin/archive/2.3.4.zip https://github.com/cloudify-cosmo/cloudify-fabric-plugin/archive/1.5.1.zip https://github.com/cloudify-incubator/cloudify-utilities-plugin/archive/1.7.1.zip https://github.com/cloudify-incubator/cloudify-ecosystem-test/archive/2.0.zip
4343
- run:
4444
name: execute test
4545
command: nosetests -s tests/test_env.py:TestAWS
@@ -72,7 +72,7 @@ jobs:
7272
command: pip install cloudify==4.3.2
7373
- run:
7474
name: install test requirements
75-
command: pip install nose https://github.com/cloudify-cosmo/cloudify-fabric-plugin/archive/1.5.1.zip https://github.com/cloudify-incubator/cloudify-utilities-plugin/archive/1.7.1.zip https://github.com/cloudify-incubator/cloudify-ecosystem-test/archive/2.0.zip
75+
command: pip install nose https://github.com/cloudify-incubator/cloudify-azure-plugin/archive/1.7.2.zip https://github.com/cloudify-cosmo/cloudify-fabric-plugin/archive/1.5.1.zip https://github.com/cloudify-incubator/cloudify-utilities-plugin/archive/1.7.1.zip https://github.com/cloudify-incubator/cloudify-ecosystem-test/archive/2.0.zip
7676
- run:
7777
name: execute test
7878
command: nosetests -s tests/test_env.py:TestAzure
@@ -105,7 +105,7 @@ jobs:
105105
command: pip install cloudify==4.3.2
106106
- run:
107107
name: install test requirements
108-
command: pip install nose https://github.com/cloudify-cosmo/cloudify-fabric-plugin/archive/1.5.1.zip https://github.com/cloudify-incubator/cloudify-utilities-plugin/archive/1.7.1.zip https://github.com/cloudify-incubator/cloudify-ecosystem-test/archive/2.0.zip
108+
command: pip install nose https://github.com/cloudify-cosmo/cloudify-gcp-plugin/archive/1.4.3.zip https://github.com/cloudify-cosmo/cloudify-fabric-plugin/archive/1.5.1.zip https://github.com/cloudify-incubator/cloudify-utilities-plugin/archive/1.7.1.zip https://github.com/cloudify-incubator/cloudify-ecosystem-test/archive/2.0.zip
109109
- run:
110110
name: execute test
111111
command: nosetests -s tests/test_env.py:TestGCP
@@ -115,17 +115,17 @@ workflows:
115115
tests:
116116
jobs:
117117
- azure:
118-
context: ecosystem
119-
filters:
120-
branches:
121-
only: /([0-9\.]*\-build|latest|dev)/
118+
context: ecosystem
119+
filters:
120+
branches:
121+
only: /([0-9\.]*\-build|latest|dev)/
122122
- aws:
123-
context: ecosystem
124-
filters:
125-
branches:
126-
only: /([0-9\.]*\-build|latest|dev)/
123+
context: ecosystem
124+
filters:
125+
branches:
126+
only: /([0-9\.]*\-build|latest|dev)/
127127
- gcp:
128-
context: ecosystem
129-
filters:
130-
branches:
131-
only: /([0-9\.]*\-build|latest|dev)/
128+
context: ecosystem
129+
filters:
130+
branches:
131+
only: /([0-9\.]*\-build|latest|dev)/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
23
# Cloudify Environment Setup
34

45
To ask a question or report an issue, please visit the [Cloudify users groups](https://groups.google.com/forum/#!forum/cloudify-users) or report an issue using [github issues](https://github.com/cloudify-examples/cloudify-environment-setup/issues).

azure.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ tosca_definitions_version: cloudify_dsl_1_3
22

33
imports:
44
- http://www.getcloudify.org/spec/cloudify/4.3.2/types.yaml
5-
- http://www.getcloudify.org/spec/azure-plugin/1.7.2/plugin.yaml
5+
- http://www.getcloudify.org/spec/azure-plugin/1.7.3/plugin.yaml
66
- http://www.getcloudify.org/spec/utilities-plugin/1.8.2/plugin.yaml
77
- http://www.getcloudify.org/spec/fabric-plugin/1.5.1/plugin.yaml
88
- imports/manager-configuration.yaml

tests/test_env.py

Lines changed: 104 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
11
# Built-in Imports
22
import os
3+
import sys
34

45
# Cloudify Imports
56
from ecosystem_tests import (
7+
PasswordFilter,
68
EcosystemTestBase,
79
utils as eco_utils)
810

911

1012
class 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):
103124
class 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

218264
class 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

Comments
 (0)