From 33a42163fbe6ff141bf8fa5fcee8bfbe6e29e73d 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 0000000000..97f218e708 --- /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 0000000000..31a13c9db8 --- /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 7aea55d472..e165fa59ab 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 60740ea0ebdc72c2fb76428be6649eed6ee241ec 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 97f218e708..0995d6cc5e 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 31a13c9db8..ab2955e65a 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 f55e5a765b173cd9fed31b6f86666211206ec07e 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 e165fa59ab..d9a1668419 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 f661d6312fe2c06bf63614bd1bd32caf1560a979 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 0995d6cc5e..56816c3042 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 3be7abc52c7ae5ddd2ef9751857c571eafe4057a 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 56816c3042..0fff42c2d2 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 aea6c3d6169c59671ca8cbc0696b6f4a40d9db36 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 0fff42c2d2..27385859ea 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 47d2b2d314f3101ebbb786b543e33558fe787722 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 27385859ea..7561210626 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 0f3e360acf82f9698d38b1f0319531162208ee91 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 7561210626..0000000000 --- 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 ab2955e65a..20e24e70a0 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"