Handle replace and rollback cases for Port
Add prepare_for_replace and restore_after_rollback methods for port
resource. Now if port has fixed_ip address it will be correctly handled
during UpdateReplace, i.e. we detach this ip and store it in self.data.
In case, when rollback happens, fixed_ips data will be taken from
self.data of resource in _backup_stack.
Follow functional tests was added:
- enable test with simple replacing port
- test for failed update with rollback
- test for failed update without rollback and second repair update
implements bp rich-network-prop
Change-Id: Id3877ed8cb1097f6c93725806d137ea67ab07466
Closes-Bug: #1455100
diff --git a/functional/test_create_update_neutron_port.py b/functional/test_create_update_neutron_port.py
index 4b2df59..575d21c 100644
--- a/functional/test_create_update_neutron_port.py
+++ b/functional/test_create_update_neutron_port.py
@@ -10,8 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from testtools import testcase
-
from heat_integrationtests.functional import functional_base
@@ -38,6 +36,12 @@
fixed_ips:
- subnet: {get_resource: subnet}
ip_address: 11.11.11.11
+ test:
+ depends_on: port
+ type: OS::Heat::TestResource
+ properties:
+ value: Test1
+ fail: False
outputs:
port_ip:
value: {get_attr: [port, fixed_ips, 0, ip_address]}
@@ -73,7 +77,6 @@
self.assertNotEqual(_ip, new_ip)
self.assertNotEqual(_id, new_id)
- @testcase.skip('Skipped until bug #1455100 is fixed.')
def test_stack_update_replace_with_ip(self):
# create with default 'mac' parameter
stack_identifier = self.stack_create(template=test_template)
@@ -92,6 +95,62 @@
self.assertEqual(_ip, new_ip)
self.assertNotEqual(_id, new_id)
+ def test_stack_update_replace_with_ip_rollback(self):
+ # create with default 'mac' parameter
+ stack_identifier = self.stack_create(template=test_template)
+
+ _id, _ip = self.get_port_id_and_ip(stack_identifier)
+
+ # Update with another 'mac' parameter
+ parameters = {'mac': '00-00-00-00-AA-AA'}
+
+ # make test resource failing during update
+ fail_template = test_template.replace('fail: False',
+ 'fail: True')
+ fail_template = fail_template.replace('value: Test1',
+ 'value: Rollback')
+
+ # port should be replaced with same ip
+ self.update_stack(stack_identifier, fail_template,
+ parameters=parameters,
+ expected_status='ROLLBACK_COMPLETE',
+ disable_rollback=False)
+
+ new_id, new_ip = self.get_port_id_and_ip(stack_identifier)
+ # port id and ip should be the same after rollback
+ self.assertEqual(_ip, new_ip)
+ self.assertEqual(_id, new_id)
+
+ def test_stack_update_replace_with_ip_after_failed_update(self):
+ # create with default 'mac' parameter
+ stack_identifier = self.stack_create(template=test_template)
+
+ _id, _ip = self.get_port_id_and_ip(stack_identifier)
+
+ # Update with another 'mac' parameter
+ parameters = {'mac': '00-00-00-00-AA-AA'}
+
+ # make test resource failing during update
+ fail_template = test_template.replace('fail: False',
+ 'fail: True')
+ fail_template = fail_template.replace('value: Test1',
+ 'value: Rollback')
+
+ # port should be replaced with same ip
+ self.update_stack(stack_identifier, fail_template,
+ parameters=parameters,
+ expected_status='UPDATE_FAILED')
+
+ # port should be replaced with same ip
+ self.update_stack(stack_identifier, test_template,
+ parameters=parameters)
+
+ new_id, new_ip = self.get_port_id_and_ip(stack_identifier)
+ # ip should be the same, but port id should be different, because it's
+ # restore replace
+ self.assertEqual(_ip, new_ip)
+ self.assertNotEqual(_id, new_id)
+
def test_stack_update_in_place_remove_ip(self):
# create with default 'mac' parameter and defined ip_address
stack_identifier = self.stack_create(template=test_template)