-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: assign region at runtime in e2e tests (#13513)
* build: assign region at runtime in e2e tests * forgot that * use different salt * try this * try that * windows $%@#T%@#%
- Loading branch information
Showing
7 changed files
with
53 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { AWS_REGIONS_TO_RUN_TESTS } from './cci-utils'; | ||
import * as fs from 'fs-extra'; | ||
import path from 'path'; | ||
|
||
/** | ||
* This script prints region assignment for an e2e test job. | ||
* The algorithm takes input via environment variable - CODEBUILD_BATCH_BUILD_IDENTIFIER | ||
* and computes deterministic region assignment by looking at position | ||
* of build job in 'wait_for_ids.json' file. | ||
* In order to reshuffle regions 'offset' constant below should be modified. | ||
* | ||
* If region is already assigned, i.e. CLI_REGION environment variable is set this script is pass-through. | ||
*/ | ||
|
||
// if region is specified by job honor it. | ||
let selectedRegion = process.env.CLI_REGION; | ||
if (!selectedRegion) { | ||
const jobId = process.env.CODEBUILD_BATCH_BUILD_IDENTIFIER; | ||
if (!jobId) { | ||
throw Error('CODEBUILD_BATCH_BUILD_IDENTIFIER environment variable must be set'); | ||
} | ||
// Offset should be changed if we want re-shuffle regions. | ||
const offset = 0; | ||
const waitForIdsFilePath = path.join('.', 'codebuild_specs', 'wait_for_ids.json'); | ||
const jobIds = JSON.parse(fs.readFileSync(waitForIdsFilePath, 'utf-8')) as Array<string>; | ||
let jobPosition = jobIds.indexOf(jobId); | ||
if (jobPosition < 0) { | ||
// this should never happen if PR checks pass, but just in case fall back to first region. | ||
jobPosition = 0; | ||
} | ||
const regionIndex = (jobPosition + offset) % AWS_REGIONS_TO_RUN_TESTS.length; | ||
|
||
selectedRegion = AWS_REGIONS_TO_RUN_TESTS[regionIndex]; | ||
} | ||
|
||
console.log(selectedRegion); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters