Skip to content

Commit

Permalink
Integration test fix for branch merges (#78)
Browse files Browse the repository at this point in the history
* # This is a combination of 99 commits.
# This is the 1st commit message:

Adding docker test base image

# This is the commit message #2:

Adding test files

# This is the commit message #3:

testing

# This is the commit message #4:

Added folder

# This is the commit message #5:

Added folder

# This is the commit message #6:

Azure Devops CI Build Pipeline (#67)

* Adding azure devops build pipeline

* Adding README

* Adding azure build badge

# This is the commit message #7:

saving latest tests

# This is the commit message #8:

Adding docker test base image (#68)


# This is the commit message #9:

EOD checkin

# This is the commit message #10:

posting latest

# This is the commit message #11:

eod commits

# This is the commit message #12:

eod commit

# This is the commit message #13:

refactored test directory structure

# This is the commit message #14:

Refactored build

# This is the commit message #15:

Adding hello world azure simple app

# This is the commit message #16:

Adding hello world azure simple app

# This is the commit message #17:

refactoring test harness

# This is the commit message #18:

refactoring test harness

# This is the commit message #19:

checking latest

# This is the commit message #20:

committing latest

# This is the commit message #21:

checking in latest changes

# This is the commit message #22:

Checking in latest progress

# This is the commit message #23:

applying final touches before PR submission

# This is the commit message #24:

updating azure keyvault secret names

# This is the commit message #25:

Checking in latest progress

# This is the commit message #26:

pushing latest pipeline definition

# This is the commit message #27:

updating build pipeline variable format

# This is the commit message #28:

updating build pipeline variable format

# This is the commit message #29:

cleaning up build variables

# This is the commit message #30:

adding minor changes to azure build pipeline

# This is the commit message #31:

updating azure keyvault secret names

# This is the commit message #32:

updating azure keyvault secret names

# This is the commit message #33:

fixing docker login azdo step

# This is the commit message #34:

fixing docker login azdo step

# This is the commit message #35:

fixing docker login azdo step

# This is the commit message #36:

fixing docker login azdo step

# This is the commit message #37:

updating build pipeline variables

# This is the commit message #38:

updating build pipeline variables

# This is the commit message #39:

updating build pipeline variables

# This is the commit message #40:

updating build pipeline variables

# This is the commit message #41:

updating build pipeline variables

# This is the commit message #42:

updating build pipeline variables

# This is the commit message #43:

applying fix to git diff script

# This is the commit message #44:

applying fix to git diff script

# This is the commit message #45:

applying fix to git diff script

# This is the commit message #46:

applying fix to git diff script

# This is the commit message #47:

applying fix to git diff script

# This is the commit message #48:

resolving pipeline bug

# This is the commit message #49:

fixing build error

# This is the commit message #50:

fixing build error

# This is the commit message #51:

fixing build error

# This is the commit message #52:

fixing build error

# This is the commit message #53:

fixing build error

# This is the commit message #54:

fixing build error

# This is the commit message #55:

fixing build error

# This is the commit message #56:

fixing build error

# This is the commit message #57:

fixing build error

# This is the commit message #58:

fixing build error

# This is the commit message #59:

fixing build error

# This is the commit message #60:

fixing build error

# This is the commit message #61:

fixing build error

# This is the commit message #62:

fixing build error

# This is the commit message #63:

fixing build error

# This is the commit message #64:

fixing build error

# This is the commit message #65:

fixing build error

# This is the commit message #66:

fixing build error

# This is the commit message #67:

fixing build error

# This is the commit message #68:

fixing build error

# This is the commit message #69:

fixing build error

# This is the commit message #70:

fixing build error

# This is the commit message #71:

fixing build error

# This is the commit message #72:

fixing build error

# This is the commit message #73:

trying acr fix

# This is the commit message #74:

latest changes

# This is the commit message #75:

removing docker dependency on azure devops pipeline

# This is the commit message #76:

removing docker dependency on azure devops pipeline

# This is the commit message #77:

removing docker dependency on azure devops pipeline

# This is the commit message #78:

removing docker dependency on azure devops pipeline

# This is the commit message #79:

removing docker dependency on azure devops pipeline

# This is the commit message #80:

removing docker dependency on azure devops pipeline

# This is the commit message #81:

removing docker dependency on azure devops pipeline

# This is the commit message #82:

removing docker dependency on azure devops pipeline

# This is the commit message #83:

removing docker dependency on azure devops pipeline

# This is the commit message #84:

removing docker dependency on azure devops pipeline

# This is the commit message #85:

removing docker dependency on azure devops pipeline

# This is the commit message #86:

removing docker dependency on azure devops pipeline

# This is the commit message #87:

removing docker dependency on azure devops pipeline

# This is the commit message #88:

removing docker dependency on azure devops pipeline

# This is the commit message #89:

removing docker dependency on azure devops pipeline

# This is the commit message #90:

removing docker dependency on azure devops pipeline

# This is the commit message #91:

removing docker dependency on azure devops pipeline

# This is the commit message #92:

removing docker dependency on azure devops pipeline

# This is the commit message #93:

removing docker dependency on azure devops pipeline

# This is the commit message #94:

removing docker dependency on azure devops pipeline

# This is the commit message #95:

removing docker dependency on azure devops pipeline

# This is the commit message #96:

removing docker dependency on azure devops pipeline

# This is the commit message #97:

removing docker dependency on azure devops pipeline

# This is the commit message #98:

final commit including resource name randomization

# This is the commit message #99:

Add provider to configure az infra for Terraform

* resolving merge conflicts for squash

Updated documentation based on review comments

Integrate review comments for documentation.

Add usage example for each of the providers

Adding environment template descriptions

removing go version var from azdo pipeline as it's unused

removing unused setup folder

adding more verbose logging for azure devops failure

fixing pull request branch name resolution bug

fixing pull request branch name resolution bug

addressing nick's pr comments

documenting script and docker images

cleaning up required env var check

fixing base branch bug

Added service plan terraform templates to Azure

Adding tags for resources

Integrate review comments to add random id to name

Add tags, capacity and reserved for service plan

Minor Fixes for documentation

Integrate review comments related to resource naming

Remove Optional and Required in variables.tf

Update variables.tf

Update Service Plan Tier to Isolated

squaching commits

applied base image suggestions from nick

* squashing commits and slimming down the build image

* removing go* path from azure devops pipeline as we removed go mods

* refactoring our azure devops pipeline so it's aligned with the local test runner

* fixing azure devops pipeline bug

* fixing base image build variable reference bug

* Addressing nick's PR comments

* resolving issue with failed builds after completing branches merges

* addressing a bug where test harness directory changes were not getting picked up by the harness

* removing local echo statement

* Adding directory exists check and app service container command variable

* addressing nick's PR comments

* adding git diff extension whitelist filter
  • Loading branch information
erikschlegel committed Apr 26, 2019
1 parent 5070b66 commit e6cdf65
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 112 deletions.
23 changes: 13 additions & 10 deletions devops/providers/azure-devops/templates/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ steps:
BASE_IMAGE=$ACR_HOST/$TEST_HARNESS_BASE_IMAGE:$TEST_HARNESS_BASE_IMAGE_TAG
substitution="remotes/origin"
replace_string="refs/heads"
GIT_DIFF_UPSTREAMBRANCH="remotes/origin/master"
GIT_DIFF_SOURCEBRANCH=`[[ -n $SYSTEM_PULLREQUEST_SOURCEBRANCH ]] && \
echo "${substitution}/${SYSTEM_PULLREQUEST_SOURCEBRANCH}" || \
echo "${BUILD_SOURCEBRANCH//$replace_string/$substitution}"`
GIT_DIFF_UPSTREAMBRANCH="remotes/origin/master"
[ $GIT_DIFF_SOURCEBRANCH == $GIT_DIFF_UPSTREAMBRANCH ] && { GIT_DIFF_SOURCEBRANCH="$GIT_DIFF_SOURCEBRANCH~"; }
. ./test-harness/init.sh --source-only
build_test_harness $GIT_DIFF_UPSTREAMBRANCH \
Expand All @@ -73,13 +74,15 @@ steps:
displayName: 'Determine integration tests based off branch changes and load build path'

- script: |
docker run -e ARM_SUBSCRIPTION_ID=$(AD-SP-SUBSCRIPTION-ID) \
-e ARM_CLIENT_ID=$(AD-SP-CLIENT-ID) \
-e ARM_CLIENT_SECRET=$(AD-SP-SECRET) \
-e ARM_TENANT_ID=$(AD-SP-TENANT-ID) \
-e DATACENTER_LOCATION=$DATACENTER_LOCATION \
-e TF_STATE_STORAGE_ACCT=$TF_STATE_STORAGE_ACCT \
-e TF_STATE_CONTAINER=$TF_STATE_CONTAINER \
-e ARM_ACCESS_KEY=$(ARM-ACCESS-KEY) \
--rm $BUILD_TEST_RUN_IMAGE:$BUILD_BUILDID
if test ! -z "$(docker images -q ${BUILD_TEST_RUN_IMAGE}:${BUILD_BUILDID})"; then
docker run -e ARM_SUBSCRIPTION_ID=$(AD-SP-SUBSCRIPTION-ID) \
-e ARM_CLIENT_ID=$(AD-SP-CLIENT-ID) \
-e ARM_CLIENT_SECRET=$(AD-SP-SECRET) \
-e ARM_TENANT_ID=$(AD-SP-TENANT-ID) \
-e DATACENTER_LOCATION=$DATACENTER_LOCATION \
-e TF_STATE_STORAGE_ACCT=$TF_STATE_STORAGE_ACCT \
-e TF_STATE_CONTAINER=$TF_STATE_CONTAINER \
-e ARM_ACCESS_KEY=$(ARM-ACCESS-KEY) \
--rm $BUILD_TEST_RUN_IMAGE:$BUILD_BUILDID
fi
displayName: 'run the test harness container which deploys, validates and tears down modified terraform templates'
2 changes: 1 addition & 1 deletion infra/templates/azure-simple-hw/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ resource "azurerm_app_service" "main" {

site_config {
app_command_line = ""
linux_fx_version = "DOCKER|appsvcsample/static-site:latest"
linux_fx_version = "${var.app_service_linux_container_command}"
}

app_settings = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func validatePlan(t *testing.T, tfPlanOutput string, tfOptions *terraform.Option

func TestITAzureSimple(t *testing.T) {
t.Parallel()
fixtureFolder := "../"
fixtureFolder := "../../"
terraformOptions := configureTerraformOptions(t, fixtureFolder)
defer terraform.Destroy(t, terraformOptions)

Expand Down
5 changes: 5 additions & 0 deletions infra/templates/azure-simple-hw/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ variable "location" {
variable "storage_account_replication_type" {
description = "Defines the type of replication to use for this storage account. Valid options are LRS*, GRS, RAGRS and ZRS."
default = "LRS"
}

variable "app_service_linux_container_command" {
description = "Defines the exec command for linux based container app services."
default = "DOCKER|appsvcsample/static-site:latest"
}
25 changes: 18 additions & 7 deletions test-harness/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
#!/usr/bin/env bash
set -euo pipefail

declare -A TEST_RUN_MAP
declare -A TEST_RUN_MAP=()
declare BUILD_TEMPLATE_DIRS="build"
declare BUILD_TEST_RUN_IMAGE="cobalt-test-harness"
declare readonly TEMPLATE_DIR="infra/templates"
declare readonly GIT_DIFF_EXTENSION_WHITE_LIST="*.go|*.tf|*.sh|Dockerfile*|*.tfvars"


function rebuild_test_image() {
Expand Down Expand Up @@ -47,8 +48,9 @@ function default_to_all_template_paths() {

function add_template_if_not_exists() {
declare readonly template_name=$1
if [[ -z ${TEST_RUN_MAP[$template_name]+unset} ]]; then
TEST_RUN_MAP[$template_name]="$TEMPLATE_DIR/$template_name"
declare readonly template_directory="$TEMPLATE_DIR/$template_name"
if [[ -z ${TEST_RUN_MAP[$template_name]+unset} && -d "$template_directory" ]]; then
TEST_RUN_MAP[$template_name]="$template_directory"
fi;
}

Expand All @@ -66,7 +68,7 @@ function build_test_harness() {
template_build_targets $GIT_DIFF_UPSTREAMBRANCH $GIT_DIFF_SOURCEBRANCH
echo "INFO: Building test harness image"
rebuild_test_image $BASE_IMAGE
rm -r $BUILD_TEMPLATE_DIRS
if [ -d "$BUILD_TEMPLATE_DIRS" ]; then rm -Rf $BUILD_TEMPLATE_DIRS; fi
}

function template_build_targets() {
Expand All @@ -77,17 +79,21 @@ function template_build_targets() {
[[ -z $GIT_DIFF_SOURCEBRANCH ]] && echo "ERROR: GIT_DIFF_SOURCEBRANCH wasn't provided" && return 1

echo "INFO: Running git diff from branch ${GIT_DIFF_SOURCEBRANCH}"
files=(`git diff ${GIT_DIFF_UPSTREAMBRANCH} ${GIT_DIFF_SOURCEBRANCH} --name-only|grep -v *.md`)
files=(`git diff ${GIT_DIFF_UPSTREAMBRANCH} ${GIT_DIFF_SOURCEBRANCH} --name-only|grep -E ${GIT_DIFF_EXTENSION_WHITE_LIST}||true`)
for file in "${files[@]}"
do
IFS='/' read -a folder_array <<< "${file}"

if [ ${#folder_array[@]} -lt 3 ]; then
continue
fi

if [ ${folder_array[0]}=='test-harness' ]; then
default_to_all_template_paths
break
fi

case ${folder_array[1]} in
'modules'|'test-harness')
'modules')
default_to_all_template_paths
break
;;
Expand All @@ -97,5 +103,10 @@ function template_build_targets() {
esac
done

if [ ${#TEST_RUN_MAP[@]} -eq 0 ]; then
echo "INFO: No templates to process. Exiting build step"
exit 0
fi

load_build_directory
}
2 changes: 1 addition & 1 deletion test-harness/local-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ readonly BUILD_UPSTREAMBRANCH="master"
readonly TF_STATE_STORAGE_ACCT="cobaltfstate"
readonly TF_STATE_CONTAINER="cobaltfstate-remote-state-container"
readonly docker_base_image_name="msftcse/cobalt-test-base"
declare docker_base_image_tag="g${GO_VERSION}t${TF_VERSION}"

function dotenv() {
set -a
Expand All @@ -26,6 +25,7 @@ function run_test_harness() {
echo "INFO: loading environment"
dotenv
check_required_env_variables
docker_base_image_tag="g${GO_VERSION}t${TF_VERSION}"
echo "INFO: verified that environment is fully defined"
build_test_harness $BUILD_UPSTREAMBRANCH \
$BUILD_SOURCEBRANCHNAME \
Expand Down
16 changes: 0 additions & 16 deletions test/README.md

This file was deleted.

34 changes: 0 additions & 34 deletions test/docker/base-images/Dockerfile

This file was deleted.

42 changes: 0 additions & 42 deletions test/docker/base-images/README.md

This file was deleted.

0 comments on commit e6cdf65

Please sign in to comment.