Browse code

ansible-test: make the httptester for Windows more resiliant around the shell chosen (#51416)

(cherry picked from commit ce8db479f020fdf16bf72d77abc6a93dab9f37a6)

Jordan Borean authored on 2019/01/30 06:50:23
Showing 2 changed files
... ...
@@ -577,9 +577,9 @@ def command_windows_integration(args):
577 577
                     manage = ManageWindowsCI(remote)
578 578
                     manage.upload("test/runner/setup/windows-httptester.ps1", watcher_path)
579 579
 
580
-                    # need to use -Command as we cannot pass an array of values with -File
581
-                    script = "powershell.exe -NoProfile -ExecutionPolicy Bypass -Command .\\%s -Hosts %s" \
582
-                             % (watcher_path, ", ".join(HTTPTESTER_HOSTS))
580
+                    # We cannot pass an array of string with -File so we just use a delimiter for multiple values
581
+                    script = "powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\\%s -Hosts \"%s\"" \
582
+                             % (watcher_path, "|".join(HTTPTESTER_HOSTS))
583 583
                     if args.verbosity > 3:
584 584
                         script += " -Verbose"
585 585
                     manage.ssh(script, options=ssh_options, force_pty=False)
... ...
@@ -594,7 +594,7 @@ def command_windows_integration(args):
594 594
                 for remote in [r for r in remotes if r.version != '2008']:
595 595
                     # delete the tmp file that keeps the http-tester alive
596 596
                     manage = ManageWindowsCI(remote)
597
-                    manage.ssh("del %s /F /Q" % watcher_path)
597
+                    manage.ssh("cmd.exe /c \"del %s /F /Q\"" % watcher_path, force_pty=False)
598 598
 
599 599
             watcher_path = "ansible-test-http-watcher-%s.ps1" % time.time()
600 600
             pre_target = forward_ssh_ports
... ...
@@ -9,13 +9,14 @@ Run this with SSH with the -R arguments to foward ports 8080 and 8443 to the
9 9
 httptester container.
10 10
 
11 11
 .PARAMETER Hosts
12
-A list of hostnames to add to the Windows hosts file for the httptester
13
-container.
12
+A list of hostnames, delimited by '|', to add to the Windows hosts file for the
13
+httptester container, e.g. 'ansible.host.com|secondary.host.test'.
14 14
 #>
15 15
 [CmdletBinding()]
16 16
 param(
17
-    [Parameter(Mandatory=$true, Position=0)][String[]]$Hosts
17
+    [Parameter(Mandatory=$true, Position=0)][String]$Hosts
18 18
 )
19
+$Hosts = $Hosts.Split('|')
19 20
 
20 21
 $ProgressPreference = "SilentlyContinue"
21 22
 $ErrorActionPreference = "Stop"