From 2a74d26675bbbc615d5ad4dd2569037b2cccc022 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Thu, 14 Mar 2024 11:06:26 -0700 Subject: [PATCH 1/8] create necessary eng/common changes to allow proxy to be shut down. add a test job which will be later deleted to test this --- .../templates/jobs/test-proxy-shutdown.yml | 40 +++++++++++++++++++ .../testproxy/test-proxy-tool-shutdown.yml | 12 ++++++ eng/common/testproxy/test-proxy-tool.yml | 6 ++- 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml create mode 100644 eng/common/testproxy/test-proxy-tool-shutdown.yml diff --git a/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml b/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml new file mode 100644 index 0000000000000..97f218e70880b --- /dev/null +++ b/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml @@ -0,0 +1,40 @@ +variables: + - template: /eng/pipelines/templates/variables/globals.yml + +stages: + - stage: + displayName: Invoke Proxy Shutdown Test + jobs: + - job: Test + strategy: + matrix: + Windows: + Pool: azsdk-pool-mms-win-2022-general + Image: windows-2022 + Linux: + Pool: azsdk-pool-mms-ubuntu-2204-general + Image: ubuntu-22.04 + Mac: + Pool: Azure Pipelines + Image: macos-11 + + pool: + name: $(Pool) + vmImage: $(Image) + + steps: + - template: /eng/common/testproxy/test-proxy-tool.yml + + - pwsh: | + $(Build.BinariesDirectory)/test-proxy/test-proxy.exe restore . + displayName: Generate some proxy logs windows + condition: and(succeeded(), ne(variables['Agent.OS'],'Windows_NT'), ${{ parameters.condition }}) + + - pwsh: | + $(Build.BinariesDirectory)/test-proxy/test-proxy restore . + displayName: Generate some proxy logs linux + continueOnError: true + condition: and(succeeded(), ne(variables['Agent.OS'],'Windows_NT'), ${{ parameters.condition }}) + + - template: /eng/common/testproxy/test-proxy-tool-shutdown.yml + diff --git a/eng/common/testproxy/test-proxy-tool-shutdown.yml b/eng/common/testproxy/test-proxy-tool-shutdown.yml new file mode 100644 index 0000000000000..31a13c9db811d --- /dev/null +++ b/eng/common/testproxy/test-proxy-tool-shutdown.yml @@ -0,0 +1,12 @@ +steps: + - pwsh: | + Stop-Process -Id $(PROXY_PID) + displayName: 'Shut down the testproxy - windows' + condition: and(succeeded(), eq(variables['Agent.OS'],'Windows_NT')) + + # nohup does NOT continue beyond the current session if you use it within powershell + - bash: | + kill -9 $(PROXY_PID) + displayName: "Shut down the testproxy - linux/mac" + condition: and(succeeded(), ne(variables['Agent.OS'],'Windows_NT')) + workingDirectory: "${{ parameters.rootFolder }}" diff --git a/eng/common/testproxy/test-proxy-tool.yml b/eng/common/testproxy/test-proxy-tool.yml index 7aea55d472d22..e165fa59ab000 100644 --- a/eng/common/testproxy/test-proxy-tool.yml +++ b/eng/common/testproxy/test-proxy-tool.yml @@ -1,3 +1,4 @@ +# This template sets variable PROXY_PID to be used for shutdown later. parameters: rootFolder: '$(Build.SourcesDirectory)' runProxy: true @@ -42,15 +43,18 @@ steps: condition: and(succeeded(), ${{ parameters.condition }}) - pwsh: | - Start-Process $(Build.BinariesDirectory)/test-proxy/test-proxy.exe ` + $Process = Start-Process $(Build.BinariesDirectory)/test-proxy/test-proxy.exe ` -ArgumentList "start --storage-location ${{ parameters.rootFolder }} -U" ` -NoNewWindow -PassThru -RedirectStandardOutput ${{ parameters.rootFolder }}/test-proxy.log + + WriteHost "##vso[task.setvariable variable=PROXY_PID]$($Process.Id)" displayName: 'Run the testproxy - windows' condition: and(succeeded(), eq(variables['Agent.OS'],'Windows_NT'), ${{ parameters.condition }}) # nohup does NOT continue beyond the current session if you use it within powershell - bash: | nohup $(Build.BinariesDirectory)/test-proxy/test-proxy &>$(Build.SourcesDirectory)/test-proxy.log & + "##vso[task.setvariable variable=PROXY_PID]$!" displayName: "Run the testproxy - linux/mac" condition: and(succeeded(), ne(variables['Agent.OS'],'Windows_NT'), ${{ parameters.condition }}) workingDirectory: "${{ parameters.rootFolder }}" From e43179c4545ab39957b9fc06e087c08ffe00f713 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Thu, 14 Mar 2024 11:13:22 -0700 Subject: [PATCH 2/8] actually fix the yaml updates --- eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml | 4 ++-- eng/common/testproxy/test-proxy-tool-shutdown.yml | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml b/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml index 97f218e70880b..0995d6cc5ec22 100644 --- a/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml +++ b/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml @@ -28,13 +28,13 @@ stages: - pwsh: | $(Build.BinariesDirectory)/test-proxy/test-proxy.exe restore . displayName: Generate some proxy logs windows - condition: and(succeeded(), ne(variables['Agent.OS'],'Windows_NT'), ${{ parameters.condition }}) + condition: and(succeeded(), ne(variables['Agent.OS'],'Windows_NT')) - pwsh: | $(Build.BinariesDirectory)/test-proxy/test-proxy restore . displayName: Generate some proxy logs linux continueOnError: true - condition: and(succeeded(), ne(variables['Agent.OS'],'Windows_NT'), ${{ parameters.condition }}) + condition: and(succeeded(), ne(variables['Agent.OS'],'Windows_NT')) - template: /eng/common/testproxy/test-proxy-tool-shutdown.yml diff --git a/eng/common/testproxy/test-proxy-tool-shutdown.yml b/eng/common/testproxy/test-proxy-tool-shutdown.yml index 31a13c9db811d..ab2955e65a74f 100644 --- a/eng/common/testproxy/test-proxy-tool-shutdown.yml +++ b/eng/common/testproxy/test-proxy-tool-shutdown.yml @@ -9,4 +9,3 @@ steps: kill -9 $(PROXY_PID) displayName: "Shut down the testproxy - linux/mac" condition: and(succeeded(), ne(variables['Agent.OS'],'Windows_NT')) - workingDirectory: "${{ parameters.rootFolder }}" From dc58e1142f09e7e0911803ae7f297fc84fea53a0 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Thu, 14 Mar 2024 11:17:43 -0700 Subject: [PATCH 3/8] fix the callsites --- eng/common/testproxy/test-proxy-tool.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eng/common/testproxy/test-proxy-tool.yml b/eng/common/testproxy/test-proxy-tool.yml index e165fa59ab000..d9a1668419263 100644 --- a/eng/common/testproxy/test-proxy-tool.yml +++ b/eng/common/testproxy/test-proxy-tool.yml @@ -47,14 +47,16 @@ steps: -ArgumentList "start --storage-location ${{ parameters.rootFolder }} -U" ` -NoNewWindow -PassThru -RedirectStandardOutput ${{ parameters.rootFolder }}/test-proxy.log - WriteHost "##vso[task.setvariable variable=PROXY_PID]$($Process.Id)" + Write-Host "##vso[task.setvariable variable=PROXY_PID]$($Process.Id)" displayName: 'Run the testproxy - windows' condition: and(succeeded(), eq(variables['Agent.OS'],'Windows_NT'), ${{ parameters.condition }}) # nohup does NOT continue beyond the current session if you use it within powershell - bash: | nohup $(Build.BinariesDirectory)/test-proxy/test-proxy &>$(Build.SourcesDirectory)/test-proxy.log & - "##vso[task.setvariable variable=PROXY_PID]$!" + + echo $! > $(Build.SourcesDirectory)/test-proxy.pid + echo "##vso[task.setvariable variable=PROXY_PID]$(cat $(Build.SourcesDirectory)/test-proxy.pid)" displayName: "Run the testproxy - linux/mac" condition: and(succeeded(), ne(variables['Agent.OS'],'Windows_NT'), ${{ parameters.condition }}) workingDirectory: "${{ parameters.rootFolder }}" From 05f167bf8a2ec35ee7b515fe9e9146aa75175d86 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Thu, 14 Mar 2024 11:29:32 -0700 Subject: [PATCH 4/8] now add some output so we can confirm the logs --- eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml b/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml index 0995d6cc5ec22..56816c3042545 100644 --- a/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml +++ b/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml @@ -28,7 +28,8 @@ stages: - pwsh: | $(Build.BinariesDirectory)/test-proxy/test-proxy.exe restore . displayName: Generate some proxy logs windows - condition: and(succeeded(), ne(variables['Agent.OS'],'Windows_NT')) + continueOnError: true + condition: and(succeeded(), eq(variables['Agent.OS'],'Windows_NT')) - pwsh: | $(Build.BinariesDirectory)/test-proxy/test-proxy restore . @@ -38,3 +39,4 @@ stages: - template: /eng/common/testproxy/test-proxy-tool-shutdown.yml + - template: eng/common/testproxy/publish-proxy-logs.yml \ No newline at end of file From 24f7c5686350655cda86ee53ee82ed05b66b7f8d Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Thu, 14 Mar 2024 11:29:57 -0700 Subject: [PATCH 5/8] relative -> absolute --- eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml b/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml index 56816c3042545..0fff42c2d2555 100644 --- a/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml +++ b/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml @@ -39,4 +39,4 @@ stages: - template: /eng/common/testproxy/test-proxy-tool-shutdown.yml - - template: eng/common/testproxy/publish-proxy-logs.yml \ No newline at end of file + - template: /eng/common/testproxy/publish-proxy-logs.yml \ No newline at end of file From 94bda3deacea84229ec137d342cee14ae6c6e5b6 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Thu, 14 Mar 2024 11:35:46 -0700 Subject: [PATCH 6/8] test-proxy isalive check after shutdown --- .../templates/jobs/test-proxy-shutdown.yml | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml b/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml index 0fff42c2d2555..27385859ea294 100644 --- a/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml +++ b/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml @@ -26,17 +26,31 @@ stages: - template: /eng/common/testproxy/test-proxy-tool.yml - pwsh: | - $(Build.BinariesDirectory)/test-proxy/test-proxy.exe restore . + $(Build.BinariesDirectory)/test-proxy/test-proxy.exe restore -a . displayName: Generate some proxy logs windows continueOnError: true condition: and(succeeded(), eq(variables['Agent.OS'],'Windows_NT')) - pwsh: | - $(Build.BinariesDirectory)/test-proxy/test-proxy restore . + $(Build.BinariesDirectory)/test-proxy/test-proxy restore -a . displayName: Generate some proxy logs linux continueOnError: true condition: and(succeeded(), ne(variables['Agent.OS'],'Windows_NT')) - template: /eng/common/testproxy/test-proxy-tool-shutdown.yml - - template: /eng/common/testproxy/publish-proxy-logs.yml \ No newline at end of file + - template: /eng/common/testproxy/publish-proxy-logs.yml + + - pwsh: | + for ($i = 0; $i -lt 10; $i++) { + try { + Invoke-WebRequest -Uri "http://localhost:5000/Admin/IsAlive" | Out-Null + exit 0 + } catch { + Write-Warning "Failed to successfully connect to test proxy. Retrying..." + Start-Sleep 6 + } + } + Write-Error "Could not connect to test proxy." + exit 1 + displayName: Test Proxy IsAlive \ No newline at end of file From b4a5330221e13a71c2c08988594729a904d7dc70 Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Thu, 14 Mar 2024 11:35:56 -0700 Subject: [PATCH 7/8] attempts from 10 to 2 --- eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml b/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml index 27385859ea294..7561210626fe1 100644 --- a/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml +++ b/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml @@ -42,7 +42,7 @@ stages: - template: /eng/common/testproxy/publish-proxy-logs.yml - pwsh: | - for ($i = 0; $i -lt 10; $i++) { + for ($i = 0; $i -lt 2; $i++) { try { Invoke-WebRequest -Uri "http://localhost:5000/Admin/IsAlive" | Out-Null exit 0 From 42b6bbd64945b862ed73155aff8ebb0fe3f5060b Mon Sep 17 00:00:00 2001 From: "Scott Beddall (from Dev Box)" Date: Thu, 14 Mar 2024 11:50:57 -0700 Subject: [PATCH 8/8] delete test-proxy-shutdown. remove bad comment --- .../templates/jobs/test-proxy-shutdown.yml | 56 ------------------- .../testproxy/test-proxy-tool-shutdown.yml | 1 - 2 files changed, 57 deletions(-) delete mode 100644 eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml diff --git a/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml b/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml deleted file mode 100644 index 7561210626fe1..0000000000000 --- a/eng/common/pipelines/templates/jobs/test-proxy-shutdown.yml +++ /dev/null @@ -1,56 +0,0 @@ -variables: - - template: /eng/pipelines/templates/variables/globals.yml - -stages: - - stage: - displayName: Invoke Proxy Shutdown Test - jobs: - - job: Test - strategy: - matrix: - Windows: - Pool: azsdk-pool-mms-win-2022-general - Image: windows-2022 - Linux: - Pool: azsdk-pool-mms-ubuntu-2204-general - Image: ubuntu-22.04 - Mac: - Pool: Azure Pipelines - Image: macos-11 - - pool: - name: $(Pool) - vmImage: $(Image) - - steps: - - template: /eng/common/testproxy/test-proxy-tool.yml - - - pwsh: | - $(Build.BinariesDirectory)/test-proxy/test-proxy.exe restore -a . - displayName: Generate some proxy logs windows - continueOnError: true - condition: and(succeeded(), eq(variables['Agent.OS'],'Windows_NT')) - - - pwsh: | - $(Build.BinariesDirectory)/test-proxy/test-proxy restore -a . - displayName: Generate some proxy logs linux - continueOnError: true - condition: and(succeeded(), ne(variables['Agent.OS'],'Windows_NT')) - - - template: /eng/common/testproxy/test-proxy-tool-shutdown.yml - - - template: /eng/common/testproxy/publish-proxy-logs.yml - - - pwsh: | - for ($i = 0; $i -lt 2; $i++) { - try { - Invoke-WebRequest -Uri "http://localhost:5000/Admin/IsAlive" | Out-Null - exit 0 - } catch { - Write-Warning "Failed to successfully connect to test proxy. Retrying..." - Start-Sleep 6 - } - } - Write-Error "Could not connect to test proxy." - exit 1 - displayName: Test Proxy IsAlive \ No newline at end of file diff --git a/eng/common/testproxy/test-proxy-tool-shutdown.yml b/eng/common/testproxy/test-proxy-tool-shutdown.yml index ab2955e65a74f..20e24e70a0aa4 100644 --- a/eng/common/testproxy/test-proxy-tool-shutdown.yml +++ b/eng/common/testproxy/test-proxy-tool-shutdown.yml @@ -4,7 +4,6 @@ steps: displayName: 'Shut down the testproxy - windows' condition: and(succeeded(), eq(variables['Agent.OS'],'Windows_NT')) - # nohup does NOT continue beyond the current session if you use it within powershell - bash: | kill -9 $(PROXY_PID) displayName: "Shut down the testproxy - linux/mac"