Fix races in SoftwareDeploymentGroupTest

Don't assume that we can get the physical IDs of all of the
SoftwareDeployment resources as soon as the stack becomes
CREATE_IN_PROGRESS. 4dd67bb1aa2df4f5270f79600ac1f888b0bd9a5f reads them
again once the stack is COMPLETE; this patch also uses the same physical
resource IDs to verify the update.

Also, make sure all of the resources are IN_PROGRESS before trying to
signal them, because the signal_resources() utility method only signals
resources that are IN_PROGRESS.

Change-Id: I9787a5de5e4272a3ab370f653182aa9283ae01c0
Closes-Bug: #1697794
Closes-Bug: #1626073
Closes-Bug: #1625921
diff --git a/functional/test_software_deployment_group.py b/functional/test_software_deployment_group.py
index 06f0ce1..22143dc 100644
--- a/functional/test_software_deployment_group.py
+++ b/functional/test_software_deployment_group.py
@@ -84,8 +84,14 @@
             expected_status='CREATE_IN_PROGRESS')
         self._wait_for_resource_status(
             stack_identifier, 'deployment', 'CREATE_IN_PROGRESS')
+
+        # Wait for all deployment resources to become IN_PROGRESS, since only
+        # IN_PROGRESS resources get signalled
         nested_identifier = self.assert_resource_is_a_stack(
             stack_identifier, 'deployment')
+        self._wait_for_stack_status(nested_identifier, 'CREATE_IN_PROGRESS')
+        self._wait_for_all_resource_status(nested_identifier,
+                                           'CREATE_IN_PROGRESS')
         group_resources = self.list_group_resources(
             stack_identifier, 'deployment', minimal=False)
 
@@ -96,9 +102,8 @@
 
         created_group_resources = self.list_group_resources(
             stack_identifier, 'deployment', minimal=False)
-
-        self.check_input_values(created_group_resources,
-                                'foo', 'foo_input')
+        self.assertEqual(4, len(created_group_resources))
+        self.check_input_values(created_group_resources, 'foo', 'foo_input')
 
         self.update_stack(stack_identifier,
                           template=template,
@@ -106,12 +111,11 @@
                           expected_status='UPDATE_IN_PROGRESS')
         nested_identifier = self.assert_resource_is_a_stack(
             stack_identifier, 'deployment')
-        self.assertEqual(4, len(group_resources))
         self._wait_for_stack_status(stack_identifier, 'UPDATE_COMPLETE',
                                     signal_required=True,
                                     resources_to_signal=group_resources)
 
-        self.check_input_values(group_resources, 'foo', 'input2')
+        self.check_input_values(created_group_resources, 'foo', 'input2')
 
         # We explicitly test delete here, vs just via cleanup and check
         # the nested stack is gone