Winrm test fixes
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/51b3c253 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/51b3c253 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/51b3c253 Branch: refs/heads/master Commit: 51b3c253e49b631ca2525ad5e537a1b14cd37e73 Parents: 5353ad0 Author: Svetoslav Neykov <svetoslav.ney...@cloudsoftcorp.com> Authored: Mon Mar 6 18:15:51 2017 +0200 Committer: Svetoslav Neykov <svetoslav.ney...@cloudsoftcorp.com> Committed: Tue Mar 7 23:11:41 2017 +0200 ---------------------------------------------------------------------- .../brooklyn/camp/brooklyn/WindowsYamlLiveTest.java | 12 +++++++----- .../blueprints/Windows7zipBlueprintLiveTest.java | 4 ++-- launcher/src/test/resources/install7zip.ps1 | 13 +++---------- .../location/jclouds/JcloudsSshingLiveTest.java | 1 + .../VanillaWindowsProcessWinrmExitStatusLiveTest.java | 6 ++++-- 5 files changed, 17 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/51b3c253/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/WindowsYamlLiveTest.java ---------------------------------------------------------------------- diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/WindowsYamlLiveTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/WindowsYamlLiveTest.java index f72805f..cba6a61 100644 --- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/WindowsYamlLiveTest.java +++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/WindowsYamlLiveTest.java @@ -88,6 +88,10 @@ public class WindowsYamlLiveTest extends AbstractYamlTest { protected WinRmMachineLocation machine; protected Entity app; + protected boolean useDefaultProperties() { + return true; + } + @BeforeClass(alwaysRun = true) public void setUpClass() throws Exception { super.setUp(); @@ -102,7 +106,7 @@ public class WindowsYamlLiveTest extends AbstractYamlTest { " byon:", " hosts:", " - winrm: "+ip+":5985", - " password: "+password, + " password: \""+password.replace("\"", "\\\"") + "\"", " user: Administrator", " osFamily: windows"); } @@ -319,7 +323,7 @@ public class WindowsYamlLiveTest extends AbstractYamlTest { app = createAndStartApplication(Joiner.on("\n").join(yaml)); fail("start should have failed for app="+app); } catch (Exception e) { - if (e.toString().contains("invalid result") && e.toString().contains("for "+cmdFailed)) throw e; + if (!e.toString().contains("invalid result") || !e.toString().contains("for "+cmdFailed)) throw e; } } } @@ -391,9 +395,7 @@ public class WindowsYamlLiveTest extends AbstractYamlTest { for (Task<?> task : tasks) { if (matcher.apply(task)) return Optional.<Task<?>>of(task); - if (!(task instanceof HasTaskChildren)) { - return Optional.absent(); - } else { + if (task instanceof HasTaskChildren) { Optional<Task<?>> subResult = findTaskOrSubTask(((HasTaskChildren) task).getChildren(), matcher); if (subResult.isPresent()) return subResult; } http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/51b3c253/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/Windows7zipBlueprintLiveTest.java ---------------------------------------------------------------------- diff --git a/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/Windows7zipBlueprintLiveTest.java b/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/Windows7zipBlueprintLiveTest.java index f3f4c7d..a2f920c 100644 --- a/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/Windows7zipBlueprintLiveTest.java +++ b/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/Windows7zipBlueprintLiveTest.java @@ -75,7 +75,7 @@ public class Windows7zipBlueprintLiveTest extends AbstractBlueprintTest { " byon:", " hosts:", " - winrm: "+machine.getAddress().getHostAddress()+":5985", - " password: "+machine.config().get(WinRmMachineLocation.PASSWORD), + " password: \""+machine.config().get(WinRmMachineLocation.PASSWORD).replace("\"", "\\\"") + "\"", " user: Administrator", " osFamily: windows", "services:", @@ -89,7 +89,7 @@ public class Windows7zipBlueprintLiveTest extends AbstractBlueprintTest { String user = Strings.getFirstWord(winRMAddress); String password = Strings.getFirstWordAfter(winRMAddress, ":"); - WinRmTool winRmTool = WinRmTool.connect(ipPort, user, password); + WinRmTool winRmTool = WinRmTool.Builder.builder(ipPort, user, password).build(); WinRmToolResponse winRmResponse = winRmTool.executePs(ImmutableList.of("(Get-Item \"C:\\\\Program Files\\\\7-Zip\\\\7z.exe\").name")); LOG.info("winRmResponse: code="+winRmResponse.getStatusCode()+"; out="+winRmResponse.getStdOut()+"; err="+winRmResponse.getStdErr()); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/51b3c253/launcher/src/test/resources/install7zip.ps1 ---------------------------------------------------------------------- diff --git a/launcher/src/test/resources/install7zip.ps1 b/launcher/src/test/resources/install7zip.ps1 index 6308fc6..72e6ebb 100644 --- a/launcher/src/test/resources/install7zip.ps1 +++ b/launcher/src/test/resources/install7zip.ps1 @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -$Path="C:\InstallTemp" +$Path = "C:\InstallTemp" New-Item -ItemType Directory -Force -Path $Path $Url = "${config['installer.download.url']}" @@ -23,13 +23,6 @@ $Dl = [System.IO.Path]::Combine($Path, "installer.msi") $WebClient = New-Object System.Net.WebClient -$WebClient.DownloadFile($Url, $Dl) +$WebClient.DownloadFile( $Url, $Dl ) -$pass = '${attribute['windows.password']}' -$secpasswd = ConvertTo-SecureString $pass -AsPlainText -Force -$mycreds = New-Object System.Management.Automation.PSCredential ($($env:COMPUTERNAME + "\Administrator"), $secpasswd) - -Invoke-Command -ComputerName localhost -credential $mycreds -scriptblock { - param($Dl) - Start-Process "msiexec" -ArgumentList '/qn','/i',$Dl,'/L c:\7ziplog.txt' -Wait -} -Authentication CredSSP -argumentlist $Dl +Start-Process "msiexec" -ArgumentList '/qn','/i',$Dl -RedirectStandardOutput ( [System.IO.Path]::Combine($Path, "stdout.txt") ) -RedirectStandardError ( [System.IO.Path]::Combine($Path, "stderr.txt") ) -Wait \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/51b3c253/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsSshingLiveTest.java ---------------------------------------------------------------------- diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsSshingLiveTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsSshingLiveTest.java index 584ceb3..2440ff1 100644 --- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsSshingLiveTest.java +++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsSshingLiveTest.java @@ -54,6 +54,7 @@ public class JcloudsSshingLiveTest extends AbstractJcloudsLiveTest { JcloudsSshMachineLocation machine = obtainMachine(MutableMap.<String,Object>builder() .putIfAbsent("inboundPorts", ImmutableList.of(22)) .build()); + machine.execCommands("test commands", ImmutableList.of("echo test")); assertSshable(machine); assertEquals(machine.getUser(), "myname"); } http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/51b3c253/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcessWinrmExitStatusLiveTest.java ---------------------------------------------------------------------- diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcessWinrmExitStatusLiveTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcessWinrmExitStatusLiveTest.java index d644d11..c6eb94c 100644 --- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcessWinrmExitStatusLiveTest.java +++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcessWinrmExitStatusLiveTest.java @@ -217,12 +217,14 @@ public class VanillaWindowsProcessWinrmExitStatusLiveTest { runExecPsNonZeroExitCode("launch-command"); } - @Test(groups = "Live") + // Failed stop command doesn't fail the effector if machine is destroyed successfully. + @Test(groups = {"Live","WIP"}) public void testPsCheckRunningNonZeroExitCode() { runExecPsNonZeroExitCode("is-running-command"); } - @Test(groups = "Live") + // Failed stop command doesn't fail the effector if machine is destroyed successfully. + @Test(groups = {"Live","WIP"}) public void testPsStopNonZeroExitCode() { runExecPsNonZeroExitCode("stop-command"); }