geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From upthewatersp...@apache.org
Subject [geode-benchmarks] branch develop updated: Ignoring extra hosts in SshInfrastructure
Date Wed, 05 Dec 2018 19:06:16 GMT
This is an automated email from the ASF dual-hosted git repository.

upthewaterspout pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-benchmarks.git


The following commit(s) were added to refs/heads/develop by this push:
     new eb4dcab  Ignoring extra hosts in SshInfrastructure
eb4dcab is described below

commit eb4dcabe1251433d0b363a1afe3a3eccbff7118f
Author: Dan Smith <upthewaterspout@apache.org>
AuthorDate: Tue Dec 4 15:07:29 2018 -0800

    Ignoring extra hosts in SshInfrastructure
    
    SshInfrastructure was trying to copy data to nodes that aren't needed,
    resulting in failures if the user passed extra nodes.
---
 .../ssh/SshInfrastructureFactory.java              | 11 +++++---
 .../ssh/SshInfrastructureFactoryTest.java}         | 30 +++++++---------------
 2 files changed, 17 insertions(+), 24 deletions(-)

diff --git a/harness/src/main/java/org/apache/geode/perftest/infrastructure/ssh/SshInfrastructureFactory.java
b/harness/src/main/java/org/apache/geode/perftest/infrastructure/ssh/SshInfrastructureFactory.java
index 00ed0c5..f63cda2 100644
--- a/harness/src/main/java/org/apache/geode/perftest/infrastructure/ssh/SshInfrastructureFactory.java
+++ b/harness/src/main/java/org/apache/geode/perftest/infrastructure/ssh/SshInfrastructureFactory.java
@@ -19,13 +19,14 @@ package org.apache.geode.perftest.infrastructure.ssh;
 
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.List;
 
 import org.apache.geode.perftest.infrastructure.Infrastructure;
 import org.apache.geode.perftest.infrastructure.InfrastructureFactory;
 
 public class SshInfrastructureFactory implements InfrastructureFactory {
 
-  private final Collection<String> hosts;
+  private final List<String> hosts;
   private final String user;
 
   public SshInfrastructureFactory(String user, String... hosts) {
@@ -34,8 +35,12 @@ public class SshInfrastructureFactory implements InfrastructureFactory
{
   }
 
   @Override
-  public Infrastructure create(int nodes) throws Exception {
-    return new SshInfrastructure(hosts, user);
+  public Infrastructure create(int nodes) {
+    if (nodes > hosts.size()) {
+      throw new IllegalStateException(
+          "Not enough hosts to create " + nodes + " nodes. Available hosts: " + hosts);
+    }
+    return new SshInfrastructure(hosts.subList(0, nodes), user);
   }
 
   public Collection<String> getHosts() {
diff --git a/harness/src/main/java/org/apache/geode/perftest/infrastructure/ssh/SshInfrastructureFactory.java
b/harness/src/test/java/org/apache/geode/perftest/infrastructure/ssh/SshInfrastructureFactoryTest.java
similarity index 59%
copy from harness/src/main/java/org/apache/geode/perftest/infrastructure/ssh/SshInfrastructureFactory.java
copy to harness/src/test/java/org/apache/geode/perftest/infrastructure/ssh/SshInfrastructureFactoryTest.java
index 00ed0c5..9c929a1 100644
--- a/harness/src/main/java/org/apache/geode/perftest/infrastructure/ssh/SshInfrastructureFactory.java
+++ b/harness/src/test/java/org/apache/geode/perftest/infrastructure/ssh/SshInfrastructureFactoryTest.java
@@ -17,32 +17,20 @@
 
 package org.apache.geode.perftest.infrastructure.ssh;
 
-import java.util.Arrays;
-import java.util.Collection;
+import org.assertj.core.api.Assertions;
+import org.junit.Test;
 
 import org.apache.geode.perftest.infrastructure.Infrastructure;
-import org.apache.geode.perftest.infrastructure.InfrastructureFactory;
 
-public class SshInfrastructureFactory implements InfrastructureFactory {
+public class SshInfrastructureFactoryTest {
 
-  private final Collection<String> hosts;
-  private final String user;
+  @Test
+  public void ignoresExtraHosts() {
+    SshInfrastructureFactory factory =
+        new SshInfrastructureFactory("user", "localhost", "localhost", "localhost");
+    Infrastructure infra = factory.create(2);
 
-  public SshInfrastructureFactory(String user, String... hosts) {
-    this.hosts = Arrays.asList(hosts);
-    this.user = user;
+    Assertions.assertThat(infra.getNodes()).hasSize(2);
   }
 
-  @Override
-  public Infrastructure create(int nodes) throws Exception {
-    return new SshInfrastructure(hosts, user);
-  }
-
-  public Collection<String> getHosts() {
-    return hosts;
-  }
-
-  public String getUser() {
-    return user;
-  }
 }


Mime
View raw message