From b5707f8cc4698f99c215f2ef2ff43f9c0cb0d159 Mon Sep 17 00:00:00 2001 From: Sam Liu Date: Mon, 19 Jul 2021 15:52:53 -0700 Subject: [PATCH] Make stage name randomized to avoid race condition among multi canary runs --- tests/integration/pipeline/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/integration/pipeline/base.py b/tests/integration/pipeline/base.py index adb0e628e1..f82d27e357 100644 --- a/tests/integration/pipeline/base.py +++ b/tests/integration/pipeline/base.py @@ -1,6 +1,7 @@ import os import shutil import logging +import uuid from pathlib import Path from typing import List, Optional, Set, Tuple, Any from unittest import TestCase @@ -54,10 +55,12 @@ class BootstrapIntegBase(PipelineBase): region = "us-east-1" stack_names: List[str] cf_client: Any + randomized_stage_suffix: str @classmethod def setUpClass(cls): cls.cf_client = boto3.client("cloudformation", region_name=cls.region) + cls.randomized_stage_suffix = uuid.uuid4().hex[-6:] def setUp(self): self.stack_names = [] @@ -142,7 +145,7 @@ def _stack_exists(self, stack_name) -> bool: def _get_stage_and_stack_name(self, suffix: str = "") -> Tuple[str, str]: # Method expects method name which can be a full path. Eg: test.integration.test_bootstrap_command.method_name method_name = self.id().split(".")[-1] - stage_name = method_name.replace("_", "-") + suffix + stage_name = method_name.replace("_", "-") + suffix + "-" + self.randomized_stage_suffix mock_env = Mock() mock_env.name = stage_name