Skip to content

Commit

Permalink
Make stage name randomized to avoid race condition among multi canary…
Browse files Browse the repository at this point in the history
… runs (#3078)
  • Loading branch information
aahung authored Jul 19, 2021
1 parent cebae87 commit 07fcdea
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/integration/pipeline/base.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 07fcdea

Please sign in to comment.