From 406c79da6fcaa8c683959f8d7d8794ca17866b55 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 21 May 2024 14:10:13 -0700 Subject: [PATCH 01/22] Try repurposing release pipeline as a test pipeline --- ...eate-release.yml => integration_tests.yml} | 36 ++----------------- .azure-devops/templates/trigger-tests.yml | 2 +- 2 files changed, 3 insertions(+), 35 deletions(-) rename .azure-devops/{create-release.yml => integration_tests.yml} (84%) diff --git a/.azure-devops/create-release.yml b/.azure-devops/integration_tests.yml similarity index 84% rename from .azure-devops/create-release.yml rename to .azure-devops/integration_tests.yml index 2cb939a51..c4791adc0 100644 --- a/.azure-devops/create-release.yml +++ b/.azure-devops/integration_tests.yml @@ -7,12 +7,6 @@ parameters: - name: variableGroup type: string default: 'aziotcli_test_primary' -- name: buildAgentPoolVar - type: string - default: 'BuildAgentPool' -- name: buildAgentVmImageVar - type: string - default: 'BuildAgentVmImage' - name: testAgentVmImage type: string default: 'ubuntu-20.04' @@ -69,10 +63,6 @@ parameters: variables: - group: ${{ parameters.variableGroup }} - - name: vmImage - value: $[variables.${{ parameters.buildAgentVmImageVar }}] - - name: buildPool - value: $[variables.${{ parameters.buildAgentPoolVar }}] stages: - stage: 'build' @@ -81,10 +71,7 @@ stages: - job: 'Build_Publish_Azure_IoT_CLI_Extension' pool: - name: $(buildPool) - vmImage: $(vmImage) - demands: - - ImageOverride -equals $(vmImage) + vmImage: ubuntu-latest steps: - task: UsePythonVersion@0 inputs: @@ -148,7 +135,6 @@ stages: # displayName: 'Validate Reference Document Generation' # steps: # - template: templates/validate-refdoc-generation.yml - - stage: 'smokeTest' displayName: 'Run smoke tests' dependsOn: test @@ -186,10 +172,7 @@ stages: - job: 'Calculate_Sha_And_Create_Release' displayName: 'Calculate package hash and publish' pool: - name: $(buildPool) - vmImage: $(vmImage) - demands: - - ImageOverride -equals $(vmImage) + vmImage: ubuntu-latest variables: CLIVersion: $[ stageDependencies.build.recordVersion.outputs['setupVersion.CLIVersion'] ] ReleaseTitle: $[ stageDependencies.build.recordVersion.outputs['setupVersion.ReleaseTitle'] ] @@ -216,18 +199,3 @@ stages: } Write-Host "done" workingDirectory: '$(System.ArtifactsDirectory)/extension' - - - task: GitHubRelease@1 - inputs: - gitHubConnection: $(GithubReleaseConnection) - repositoryName: $(Build.Repository.Name) - action: 'create' - target: '$(Build.SourceVersion)' - tagSource: userSpecifiedTag - tag: 'v$(CLIVersion)' - title: $(ReleaseTitle) - assets: '$(System.ArtifactsDirectory)/extension/**/*.whl' - assetUploadMode: 'replace' - isDraft: true - isPreRelease: false - addChangeLog: false diff --git a/.azure-devops/templates/trigger-tests.yml b/.azure-devops/templates/trigger-tests.yml index 33ec54cf2..dec2277f3 100644 --- a/.azure-devops/templates/trigger-tests.yml +++ b/.azure-devops/templates/trigger-tests.yml @@ -139,7 +139,7 @@ jobs: azureCLIVersion: ${{ parameters.azureCLIVersion }} pythonVersion: $(python) num_reruns: 0 - serviceConnection: $(AzureServiceConnectionAlt) + serviceConnection: $(AzureServiceConnection) - job: 'unitTests' displayName: 'Unit tests and code coverage' From 39a6a4b13c2749532bc0178b769b869f532a90a4 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 21 May 2024 14:28:26 -0700 Subject: [PATCH 02/22] remove entire release stage --- .azure-devops/integration_tests.yml | 42 +---------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/.azure-devops/integration_tests.yml b/.azure-devops/integration_tests.yml index c4791adc0..f839c533a 100644 --- a/.azure-devops/integration_tests.yml +++ b/.azure-devops/integration_tests.yml @@ -158,44 +158,4 @@ stages: - template: templates/calculate-code-coverage.yml parameters: pythonVersion: ${{ parameters.pythonVersion }} - architecture: ${{ parameters.architecture }} - - - stage: 'release' - displayName: 'Stage GitHub release' - dependsOn: build - condition: and(succeeded(), eq(${{ parameters.stageForPublish }}, 'true')) - jobs: - - deployment: 'StageGitHub' - displayName: 'Stage CLI extension on GitHub' - environment: 'production' - - - job: 'Calculate_Sha_And_Create_Release' - displayName: 'Calculate package hash and publish' - pool: - vmImage: ubuntu-latest - variables: - CLIVersion: $[ stageDependencies.build.recordVersion.outputs['setupVersion.CLIVersion'] ] - ReleaseTitle: $[ stageDependencies.build.recordVersion.outputs['setupVersion.ReleaseTitle'] ] - - steps: - - task: DownloadBuildArtifacts@0 - displayName : 'Download Extension wheel from Build Artifacts' - inputs: - buildType: 'current' - downloadType: 'single' - artifactName: 'azure-iot' - downloadPath: '$(System.ArtifactsDirectory)/extension' - - - task: PowerShell@2 - displayName: 'Calculate sha for downloaded extension' - inputs: - targetType: 'inline' - script: | - $extensions = Get-ChildItem -Filter "*.whl" -Recurse | Select-Object FullName - Foreach ($extension in $extensions) - { - Write-Host "calculating sha256 for " $extension.FullName - (Get-Filehash -Path $extension.Fullname -Algorithm SHA256).Hash.ToLower() - } - Write-Host "done" - workingDirectory: '$(System.ArtifactsDirectory)/extension' + architecture: ${{ parameters.architecture }} \ No newline at end of file From beac0955501ff801c9bee1bf4062205f5d0d9639 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 29 May 2024 08:42:32 -0700 Subject: [PATCH 03/22] try faster failures, no parallelization on central tests --- .azure-devops/templates/run-tests-parallel.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.azure-devops/templates/run-tests-parallel.yml b/.azure-devops/templates/run-tests-parallel.yml index 92aa16cc3..abbcaa5eb 100644 --- a/.azure-devops/templates/run-tests-parallel.yml +++ b/.azure-devops/templates/run-tests-parallel.yml @@ -39,7 +39,6 @@ parameters: - name: parallel_execution_dirs type: object default: - - 'azext_iot/tests/central' - 'azext_iot/tests/digitaltwins' - 'azext_iot/tests/deviceupdate' @@ -81,6 +80,10 @@ steps: inlineScript: | export COVERAGE_FILE=.coverage.${{ parameters.name }} pytest -vv ${{ parameters.path }} -k "_int.py" --dist=loadfile -n ${{ parameters.num_threads }} --reruns ${{ parameters.num_reruns }} --reruns-delay ${{ parameters.reruns_delay }} --cov=azext_iot --cov-config .coveragerc --junitxml=junit/test-iotext-int.xml --durations=0 + ${{ if contains(parameters.path, 'azext_iot/tests/central') }}: + inlineScript: | + export COVERAGE_FILE=.coverage.${{ parameters.name }} + pytest -vv ${{ parameters.path }} -k "_int.py" --cov=azext_iot --cov-config .coveragerc --junitxml=junit/test-iotext-int.xml --maxfail=3 ${{ if contains(parameters.path, 'azext_iot/tests/iothub') }}: inlineScript: | export COVERAGE_FILE=.coverage.${{ parameters.name }} From eec4fdd415d3ec1491076d057c17eeaf68cd6c04 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 29 May 2024 10:27:26 -0700 Subject: [PATCH 04/22] remove maxFail from central tests --- .azure-devops/templates/run-tests-parallel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-devops/templates/run-tests-parallel.yml b/.azure-devops/templates/run-tests-parallel.yml index abbcaa5eb..037ce945a 100644 --- a/.azure-devops/templates/run-tests-parallel.yml +++ b/.azure-devops/templates/run-tests-parallel.yml @@ -83,7 +83,7 @@ steps: ${{ if contains(parameters.path, 'azext_iot/tests/central') }}: inlineScript: | export COVERAGE_FILE=.coverage.${{ parameters.name }} - pytest -vv ${{ parameters.path }} -k "_int.py" --cov=azext_iot --cov-config .coveragerc --junitxml=junit/test-iotext-int.xml --maxfail=3 + pytest -vv ${{ parameters.path }} -k "_int.py" --cov=azext_iot --cov-config .coveragerc --junitxml=junit/test-iotext-int.xml ${{ if contains(parameters.path, 'azext_iot/tests/iothub') }}: inlineScript: | export COVERAGE_FILE=.coverage.${{ parameters.name }} From 40ce77b02b0847ee2c423c47f21c73a2b874a2ec Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 29 May 2024 10:27:50 -0700 Subject: [PATCH 05/22] break out adu update tets --- .azure-devops/integration_tests.yml | 4 +++ .../templates/run-tests-parallel.yml | 6 ++++- .azure-devops/templates/trigger-tests.yml | 25 +++++++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/.azure-devops/integration_tests.yml b/.azure-devops/integration_tests.yml index f839c533a..25aaaae2d 100644 --- a/.azure-devops/integration_tests.yml +++ b/.azure-devops/integration_tests.yml @@ -60,6 +60,9 @@ parameters: - name: 'testADU' type: boolean default: true +- name: 'testADUupdate' + type: boolean + default: true variables: - group: ${{ parameters.variableGroup }} @@ -123,6 +126,7 @@ stages: testDPS: ${{ parameters.testDPS }} testHub: ${{ parameters.testHub }} testADU: ${{ parameters.testADU }} + testADUupdate: ${{ parameters.testADUupdate }} maxParallelADT: 2 maxParallelDPS: 2 maxParallelHub: 2 diff --git a/.azure-devops/templates/run-tests-parallel.yml b/.azure-devops/templates/run-tests-parallel.yml index 037ce945a..9c9c7cfd9 100644 --- a/.azure-devops/templates/run-tests-parallel.yml +++ b/.azure-devops/templates/run-tests-parallel.yml @@ -40,7 +40,6 @@ parameters: type: object default: - 'azext_iot/tests/digitaltwins' - - 'azext_iot/tests/deviceupdate' steps: - checkout: self @@ -80,6 +79,11 @@ steps: inlineScript: | export COVERAGE_FILE=.coverage.${{ parameters.name }} pytest -vv ${{ parameters.path }} -k "_int.py" --dist=loadfile -n ${{ parameters.num_threads }} --reruns ${{ parameters.num_reruns }} --reruns-delay ${{ parameters.reruns_delay }} --cov=azext_iot --cov-config .coveragerc --junitxml=junit/test-iotext-int.xml --durations=0 + ${{ if contains(parameters.path, 'azext_iot/tests/deviceupdate/test_adu_update') }}: + # no parallelization on adu update tests + inlineScript: | + export COVERAGE_FILE=.coverage.${{ parameters.name }} + pytest -vv ${{ parameters.path }} -k "_int.py" --cov=azext_iot --cov-config .coveragerc --junitxml=junit/test-iotext-int.xml ${{ if contains(parameters.path, 'azext_iot/tests/central') }}: inlineScript: | export COVERAGE_FILE=.coverage.${{ parameters.name }} diff --git a/.azure-devops/templates/trigger-tests.yml b/.azure-devops/templates/trigger-tests.yml index dec2277f3..f5847e579 100644 --- a/.azure-devops/templates/trigger-tests.yml +++ b/.azure-devops/templates/trigger-tests.yml @@ -24,6 +24,9 @@ parameters: - name: 'testADU' type: boolean default: true +- name: 'testADUupdate' + type: boolean + default: true - name: 'maxParallelCentral' type: number default: 1 @@ -126,7 +129,7 @@ jobs: - job: 'testADU' timeoutInMinutes: 200 - displayName: 'Test Azure Device Update' + displayName: 'Test ADU' condition: and(succeeded(), eq('${{ parameters.testADU }}', true)) strategy: matrix: $[ variables['pythonVersions'] ] @@ -134,12 +137,30 @@ jobs: steps: - template: run-tests-parallel.yml parameters: - path: 'azext_iot/tests/deviceupdate' + path: 'azext_iot/tests/deviceupdate --ignore=azext_iot/tests/deviceupdate/test_adu_update_int.py' name: 'azure-deviceupdate' azureCLIVersion: ${{ parameters.azureCLIVersion }} pythonVersion: $(python) num_reruns: 0 serviceConnection: $(AzureServiceConnection) + +# Splitting up adu update tests due to timeout failures and other inconsistencies +- job: 'testADUupdate' + timeoutInMinutes: 200 + displayName: 'Test ADU Update' + condition: and(succeeded(), eq('${{ parameters.testADUupdate }}', true)) + strategy: + matrix: $[ variables['pythonVersions'] ] + maxParallel: ${{ parameters.maxParallelADU }} + steps: + - template: run-tests-parallel.yml + parameters: + path: 'azext_iot/tests/deviceupdate/test_adu_update_int.py' + name: 'azure-deviceupdate-update' + azureCLIVersion: ${{ parameters.azureCLIVersion }} + pythonVersion: $(python) + num_reruns: 0 + serviceConnection: $(AzureServiceConnection) - job: 'unitTests' displayName: 'Unit tests and code coverage' From 04f8daab3a04d448f218b62ad2a7cb1dbc87ad48 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 29 May 2024 10:49:03 -0700 Subject: [PATCH 06/22] No need for RG role assignment of data contributor --- azext_iot/tests/deviceupdate/conftest.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/azext_iot/tests/deviceupdate/conftest.py b/azext_iot/tests/deviceupdate/conftest.py index df5267d3a..b2adfd1be 100644 --- a/azext_iot/tests/deviceupdate/conftest.py +++ b/azext_iot/tests/deviceupdate/conftest.py @@ -15,9 +15,8 @@ from azext_iot.common.embedded_cli import EmbeddedCLI from azext_iot.tests.generators import generate_generic_id -from azext_iot.tests.helpers import assign_role_assignment, get_role_assignments, tags_to_dict +from azext_iot.tests.helpers import get_role_assignments, tags_to_dict from azext_iot.tests.settings import DynamoSettings -from azext_iot.deviceupdate.common import AUTH_RESOURCE_ID logger = get_logger(__name__) @@ -303,15 +302,15 @@ def _iothub_provisioner(request) -> Optional[dict]: hub_names = [] # Assign Data Contributor role to resource group if it does not exist - account = cli.invoke("account show").as_json() - scope_id = "/subscriptions/{}/resourceGroups/{}".format( - account["id"], - ACCOUNT_RG - ) - assign_role_assignment( - role="IoT Hub Data Contributor", - scope=scope_id, - assignee=AUTH_RESOURCE_ID) + # account = cli.invoke("account show").as_json() + # scope_id = "/subscriptions/{}/resourceGroups/{}".format( + # account["id"], + # ACCOUNT_RG + # ) + # assign_role_assignment( + # role="IoT Hub Data Contributor", + # scope=scope_id, + # assignee=AUTH_RESOURCE_ID) for _ in range(desired_instance_count): target_name = generate_linked_hub_id() From 77b99f487f6f4f484b55c303207c2dc56ad9c208 Mon Sep 17 00:00:00 2001 From: Ryan Kelly Date: Thu, 30 May 2024 10:24:10 -0700 Subject: [PATCH 07/22] update some defaults, timeouts, etc --- .azure-devops/integration_tests.yml | 7 ++++--- .azure-devops/templates/run-tests-parallel.yml | 2 +- .azure-devops/templates/trigger-tests.yml | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.azure-devops/integration_tests.yml b/.azure-devops/integration_tests.yml index 25aaaae2d..4c984ed8b 100644 --- a/.azure-devops/integration_tests.yml +++ b/.azure-devops/integration_tests.yml @@ -9,7 +9,7 @@ parameters: default: 'aziotcli_test_primary' - name: testAgentVmImage type: string - default: 'ubuntu-20.04' + default: 'ubuntu-22.04' values: - 'ubuntu-20.04' - 'ubuntu-22.04' @@ -17,7 +17,7 @@ parameters: - name: pythonVersion displayName: 'Python version for building wheel, KPIs' type: string - default: '3.8' + default: '3.9' values: - '3.8' - '3.9' @@ -60,9 +60,10 @@ parameters: - name: 'testADU' type: boolean default: true +# These tests currently time out with federated credentials and must be tested locally - name: 'testADUupdate' type: boolean - default: true + default: false variables: - group: ${{ parameters.variableGroup }} diff --git a/.azure-devops/templates/run-tests-parallel.yml b/.azure-devops/templates/run-tests-parallel.yml index 9c9c7cfd9..91d0a49cd 100644 --- a/.azure-devops/templates/run-tests-parallel.yml +++ b/.azure-devops/templates/run-tests-parallel.yml @@ -79,8 +79,8 @@ steps: inlineScript: | export COVERAGE_FILE=.coverage.${{ parameters.name }} pytest -vv ${{ parameters.path }} -k "_int.py" --dist=loadfile -n ${{ parameters.num_threads }} --reruns ${{ parameters.num_reruns }} --reruns-delay ${{ parameters.reruns_delay }} --cov=azext_iot --cov-config .coveragerc --junitxml=junit/test-iotext-int.xml --durations=0 + # no parallelization on specific adu update tests (test_adu_update_int.py) ${{ if contains(parameters.path, 'azext_iot/tests/deviceupdate/test_adu_update') }}: - # no parallelization on adu update tests inlineScript: | export COVERAGE_FILE=.coverage.${{ parameters.name }} pytest -vv ${{ parameters.path }} -k "_int.py" --cov=azext_iot --cov-config .coveragerc --junitxml=junit/test-iotext-int.xml diff --git a/.azure-devops/templates/trigger-tests.yml b/.azure-devops/templates/trigger-tests.yml index f5847e579..31368c382 100644 --- a/.azure-devops/templates/trigger-tests.yml +++ b/.azure-devops/templates/trigger-tests.yml @@ -95,7 +95,7 @@ jobs: serviceConnection: $(AzureServiceConnection) - job: 'testHub_job_1' - timeoutInMinutes: 105 + timeoutInMinutes: 120 displayName: 'Test IoT Hub - certificate, config, core, jobs, state' condition: and(succeeded(), eq('${{ parameters.testHub }}', true)) strategy: @@ -112,7 +112,7 @@ jobs: serviceConnection: $(AzureServiceConnection) - job: 'testHub_job_2' - timeoutInMinutes: 90 + timeoutInMinutes: 120 condition: and(succeeded(), eq('${{ parameters.testHub }}', true)) displayName: 'Test IoT Hub - devices, message endpoints, messaging, and modules' strategy: @@ -146,7 +146,7 @@ jobs: # Splitting up adu update tests due to timeout failures and other inconsistencies - job: 'testADUupdate' - timeoutInMinutes: 200 + timeoutInMinutes: 90 displayName: 'Test ADU Update' condition: and(succeeded(), eq('${{ parameters.testADUupdate }}', true)) strategy: From 65339e7bfb753ec5004e19e6809dd84547ebb45e Mon Sep 17 00:00:00 2001 From: Ryan Kelly Date: Thu, 30 May 2024 10:25:50 -0700 Subject: [PATCH 08/22] Add github workflow to trigger ADO pipeline --- .github/workflows/trigger_ado_int_tests.yml | 240 ++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 .github/workflows/trigger_ado_int_tests.yml diff --git a/.github/workflows/trigger_ado_int_tests.yml b/.github/workflows/trigger_ado_int_tests.yml new file mode 100644 index 000000000..befb38736 --- /dev/null +++ b/.github/workflows/trigger_ado_int_tests.yml @@ -0,0 +1,240 @@ +name: Run Azure DevOps Integration Tests +on: + workflow_call: + inputs: + showLogs: + description: "Show logs" + required: false + type: boolean + default: false + testCentral: + description: Run Central tests + type: boolean + default: true + testADT: + description: Run ADT tests + type: boolean + default: true + testDPS: + description: Run DPS tests + type: boolean + default: true + testHub: + description: Run Hub tests + type: boolean + default: true + testADU: + description: Run ADU tests + type: boolean + default: true + # These tests currently time out with federated credentials and must be tested locally + testADUupdate: + description: Run ADU update tests + type: boolean + default: false + python_versions: + description: "Python versions to test" + required: true + type: string + default: > + { + Python38: { python: '3.8' }, + Python39: { python: '3.9' }, + Python310: { python: '3.10' } + } + secrets: + ADO_PAT: + required: true + workflow_dispatch: + inputs: + showLogs: + description: "Show logs" + required: false + type: boolean + default: false + testCentral: + description: Run Central tests + type: boolean + default: true + testADT: + description: Run ADT tests + type: boolean + default: true + testDPS: + description: Run DPS tests + type: boolean + default: true + testHub: + description: Run Hub tests + type: boolean + default: true + testADU: + description: Run ADU tests + type: boolean + default: true + # These tests currently time out with federated credentials and must be tested locally + testADUupdate: + description: Run ADU update tests + type: boolean + default: false + python_versions: + description: "Python versions to test" + required: true + type: string + default: > + { + Python38: { python: '3.8' }, + Python39: { python: '3.9' }, + Python310: { python: '3.10' } + } +env: + DEFAULT_TITLE: "Azure DevOps Pipeline" + AZURE_DEVOPS_EXT_PAT: ${{ secrets.ADO_PAT }} + DEFINITION_ID: 147 + ORG: azureiotdevxp + PROJECT: aziotcli +jobs: + call-ado-pipeline: + runs-on: ubuntu-latest + name: Run integration tests + outputs: + runId: ${{ steps.start.outputs.runId }} + portalUrl: ${{ steps.start.outputs.portalUrl }} + url: ${{ steps.start.outputs.url }} + steps: + - shell: bash + id: start + name: Trigger the pipeline + run: |- + set -ex + if [ -z "$ORG" ]; then + echo "::error::Organization is required" + exit 1 + fi + if [ -z "$PROJECT" ]; then + echo "::error::Project is required" + exit 1 + fi + + cmdArgs=(--org "https://dev.azure.com/$ORG" --project "$PROJECT" --branch "add_ado_int_tests" --debug) + + if [ -n "$DEFINITION_ID" ]; then + cmdArgs+=(--id "$DEFINITION_ID") + else + echo "::error::Pipeline definition ID must be provided" + exit 1 + fi + + cmdArgs+=("--parameters") + cmdArgs+=("pythonVersionsTestingMatrix=${{inputs.python_versions}}") + cmdArgs+=("testCentral=${{inputs.testCentral}}") + cmdArgs+=("testADT=${{inputs.testADT}}") + cmdArgs+=("testDPS=${{inputs.testDPS}}") + cmdArgs+=("testHub=${{inputs.testHub}}") + cmdArgs+=("testADU=${{inputs.testADU}}") + cmdArgs+=("testADUupdate=${{inputs.testADUupdate}}") + echo "Running: az pipelines run ${cmdArgs[@]}" + res=$(az pipelines run "${cmdArgs[@]}") + + if [ -z "$res" ]; then + echo "::error::Failed to trigger the pipeline" + fi + runId=$(echo $res | jq -r '.id') + portalUrl="https://dev.azure.com/$ORG/$PROJECT/_build/results?buildId=$runId&view=results" + url=$(echo $res | jq -r '.url') + echo "runId=$runId" >> $GITHUB_OUTPUT + echo "portalUrl=$portalUrl" >> $GITHUB_OUTPUT + echo "url=$url" >> $GITHUB_OUTPUT + - name: Summary + id: summary + run: |- + echo "# ${PIPELINE:-$DEFAULT_TITLE} Started" >> $GITHUB_STEP_SUMMARY + echo "## Azure DevOps Pipeline" >> $GITHUB_STEP_SUMMARY + echo "You can follow the progress [here](${{ steps.start.outputs.portalUrl }})" >> $GITHUB_STEP_SUMMARY + + wait-for-completion: + runs-on: ubuntu-latest + name: Wait for the pipeline to complete + needs: [call-ado-pipeline] + env: + SHOW_LOGS: ${{ inputs.showLogs }} + RUN_ID: ${{ needs.call-ado-pipeline.outputs.runId }} + PORTAL_URL: ${{ needs.call-ado-pipeline.outputs.portalUrl }} + steps: + - name: Wait for the pipeline to complete + run: | + set -e + runId="${{ needs.call-ado-pipeline.outputs.runId }}" + status="none" + result="none" + lastLog=1 + while [[ "$status" =~ (inProgress|notStarted|postponed|none) ]]; do + sleep 60 + res=$(az pipelines runs show --id "$RUN_ID" --org "https://dev.azure.com/$ORG" --project "$PROJECT") + status=$(echo "$res" | jq -r '.status') + result=$(echo "$res" | jq -r '.result') + logsUrl=$(echo "$res" | jq -r '.logs.url') + logsList=$(curl -s -u ":$AZURE_DEVOPS_EXT_PAT" -H "Content-Type: application/json" -X GET "$logsUrl") + count=$(echo $logsList | jq -r '.count') + + if [[ "$SHOW_LOGS" == "false" ]]; then + continue + fi + + # we skip the first log as it's the pipeline template + # also we want to log up to n-1 logs because the current log is still being written to + + items=$(echo $logsList | jq -r '.value') + if [[ $count -gt 1 ]]; then + for i in $(seq $(($lastLog+1)) $(($count-1))); do + log="${logsUrl}/$i" # or we can use jq to get the log url from each item + curl -s -u ":$AZURE_DEVOPS_EXT_PAT" -H "Content-Type: application/json" -X GET "$log" + lastLog=$i + echo "====================================================================================================" + echo "Logs are streaming in. For more realtime structured logs, check ${PORTAL_URL}" + echo "====================================================================================================" + sleep 2 + done + fi + done + + # if status is not completed, or the result is one of failed, canceled; then fail the job + if [[ "$status" != "completed" || "$result" =~ (failed|canceled) ]]; then + echo "::error::Pipeline did not complete successfully" + echo "# ❌ ${PIPELINE:-$DEFAULT_TITLE} Failed ❌" >> $GITHUB_STEP_SUMMARY + echo "The pipeline did not complete successfully. Please check the logs [here](${PORTAL_URL})" >> $GITHUB_STEP_SUMMARY + exit 1 + fi + + if [[ "$SHOW_LOGS" == "true" ]]; then + # curl the last log + curl -s -u ":$AZURE_DEVOPS_EXT_PAT" -H "Content-Type: application/json" -X GET "${logsUrl}/${count}" + fi + + echo "# ✅ ${PIPELINE:-$DEFAULT_TITLE} Completed ✅" >> $GITHUB_STEP_SUMMARY + echo "The pipeline completed successfully. You can check the logs [here](${PORTAL_URL})" >> $GITHUB_STEP_SUMMARY + CancelPipeline: + runs-on: ubuntu-latest + needs: [call-ado-pipeline, wait-for-completion] + if: cancelled() + env: + RUN_ID: ${{ needs.call-ado-pipeline.outputs.runId }} + RUN_URL: ${{ needs.call-ado-pipeline.outputs.url }} + PORTAL_URL: ${{ needs.call-ado-pipeline.outputs.portalUrl }} + steps: + - name: Cancel the pipeline + run: | + set -ex + if [[ -z "$RUN_ID" ]]; then + echo "No pipeline to cancel" + exit 0 + fi + + curl \ + -X PATCH \ + -u ":$AZURE_DEVOPS_EXT_PAT" \ + -H "Content-Type: application/json" \ + -d '{"status": "cancelling"}' \ + "${RUN_URL}?api-version=7.2-preview.7" + echo "# ❌ ${PIPELINE:-$DEFAULT_TITLE} Cancelled ❌" >> $GITHUB_STEP_SUMMARY + echo "The pipeline was cancelled. You can check the logs [here](${PORTAL_URL})" >> $GITHUB_STEP_SUMMARY From 3dd8efa1c4d013e6178effaddd60b2c2430b110b Mon Sep 17 00:00:00 2001 From: Ryan Kelly Date: Thu, 30 May 2024 10:41:54 -0700 Subject: [PATCH 09/22] remove debug switch and change to correct branch --- .github/workflows/trigger_ado_int_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger_ado_int_tests.yml b/.github/workflows/trigger_ado_int_tests.yml index befb38736..4dc8868e0 100644 --- a/.github/workflows/trigger_ado_int_tests.yml +++ b/.github/workflows/trigger_ado_int_tests.yml @@ -116,7 +116,7 @@ jobs: exit 1 fi - cmdArgs=(--org "https://dev.azure.com/$ORG" --project "$PROJECT" --branch "add_ado_int_tests" --debug) + cmdArgs=(--org "https://dev.azure.com/$ORG" --project "$PROJECT" --branch "ado_tests") if [ -n "$DEFINITION_ID" ]; then cmdArgs+=(--id "$DEFINITION_ID") From 37fb3dfe170205a221ae455cd0747cf7b05014d0 Mon Sep 17 00:00:00 2001 From: Ryan Kelly Date: Thu, 30 May 2024 10:44:40 -0700 Subject: [PATCH 10/22] stringify python mapping --- .github/workflows/trigger_ado_int_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/trigger_ado_int_tests.yml b/.github/workflows/trigger_ado_int_tests.yml index 4dc8868e0..4f55b90f9 100644 --- a/.github/workflows/trigger_ado_int_tests.yml +++ b/.github/workflows/trigger_ado_int_tests.yml @@ -82,11 +82,11 @@ on: required: true type: string default: > - { + "{ Python38: { python: '3.8' }, Python39: { python: '3.9' }, Python310: { python: '3.10' } - } + }" env: DEFAULT_TITLE: "Azure DevOps Pipeline" AZURE_DEVOPS_EXT_PAT: ${{ secrets.ADO_PAT }} From 2b6d11a539055357b4db065a409ddeea980385df Mon Sep 17 00:00:00 2001 From: Ryan Kelly Date: Thu, 30 May 2024 10:49:44 -0700 Subject: [PATCH 11/22] more quotes --- .github/workflows/trigger_ado_int_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger_ado_int_tests.yml b/.github/workflows/trigger_ado_int_tests.yml index 4f55b90f9..2ddf1ba95 100644 --- a/.github/workflows/trigger_ado_int_tests.yml +++ b/.github/workflows/trigger_ado_int_tests.yml @@ -126,7 +126,7 @@ jobs: fi cmdArgs+=("--parameters") - cmdArgs+=("pythonVersionsTestingMatrix=${{inputs.python_versions}}") + cmdArgs+=("pythonVersionsTestingMatrix=\"${{inputs.python_versions}}\") cmdArgs+=("testCentral=${{inputs.testCentral}}") cmdArgs+=("testADT=${{inputs.testADT}}") cmdArgs+=("testDPS=${{inputs.testDPS}}") From f5e0db1e31049820906ddbf52e1a1e1016c94c7e Mon Sep 17 00:00:00 2001 From: Ryan Kelly Date: Thu, 30 May 2024 11:19:00 -0700 Subject: [PATCH 12/22] python stringification testing --- .github/workflows/trigger_ado_int_tests.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/trigger_ado_int_tests.yml b/.github/workflows/trigger_ado_int_tests.yml index 2ddf1ba95..78a50d9d2 100644 --- a/.github/workflows/trigger_ado_int_tests.yml +++ b/.github/workflows/trigger_ado_int_tests.yml @@ -125,8 +125,14 @@ jobs: exit 1 fi + python_versions=${{inputs.python_versions}} + echo "input: " + echo $python_versions + python_version_strings=$(echo $python_versions | jq -R .) + echo "stringified: " + echo "python_version_strings" cmdArgs+=("--parameters") - cmdArgs+=("pythonVersionsTestingMatrix=\"${{inputs.python_versions}}\") + cmdArgs+=("pythonVersionsTestingMatrix=$python_version_strings") cmdArgs+=("testCentral=${{inputs.testCentral}}") cmdArgs+=("testADT=${{inputs.testADT}}") cmdArgs+=("testDPS=${{inputs.testDPS}}") From fc87e49d0541c1585bbbf2f261fbb42d52e7ff63 Mon Sep 17 00:00:00 2001 From: Ryan Kelly Date: Thu, 30 May 2024 15:38:12 -0700 Subject: [PATCH 13/22] Put ADU tests back in parallelization --- .azure-devops/integration_tests.yml | 8 ++-- .../templates/run-tests-parallel.yml | 12 +++--- .azure-devops/templates/trigger-tests.yml | 40 +++++++++---------- .github/workflows/trigger_ado_int_tests.yml | 22 +++++----- 4 files changed, 40 insertions(+), 42 deletions(-) diff --git a/.azure-devops/integration_tests.yml b/.azure-devops/integration_tests.yml index 4c984ed8b..da64d386d 100644 --- a/.azure-devops/integration_tests.yml +++ b/.azure-devops/integration_tests.yml @@ -61,9 +61,9 @@ parameters: type: boolean default: true # These tests currently time out with federated credentials and must be tested locally -- name: 'testADUupdate' - type: boolean - default: false +# - name: 'testADUupdate' +# type: boolean +# default: false variables: - group: ${{ parameters.variableGroup }} @@ -127,7 +127,7 @@ stages: testDPS: ${{ parameters.testDPS }} testHub: ${{ parameters.testHub }} testADU: ${{ parameters.testADU }} - testADUupdate: ${{ parameters.testADUupdate }} + # testADUupdate: ${{ parameters.testADUupdate }} maxParallelADT: 2 maxParallelDPS: 2 maxParallelHub: 2 diff --git a/.azure-devops/templates/run-tests-parallel.yml b/.azure-devops/templates/run-tests-parallel.yml index 91d0a49cd..99c20a635 100644 --- a/.azure-devops/templates/run-tests-parallel.yml +++ b/.azure-devops/templates/run-tests-parallel.yml @@ -40,6 +40,7 @@ parameters: type: object default: - 'azext_iot/tests/digitaltwins' + - 'azext_iot/tests/deviceupdate' steps: - checkout: self @@ -79,11 +80,12 @@ steps: inlineScript: | export COVERAGE_FILE=.coverage.${{ parameters.name }} pytest -vv ${{ parameters.path }} -k "_int.py" --dist=loadfile -n ${{ parameters.num_threads }} --reruns ${{ parameters.num_reruns }} --reruns-delay ${{ parameters.reruns_delay }} --cov=azext_iot --cov-config .coveragerc --junitxml=junit/test-iotext-int.xml --durations=0 - # no parallelization on specific adu update tests (test_adu_update_int.py) - ${{ if contains(parameters.path, 'azext_iot/tests/deviceupdate/test_adu_update') }}: - inlineScript: | - export COVERAGE_FILE=.coverage.${{ parameters.name }} - pytest -vv ${{ parameters.path }} -k "_int.py" --cov=azext_iot --cov-config .coveragerc --junitxml=junit/test-iotext-int.xml + # exclude test_adu_update_int tests due to test failures / token timeouts + # ${{ if contains(parameters.path, 'azext_iot/tests/deviceupdate') }}: + # inlineScript: | + # export COVERAGE_FILE=.coverage.${{ parameters.name }} + # pytest -vv ${{ parameters.path }} -k "_int.py" --ignore=azext_iot/tests/deviceupdate/test_adu_update_int.py --dist=loadfile -n ${{ parameters.num_threads }} --reruns ${{ parameters.num_reruns }} --reruns-delay ${{ parameters.reruns_delay }} --cov=azext_iot --cov-config .coveragerc --junitxml=junit/test-iotext-int.xml + # remove parallelization from central tests ${{ if contains(parameters.path, 'azext_iot/tests/central') }}: inlineScript: | export COVERAGE_FILE=.coverage.${{ parameters.name }} diff --git a/.azure-devops/templates/trigger-tests.yml b/.azure-devops/templates/trigger-tests.yml index 31368c382..ddd838ca3 100644 --- a/.azure-devops/templates/trigger-tests.yml +++ b/.azure-devops/templates/trigger-tests.yml @@ -24,9 +24,9 @@ parameters: - name: 'testADU' type: boolean default: true -- name: 'testADUupdate' - type: boolean - default: true +# - name: 'testADUupdate' +# type: boolean +# default: true - name: 'maxParallelCentral' type: number default: 1 @@ -137,7 +137,7 @@ jobs: steps: - template: run-tests-parallel.yml parameters: - path: 'azext_iot/tests/deviceupdate --ignore=azext_iot/tests/deviceupdate/test_adu_update_int.py' + path: 'azext_iot/tests/deviceupdate' name: 'azure-deviceupdate' azureCLIVersion: ${{ parameters.azureCLIVersion }} pythonVersion: $(python) @@ -145,22 +145,22 @@ jobs: serviceConnection: $(AzureServiceConnection) # Splitting up adu update tests due to timeout failures and other inconsistencies -- job: 'testADUupdate' - timeoutInMinutes: 90 - displayName: 'Test ADU Update' - condition: and(succeeded(), eq('${{ parameters.testADUupdate }}', true)) - strategy: - matrix: $[ variables['pythonVersions'] ] - maxParallel: ${{ parameters.maxParallelADU }} - steps: - - template: run-tests-parallel.yml - parameters: - path: 'azext_iot/tests/deviceupdate/test_adu_update_int.py' - name: 'azure-deviceupdate-update' - azureCLIVersion: ${{ parameters.azureCLIVersion }} - pythonVersion: $(python) - num_reruns: 0 - serviceConnection: $(AzureServiceConnection) +# - job: 'testADUupdate' +# timeoutInMinutes: 90 +# displayName: 'Test ADU Update' +# condition: and(succeeded(), eq('${{ parameters.testADUupdate }}', true)) +# strategy: +# matrix: $[ variables['pythonVersions'] ] +# maxParallel: ${{ parameters.maxParallelADU }} +# steps: +# - template: run-tests-parallel.yml +# parameters: +# path: 'azext_iot/tests/deviceupdate/test_adu_update_int.py' +# name: 'azure-deviceupdate-update' +# azureCLIVersion: ${{ parameters.azureCLIVersion }} +# pythonVersion: $(python) +# num_reruns: 0 +# serviceConnection: $(AzureServiceConnection) - job: 'unitTests' displayName: 'Unit tests and code coverage' diff --git a/.github/workflows/trigger_ado_int_tests.yml b/.github/workflows/trigger_ado_int_tests.yml index 78a50d9d2..d08edaaeb 100644 --- a/.github/workflows/trigger_ado_int_tests.yml +++ b/.github/workflows/trigger_ado_int_tests.yml @@ -28,10 +28,10 @@ on: type: boolean default: true # These tests currently time out with federated credentials and must be tested locally - testADUupdate: - description: Run ADU update tests - type: boolean - default: false + # testADUupdate: + # description: Run ADU update tests + # type: boolean + # default: false python_versions: description: "Python versions to test" required: true @@ -73,10 +73,10 @@ on: type: boolean default: true # These tests currently time out with federated credentials and must be tested locally - testADUupdate: - description: Run ADU update tests - type: boolean - default: false + # testADUupdate: + # description: Run ADU update tests + # type: boolean + # default: false python_versions: description: "Python versions to test" required: true @@ -126,11 +126,7 @@ jobs: fi python_versions=${{inputs.python_versions}} - echo "input: " - echo $python_versions python_version_strings=$(echo $python_versions | jq -R .) - echo "stringified: " - echo "python_version_strings" cmdArgs+=("--parameters") cmdArgs+=("pythonVersionsTestingMatrix=$python_version_strings") cmdArgs+=("testCentral=${{inputs.testCentral}}") @@ -138,7 +134,7 @@ jobs: cmdArgs+=("testDPS=${{inputs.testDPS}}") cmdArgs+=("testHub=${{inputs.testHub}}") cmdArgs+=("testADU=${{inputs.testADU}}") - cmdArgs+=("testADUupdate=${{inputs.testADUupdate}}") + # cmdArgs+=("testADUupdate=${{inputs.testADUupdate}}") echo "Running: az pipelines run ${cmdArgs[@]}" res=$(az pipelines run "${cmdArgs[@]}") From fe787aef1e06b04e239fbc125f563e4523cc45aa Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 31 May 2024 09:34:36 -0700 Subject: [PATCH 14/22] add integration tests to release workflow --- .github/workflows/release_workflow.yml | 4 ++++ .github/workflows/trigger_ado_int_tests.yml | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release_workflow.yml b/.github/workflows/release_workflow.yml index f65ce1784..47125f211 100644 --- a/.github/workflows/release_workflow.yml +++ b/.github/workflows/release_workflow.yml @@ -34,6 +34,10 @@ jobs: uses: ./.github/workflows/azdev_linter.yml with: continue-on-error: ${{ github.event.inputs.continue-on-error == 'true' }} + int_test: + needs: [build] + uses: ./.github/workflows/trigger_ado_int_tests.yml + secrets: inherit approval: needs: [security, build, unit-test, azdev_linter] # only needed if (release || wheel) - conditionals allow previous jobs to be skipped and still run diff --git a/.github/workflows/trigger_ado_int_tests.yml b/.github/workflows/trigger_ado_int_tests.yml index d08edaaeb..d0ab52409 100644 --- a/.github/workflows/trigger_ado_int_tests.yml +++ b/.github/workflows/trigger_ado_int_tests.yml @@ -34,7 +34,6 @@ on: # default: false python_versions: description: "Python versions to test" - required: true type: string default: > { From b7098ed8b356274a5e9351a55e254afcced67bfb Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 31 May 2024 14:54:04 -0700 Subject: [PATCH 15/22] Disable 1ES pool for pipeline test --- .github/workflows/release_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_build.yml b/.github/workflows/release_build.yml index 5412c1bc2..a2bd447f6 100644 --- a/.github/workflows/release_build.yml +++ b/.github/workflows/release_build.yml @@ -4,7 +4,7 @@ on: jobs: build: - runs-on: [self-hosted, 1ES.Pool=iotupx-iot-cli-github-hosted-pool, 1ES.ImageOverride=Ubuntu20.04Compliant] + runs-on: ubuntu-latest # [self-hosted, 1ES.Pool=iotupx-iot-cli-github-hosted-pool, 1ES.ImageOverride=Ubuntu20.04Compliant] permissions: contents: read steps: From 116b750cc06686293db7297b5a59cb9b66a67045 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 31 May 2024 15:08:41 -0700 Subject: [PATCH 16/22] quotes --- .github/workflows/trigger_ado_int_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/trigger_ado_int_tests.yml b/.github/workflows/trigger_ado_int_tests.yml index d0ab52409..dde799e80 100644 --- a/.github/workflows/trigger_ado_int_tests.yml +++ b/.github/workflows/trigger_ado_int_tests.yml @@ -36,11 +36,11 @@ on: description: "Python versions to test" type: string default: > - { + "{ Python38: { python: '3.8' }, Python39: { python: '3.9' }, Python310: { python: '3.10' } - } + }" secrets: ADO_PAT: required: true From bb449396018ce3b6974d6d1fa39adc2ff6949fc0 Mon Sep 17 00:00:00 2001 From: Ryan Kelly Date: Tue, 4 Jun 2024 10:46:12 -0700 Subject: [PATCH 17/22] Removed unused steps and params --- .azure-devops/integration_tests.yml | 5 ----- .../templates/run-tests-parallel.yml | 5 ----- .azure-devops/templates/trigger-tests.yml | 21 ------------------- .github/workflows/trigger_ado_int_tests.yml | 10 --------- 4 files changed, 41 deletions(-) diff --git a/.azure-devops/integration_tests.yml b/.azure-devops/integration_tests.yml index da64d386d..7d9520e7c 100644 --- a/.azure-devops/integration_tests.yml +++ b/.azure-devops/integration_tests.yml @@ -60,10 +60,6 @@ parameters: - name: 'testADU' type: boolean default: true -# These tests currently time out with federated credentials and must be tested locally -# - name: 'testADUupdate' -# type: boolean -# default: false variables: - group: ${{ parameters.variableGroup }} @@ -127,7 +123,6 @@ stages: testDPS: ${{ parameters.testDPS }} testHub: ${{ parameters.testHub }} testADU: ${{ parameters.testADU }} - # testADUupdate: ${{ parameters.testADUupdate }} maxParallelADT: 2 maxParallelDPS: 2 maxParallelHub: 2 diff --git a/.azure-devops/templates/run-tests-parallel.yml b/.azure-devops/templates/run-tests-parallel.yml index 99c20a635..9a0c9a899 100644 --- a/.azure-devops/templates/run-tests-parallel.yml +++ b/.azure-devops/templates/run-tests-parallel.yml @@ -80,11 +80,6 @@ steps: inlineScript: | export COVERAGE_FILE=.coverage.${{ parameters.name }} pytest -vv ${{ parameters.path }} -k "_int.py" --dist=loadfile -n ${{ parameters.num_threads }} --reruns ${{ parameters.num_reruns }} --reruns-delay ${{ parameters.reruns_delay }} --cov=azext_iot --cov-config .coveragerc --junitxml=junit/test-iotext-int.xml --durations=0 - # exclude test_adu_update_int tests due to test failures / token timeouts - # ${{ if contains(parameters.path, 'azext_iot/tests/deviceupdate') }}: - # inlineScript: | - # export COVERAGE_FILE=.coverage.${{ parameters.name }} - # pytest -vv ${{ parameters.path }} -k "_int.py" --ignore=azext_iot/tests/deviceupdate/test_adu_update_int.py --dist=loadfile -n ${{ parameters.num_threads }} --reruns ${{ parameters.num_reruns }} --reruns-delay ${{ parameters.reruns_delay }} --cov=azext_iot --cov-config .coveragerc --junitxml=junit/test-iotext-int.xml # remove parallelization from central tests ${{ if contains(parameters.path, 'azext_iot/tests/central') }}: inlineScript: | diff --git a/.azure-devops/templates/trigger-tests.yml b/.azure-devops/templates/trigger-tests.yml index ddd838ca3..dfb86ba08 100644 --- a/.azure-devops/templates/trigger-tests.yml +++ b/.azure-devops/templates/trigger-tests.yml @@ -24,9 +24,6 @@ parameters: - name: 'testADU' type: boolean default: true -# - name: 'testADUupdate' -# type: boolean -# default: true - name: 'maxParallelCentral' type: number default: 1 @@ -143,24 +140,6 @@ jobs: pythonVersion: $(python) num_reruns: 0 serviceConnection: $(AzureServiceConnection) - -# Splitting up adu update tests due to timeout failures and other inconsistencies -# - job: 'testADUupdate' -# timeoutInMinutes: 90 -# displayName: 'Test ADU Update' -# condition: and(succeeded(), eq('${{ parameters.testADUupdate }}', true)) -# strategy: -# matrix: $[ variables['pythonVersions'] ] -# maxParallel: ${{ parameters.maxParallelADU }} -# steps: -# - template: run-tests-parallel.yml -# parameters: -# path: 'azext_iot/tests/deviceupdate/test_adu_update_int.py' -# name: 'azure-deviceupdate-update' -# azureCLIVersion: ${{ parameters.azureCLIVersion }} -# pythonVersion: $(python) -# num_reruns: 0 -# serviceConnection: $(AzureServiceConnection) - job: 'unitTests' displayName: 'Unit tests and code coverage' diff --git a/.github/workflows/trigger_ado_int_tests.yml b/.github/workflows/trigger_ado_int_tests.yml index dde799e80..6f714945a 100644 --- a/.github/workflows/trigger_ado_int_tests.yml +++ b/.github/workflows/trigger_ado_int_tests.yml @@ -27,11 +27,6 @@ on: description: Run ADU tests type: boolean default: true - # These tests currently time out with federated credentials and must be tested locally - # testADUupdate: - # description: Run ADU update tests - # type: boolean - # default: false python_versions: description: "Python versions to test" type: string @@ -71,11 +66,6 @@ on: description: Run ADU tests type: boolean default: true - # These tests currently time out with federated credentials and must be tested locally - # testADUupdate: - # description: Run ADU update tests - # type: boolean - # default: false python_versions: description: "Python versions to test" required: true From b41d83b116d7c3689707057dddb61b9ff81aaea2 Mon Sep 17 00:00:00 2001 From: Ryan Kelly Date: Tue, 4 Jun 2024 11:02:16 -0700 Subject: [PATCH 18/22] Remove JIT role assignment due to graph permissions query in 'role assignment create' causing issues --- azext_iot/tests/deviceupdate/conftest.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/azext_iot/tests/deviceupdate/conftest.py b/azext_iot/tests/deviceupdate/conftest.py index b2adfd1be..0f3c97ec2 100644 --- a/azext_iot/tests/deviceupdate/conftest.py +++ b/azext_iot/tests/deviceupdate/conftest.py @@ -300,18 +300,6 @@ def _iothub_provisioner(request) -> Optional[dict]: if desired_instance_count: hub_id_map = {} hub_names = [] - - # Assign Data Contributor role to resource group if it does not exist - # account = cli.invoke("account show").as_json() - # scope_id = "/subscriptions/{}/resourceGroups/{}".format( - # account["id"], - # ACCOUNT_RG - # ) - # assign_role_assignment( - # role="IoT Hub Data Contributor", - # scope=scope_id, - # assignee=AUTH_RESOURCE_ID) - for _ in range(desired_instance_count): target_name = generate_linked_hub_id() create_result = cli.invoke(f"iot hub create -g {ACCOUNT_RG} -n {target_name}") From d7a418db8d4c653aa03cffdb93d62bd95c3a3918 Mon Sep 17 00:00:00 2001 From: Ryan Kelly Date: Tue, 4 Jun 2024 13:03:19 -0700 Subject: [PATCH 19/22] remove extra unused line --- .github/workflows/trigger_ado_int_tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/trigger_ado_int_tests.yml b/.github/workflows/trigger_ado_int_tests.yml index 6f714945a..18f29f962 100644 --- a/.github/workflows/trigger_ado_int_tests.yml +++ b/.github/workflows/trigger_ado_int_tests.yml @@ -123,7 +123,6 @@ jobs: cmdArgs+=("testDPS=${{inputs.testDPS}}") cmdArgs+=("testHub=${{inputs.testHub}}") cmdArgs+=("testADU=${{inputs.testADU}}") - # cmdArgs+=("testADUupdate=${{inputs.testADUupdate}}") echo "Running: az pipelines run ${cmdArgs[@]}" res=$(az pipelines run "${cmdArgs[@]}") From 307357ff7c0846de582da7cbd285e594cd745504 Mon Sep 17 00:00:00 2001 From: Ryan Kelly Date: Tue, 4 Jun 2024 13:09:32 -0700 Subject: [PATCH 20/22] Remove log streaming capability from external pipeline caller workflow --- .github/workflows/trigger_ado_int_tests.yml | 39 --------------------- 1 file changed, 39 deletions(-) diff --git a/.github/workflows/trigger_ado_int_tests.yml b/.github/workflows/trigger_ado_int_tests.yml index 18f29f962..fbc8f1369 100644 --- a/.github/workflows/trigger_ado_int_tests.yml +++ b/.github/workflows/trigger_ado_int_tests.yml @@ -2,11 +2,6 @@ name: Run Azure DevOps Integration Tests on: workflow_call: inputs: - showLogs: - description: "Show logs" - required: false - type: boolean - default: false testCentral: description: Run Central tests type: boolean @@ -41,11 +36,6 @@ on: required: true workflow_dispatch: inputs: - showLogs: - description: "Show logs" - required: false - type: boolean - default: false testCentral: description: Run Central tests type: boolean @@ -147,7 +137,6 @@ jobs: name: Wait for the pipeline to complete needs: [call-ado-pipeline] env: - SHOW_LOGS: ${{ inputs.showLogs }} RUN_ID: ${{ needs.call-ado-pipeline.outputs.runId }} PORTAL_URL: ${{ needs.call-ado-pipeline.outputs.portalUrl }} steps: @@ -163,29 +152,6 @@ jobs: res=$(az pipelines runs show --id "$RUN_ID" --org "https://dev.azure.com/$ORG" --project "$PROJECT") status=$(echo "$res" | jq -r '.status') result=$(echo "$res" | jq -r '.result') - logsUrl=$(echo "$res" | jq -r '.logs.url') - logsList=$(curl -s -u ":$AZURE_DEVOPS_EXT_PAT" -H "Content-Type: application/json" -X GET "$logsUrl") - count=$(echo $logsList | jq -r '.count') - - if [[ "$SHOW_LOGS" == "false" ]]; then - continue - fi - - # we skip the first log as it's the pipeline template - # also we want to log up to n-1 logs because the current log is still being written to - - items=$(echo $logsList | jq -r '.value') - if [[ $count -gt 1 ]]; then - for i in $(seq $(($lastLog+1)) $(($count-1))); do - log="${logsUrl}/$i" # or we can use jq to get the log url from each item - curl -s -u ":$AZURE_DEVOPS_EXT_PAT" -H "Content-Type: application/json" -X GET "$log" - lastLog=$i - echo "====================================================================================================" - echo "Logs are streaming in. For more realtime structured logs, check ${PORTAL_URL}" - echo "====================================================================================================" - sleep 2 - done - fi done # if status is not completed, or the result is one of failed, canceled; then fail the job @@ -196,11 +162,6 @@ jobs: exit 1 fi - if [[ "$SHOW_LOGS" == "true" ]]; then - # curl the last log - curl -s -u ":$AZURE_DEVOPS_EXT_PAT" -H "Content-Type: application/json" -X GET "${logsUrl}/${count}" - fi - echo "# ✅ ${PIPELINE:-$DEFAULT_TITLE} Completed ✅" >> $GITHUB_STEP_SUMMARY echo "The pipeline completed successfully. You can check the logs [here](${PORTAL_URL})" >> $GITHUB_STEP_SUMMARY CancelPipeline: From 41bdb96c7f4dabd72a86bcf114534ccacab889dc Mon Sep 17 00:00:00 2001 From: Ryan Kelly Date: Tue, 4 Jun 2024 16:07:40 -0700 Subject: [PATCH 21/22] Revert "Disable 1ES pool for pipeline test" This reverts commit b7098ed8b356274a5e9351a55e254afcced67bfb. --- .github/workflows/release_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_build.yml b/.github/workflows/release_build.yml index a2bd447f6..5412c1bc2 100644 --- a/.github/workflows/release_build.yml +++ b/.github/workflows/release_build.yml @@ -4,7 +4,7 @@ on: jobs: build: - runs-on: ubuntu-latest # [self-hosted, 1ES.Pool=iotupx-iot-cli-github-hosted-pool, 1ES.ImageOverride=Ubuntu20.04Compliant] + runs-on: [self-hosted, 1ES.Pool=iotupx-iot-cli-github-hosted-pool, 1ES.ImageOverride=Ubuntu20.04Compliant] permissions: contents: read steps: From 4068ec05d1b57cf3769e52e6b842817527e0e8a4 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 5 Jun 2024 10:58:24 -0700 Subject: [PATCH 22/22] Use github branch ref to pick which branch to run pipeline from --- .github/workflows/trigger_ado_int_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger_ado_int_tests.yml b/.github/workflows/trigger_ado_int_tests.yml index fbc8f1369..d1595fd0b 100644 --- a/.github/workflows/trigger_ado_int_tests.yml +++ b/.github/workflows/trigger_ado_int_tests.yml @@ -95,7 +95,7 @@ jobs: exit 1 fi - cmdArgs=(--org "https://dev.azure.com/$ORG" --project "$PROJECT" --branch "ado_tests") + cmdArgs=(--org "https://dev.azure.com/$ORG" --project "$PROJECT" --branch "${{ github.ref }}") if [ -n "$DEFINITION_ID" ]; then cmdArgs+=(--id "$DEFINITION_ID")