Repository: hazelcast/hazelcast-simulator
Issue: Bug in harakiri

The problem is in the startup of the harakiri monitor after a test completes. Instead of setting the actual key/value, the literal values are taken. So if you have your identity configured as '''bla/ec2.identity''', then '''bla/ec2.identity''' is the literal value.

The cause of this is the SimulatorProperties.asMap function which returns the values without replacements being applied.

Changed files:
simulator/src/main/java/com/hazelcast/simulator/common/SimulatorProperties.java, simulator/src/main/java/com/hazelcast/simulator/coordinator/AgentUtils.java, simulator/src/main/java/com/hazelcast/simulator/utils/CloudProviderUtils.java

diff --git a/simulator/src/main/java/com/hazelcast/simulator/common/SimulatorProperties.java b/simulator/src/main/java/com/hazelcast/simulator/common/SimulatorProperties.java
index d4638aefd..5ef21b522 100644
--- a/simulator/src/main/java/com/hazelcast/simulator/common/SimulatorProperties.java
+++ b/simulator/src/main/java/com/hazelcast/simulator/common/SimulatorProperties.java
@@ -26,6 +26,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 
+import static com.hazelcast.simulator.utils.CloudProviderUtils.isTrueCloud;
 import static com.hazelcast.simulator.utils.CommonUtils.closeQuietly;
 import static com.hazelcast.simulator.utils.CommonUtils.rethrow;
 import static com.hazelcast.simulator.utils.FileUtils.fileAsText;
@@ -74,6 +75,17 @@ public class SimulatorProperties {
             String key = (String) entry.getKey();
             map.put(key, get(key));
         }
+
+        String cloudProvider = getCloudProvider();
+        if (!isTrueCloud(cloudProvider)) {
+            // if isn't a true cloud, we don't for the identity/credentials.
+            return map;
+        }
+
+        // it is a true cloud; so we care for the identity/credentials. They need to be configured correctly or
+        // else an exception is thrown.
+        map.put(CLOUD_IDENTITY, getCloudIdentity());
+        map.put(CLOUD_CREDENTIAL, getCloudCredential());
         return map;
     }
 
diff --git a/simulator/src/main/java/com/hazelcast/simulator/coordinator/AgentUtils.java b/simulator/src/main/java/com/hazelcast/simulator/coordinator/AgentUtils.java
index 08376fde9..5be4840ac 100644
--- a/simulator/src/main/java/com/hazelcast/simulator/coordinator/AgentUtils.java
+++ b/simulator/src/main/java/com/hazelcast/simulator/coordinator/AgentUtils.java
@@ -28,9 +28,9 @@ public final class AgentUtils {
     }
 
     public static void startAgents(SimulatorProperties properties, ComponentRegistry registry) {
-        String startscript = getConfigurationFile("agent_start.sh").getAbsolutePath();
+        String startScript = getConfigurationFile("agent_start.sh").getAbsolutePath();
 
-        new BashCommand(startscript)
+        new BashCommand(startScript)
                 .addParams(join(registry.getAgentIps(), ","))
                 .addEnvironment(properties.asMap())
                 .execute();
diff --git a/simulator/src/main/java/com/hazelcast/simulator/utils/CloudProviderUtils.java b/simulator/src/main/java/com/hazelcast/simulator/utils/CloudProviderUtils.java
index 471eca063..629b0f415 100644
--- a/simulator/src/main/java/com/hazelcast/simulator/utils/CloudProviderUtils.java
+++ b/simulator/src/main/java/com/hazelcast/simulator/utils/CloudProviderUtils.java
@@ -47,6 +47,12 @@ public final class CloudProviderUtils {
         }
     }
 
+    public static boolean isTrueCloud(String cloudProvider) {
+        return !cloudProvider.equals("embedded")
+                && !cloudProvider.equals("local")
+                && !cloudProvider.equals("static");
+    }
+
     public static boolean isStatic(SimulatorProperties properties) {
         return isStatic(properties.getCloudProvider());
     }