Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Deployment and Operations
infra-azure-provisioning
Commits
7c871d7d
Commit
7c871d7d
authored
Sep 07, 2021
by
Kishore Battula
Browse files
Merge branch 'haaggarw/update-test-dag-stage' into 'master'
Azure - Update Dag Test Stage See merge request
!468
parents
9b22c55e
f4d2a0ab
Pipeline
#63432
passed with stages
in 1 minute and 24 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
devops/dag-pipeline-stages/execute-end-to-end-tests.yml
View file @
7c871d7d
# Copyright © Microsoft Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################
# README: Defines a Stage to execute End to End Tests for DAGs
#####################
parameters
:
outputDagsFolder
:
'
output_dags'
dockerfilePath
:
'
'
environmentVars
:
'
'
stages
:
-
stage
:
'
Execute_End_to_End_Tests'
jobs
:
-
job
:
Execute_End_to_End_Tests
displayName
:
Execute End to End Test Cases
pool
:
name
:
$(AGENT_POOL)
steps
:
-
task
:
DownloadPipelineArtifact@2
displayName
:
Download Dag files
inputs
:
artifact
:
${{ parameters.outputDagsFolder }}
path
:
$(System.DefaultWorkingDirectory)/output_dags
-
task
:
AzureCLI@1
displayName
:
Execute End to End Tests
env
:
AZURE_TENANT_ID
:
$(app-dev-sp-tenant-id)
inputs
:
azureSubscription
:
$(SERVICE_CONNECTION_NAME)
addSpnToEnvironment
:
true
scriptLocation
:
inlineScript
inlineScript
:
|
// Generate the env file for docker run
NEWLINE=$'\n'
cat > .env << EOF
${{ parameters.environmentVars }}
EOF
docker_image_name=execute-end-to-end-tests:$(Build.SourceVersion)
docker build -t $docker_image_name --file ${{ parameters.dockerfilePath }} .
docker run --env-file .env $docker_image_name
# Copyright © Microsoft Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################
# README: Defines a Stage to execute End to End Tests for DAGs
#####################
parameters
:
outputDagsFolder
:
'
output_dags'
environmentVars
:
'
'
postmanCollection
:
'
'
stages
:
-
stage
:
'
Execute_End_to_End_Tests'
jobs
:
-
job
:
Execute_End_to_End_Tests
displayName
:
Execute End to End Test Cases
pool
:
name
:
$(AGENT_POOL)
steps
:
-
task
:
DownloadPipelineArtifact@2
displayName
:
Download Dag files
inputs
:
artifact
:
${{ parameters.outputDagsFolder }}
path
:
$(System.DefaultWorkingDirectory)/output_dags
-
task
:
UsePythonVersion@0
inputs
:
versionSpec
:
'
3.8'
-
task
:
NodeTool@0
inputs
:
versionSpec
:
'
14.x'
-
task
:
AzureCLI@1
displayName
:
Execute End to End Tests
env
:
AZURE_TENANT_ID
:
$(app-dev-sp-tenant-id)
AZURE_POSTMAN_ENVIRONMENT_FILE_URL
:
$AZURE_POSTMAN_ENVIRONMENT_FILE_URL
AZURE_POSTMAN_COLLECTION_FILE_URL
:
${{ parameters.postmanCollection }}
CLIENT_ID
:
$(aad-client-id)
inputs
:
azureSubscription
:
$(SERVICE_CONNECTION_NAME)
addSpnToEnvironment
:
true
scriptLocation
:
inlineScript
inlineScript
:
|
NEWLINE=$'\n'
cat > python_env_vars.txt << EOF
${{ parameters.environmentVars }}
EOF
cat > run_postman_collection.py << EOF
import requests
import os
import json
def bootstrap():
f = open('./output_dags/workflow_request_body.json', 'r', encoding='utf-8')
data = json.load(f)
f.close()
dag_name = data[0]['workflowName']
prepare_environment(dag_name)
prepare_postman_collection()
def prepare_postman_collection():
# Downloading the postman collection json file
url_collection = os.environ.get('AZURE_POSTMAN_COLLECTION_FILE_URL')
r = requests.get(url_collection, allow_redirects=True)
open('collection_file.json', 'wb').write(r.content)
def prepare_environment(dag_name):
# Downloading the environment file to trigger the postman collections
url_env_file = os.environ.get('AZURE_POSTMAN_ENVIRONMENT_FILE_URL')
r = requests.get(url_env_file, allow_redirects=True)
open('env_file.json', 'wb').write(r.content)
env_file = open('env_file.json', "r")
data = json.load(env_file)
# Setting env variables
postman_var_to_env_dict = {}
python_vars = open("python_env_vars.txt")
for line in python_vars:
key, value = line.split()
postman_var_to_env_dict[key] = eval(value)
for value in data['values']:
if value['key'] in postman_var_to_env_dict.keys():
value['value'] = postman_var_to_env_dict[value['key']]
env_file = open('env_file.json', "w")
json.dump(data, env_file)
env_file.close()
if __name__ == "__main__":
bootstrap()
EOF
pip install requests
python ./run_postman_collection.py
npm install -g newman
newman run collection_file.json -e env_file.json
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment