Skip to content

Commit

Permalink
On 1.7, specifically ignore cf errands (since detection is not reliable)
Browse files Browse the repository at this point in the history
  • Loading branch information
guidowb committed Oct 27, 2016
1 parent 30897b5 commit 0ae5072
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
4 changes: 2 additions & 2 deletions tile_generator/opsmgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ def build_changes_1_7(deploy_errands, delete_errands):
staged = [p for p in get('/api/v0/staged/products').json()]
install = [p for p in staged if p["guid"] not in [g["guid"] for g in deployed]]
delete = [p for p in deployed if p["guid"] not in [g["guid"] for g in staged]]
# update = [p for p in deployed if p["guid"] in [g["guid"] for g in staged]]
update = []
update = [p for p in deployed if p["guid"] in [g["guid"] for g in staged if not g["guid"].startswith('cf-')]]
# update = []
for p in install + update:
manifest = get('/api/v0/staged/products/' + p['guid'] + '/manifest').json()['manifest']
errands = [j['name'] for j in manifest['jobs'] if j['lifecycle'] == 'errand']
Expand Down
47 changes: 34 additions & 13 deletions tile_generator/opsmgr_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,28 @@ def test_default_errands(self, mock_get):
product_changes = opsmgr.get_changes()

changes = product_changes['product_changes']
self.assertEqual(len(changes), 2)
self.assertEqual(len(changes), 3)

update_one = changes[0]
self.assertEqual(update_one['action'], 'install')
update_one = changes[1]
self.assertEqual(update_one['action'], 'update')
self.assertEqual(update_one['guid'], 'service-broker-one-9ed445129ddee5b24bff')

update_one_errands = update_one['errands']
self.assertEqual(len(update_one_errands), 1)
self.assertEqual(update_one_errands[0]['name'], 'deploy-all')
self.assertTrue(update_one_errands[0]['post_deploy'])

update_two = changes[2]
self.assertEqual(update_two['action'], 'update')
self.assertEqual(update_two['guid'], 'tile-two-ed10ef2a821e0e810f2c')

update_two_errands = update_two['errands']
self.assertEqual(len(update_two_errands), 2)
self.assertEqual(update_two_errands[0]['name'], 'deploy-all')
self.assertTrue(update_two_errands[0]['post_deploy'])
self.assertEqual(update_two_errands[1]['name'], 'configure-broker')
self.assertTrue(update_two_errands[1]['post_deploy'])

def test_custom_deploy_errands(self, mock_get):
resp_not_found = requests.Response()
resp_not_found.status_code = 404
Expand All @@ -110,15 +121,20 @@ def test_custom_deploy_errands(self, mock_get):
product_changes = opsmgr.get_changes(deploy_errands= ['deploy-all', 'configure-broker', 'missing'])

changes = product_changes['product_changes']
self.assertEqual(len(changes), 2)
self.assertEqual(len(changes), 3)

update_one = changes[0]
update_one = changes[1]
self.assertEqual(update_one['guid'], 'service-broker-one-9ed445129ddee5b24bff')
self.assertEqual(len(update_one['errands']), 1)
update_one_errands = update_one['errands']
self.assertEqual(len(update_one_errands), 1)
self.assertEqual(update_one_errands[0]['name'], 'deploy-all')
self.assertTrue(update_one_errands[0]['post_deploy'])

update_two = changes[2]
self.assertEqual(update_two['guid'], 'tile-two-ed10ef2a821e0e810f2c')
change_two_errands = update_two['errands']
self.assertEqual(len(change_two_errands), 2)
self.assertEqual(change_two_errands[0]['name'], 'deploy-all')
self.assertTrue(change_two_errands[0]['post_deploy'])
self.assertEqual(change_two_errands[1]['name'], 'configure-broker')
self.assertTrue(change_two_errands[1]['post_deploy'])

def test_default_delete_errands(self, mock_get):
resp_not_found = requests.Response()
Expand All @@ -136,9 +152,9 @@ def test_default_delete_errands(self, mock_get):
product_changes = opsmgr.get_changes()

changes = product_changes['product_changes']
self.assertEqual(len(changes), 2)
self.assertEqual(len(changes), 3)

delete = changes[1]
delete = changes[0]
self.assertEqual(delete['action'], 'delete')
self.assertEqual(delete['guid'], 'deleting-ecb2884a79cf44f5849b')

Expand Down Expand Up @@ -166,9 +182,9 @@ def test_custom_delete_errands(self, mock_get):
)

changes = product_changes['product_changes']
self.assertEqual(len(changes), 2)
self.assertEqual(len(changes), 3)

delete = changes[1]
delete = changes[0]
self.assertEqual(delete['action'], 'delete')
self.assertEqual(delete['guid'], 'deleting-ecb2884a79cf44f5849b')

Expand Down Expand Up @@ -342,6 +358,11 @@ def test_custom_delete_errands(self, mock_get):
"""
api_responses_1_7['deployed_products'] = b"""
[
{
"guid": "service-broker-one-9ed445129ddee5b24bff",
"installation_name": "service-broker-one-9ed445129ddee5b24bff",
"type": "service-broker-one"
},
{
"guid": "tile-two-ed10ef2a821e0e810f2c",
"installation_name": "tile-two-ed10ef2a821e0e810f2c",
Expand Down

0 comments on commit 0ae5072

Please sign in to comment.