Cleanup Secrets created after Order functional tests
Order functional tests create secrets and containers, but do not remove them after testing. This patch makes sure the secrets and containers are removed after an order is. Change-Id: Ie191006acc919a07a79c0ba4b714603ecbe75da3 Closes-Bug: 1490566
This commit is contained in:
parent
3b15b63752
commit
dfb8d5ab93
|
@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
"""
|
||||
from functionaltests.api.v1.behaviors import base_behaviors
|
||||
from functionaltests.api.v1.behaviors import container_behaviors
|
||||
from functionaltests.api.v1.behaviors import secret_behaviors
|
||||
from functionaltests.api.v1.models import order_models
|
||||
|
||||
|
||||
|
@ -127,7 +129,36 @@ class OrderBehaviors(base_behaviors.BaseBehaviors):
|
|||
return resp
|
||||
|
||||
def delete_all_created_orders(self):
|
||||
"""Delete all of the orders that we have created."""
|
||||
"""Delete all orders and other entities created by orders.
|
||||
|
||||
"""
|
||||
container_client = container_behaviors.ContainerBehaviors(self.client)
|
||||
secret_client = secret_behaviors.SecretBehaviors(self.client)
|
||||
|
||||
orders_to_delete = [order for order in self.created_entities]
|
||||
|
||||
for (order_ref, admin) in orders_to_delete:
|
||||
order_resp = self.get_order(order_ref, user_name=admin)
|
||||
|
||||
# If order has secrets
|
||||
if order_resp.model.secret_ref:
|
||||
secret_client.delete_secret(order_resp.model.secret_ref,
|
||||
user_name=admin)
|
||||
|
||||
# If containers supported
|
||||
container_attr_exists = getattr(order_resp.model,
|
||||
"container_ref",
|
||||
None)
|
||||
if container_attr_exists and order_resp.model.container_ref:
|
||||
container_resp = container_client.get_container(
|
||||
order_resp.model.container_ref, user_name=admin)
|
||||
# remove secrets in the containers in the orders
|
||||
if container_resp.model.secret_refs:
|
||||
for secret in container_resp.model.secret_refs:
|
||||
secret_client.delete_secret(secret.secret_ref,
|
||||
user_name=admin)
|
||||
|
||||
container_client.delete_container(
|
||||
order_resp.model.container_ref, user_name=admin)
|
||||
|
||||
self.delete_order(order_ref, user_name=admin)
|
||||
|
|
Loading…
Reference in New Issue