anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: ballerina-platform/openapi-tools
Issue: utils.bal file not getting over written in regeneration of clients 

**Description:**
$subject

**Steps to reproduce:**
Regenerate a client using the openapi file within the same directory where the client is generated earlier

**Affected Versions:**

**OS, DB, other environment details and versions:**

**Related Issues (optional):**
<!-- Any related issues such as sub tasks, issues reported in other repositories (e.g component repositories), similar problems, etc. -->

**Suggested Labels (optional):**
<!-- Optional comma separated list of suggested labels. Non committers can’t assign labels to issues, so this will help issue creators who are not a committer to suggest possible labels-->

**Suggested Assignees (optional):**
<!--Optional comma separated list of suggested team members who should attend the issue. Non committers can’t assign issues to assignees, so this will help issue creators who are not a committer to suggest possible assignees-->


Changed files:
openapi-core/src/main/java/io/ballerina/openapi/core/model/GenSrcFile.java

diff --git a/openapi-core/src/main/java/io/ballerina/openapi/core/model/GenSrcFile.java b/openapi-core/src/main/java/io/ballerina/openapi/core/model/GenSrcFile.java
index 8174e355..55d4463e 100644
--- a/openapi-core/src/main/java/io/ballerina/openapi/core/model/GenSrcFile.java
+++ b/openapi-core/src/main/java/io/ballerina/openapi/core/model/GenSrcFile.java
@@ -42,7 +42,7 @@ public class GenSrcFile {
         UTIL_SRC;
 
         public boolean isOverwritable() {
-            if (this == GEN_SRC || this == RES || this == MODEL_SRC) {
+            if (this == GEN_SRC || this == RES || this == MODEL_SRC || this == UTIL_SRC) {
                 return true;
             }
Repository: gchq/sleeper
Issue: EMR instance types are invalid with the same weight for different types

### Description

In all the EMR instance types properties, weights for the different instance types are set in-line with the instance types.

A validation predicate has been added for those properties which ensures that duplicate instance types are not set, but it includes the weights in the duplication test. This means that you can't set the same weight for more than one instance type.

### Steps to reproduce

1. Open the admin client with EmrBulkImportStack deployed
2. Update table property `sleeper.table.bulk.import.emr.master.x86.instance.types` to `m5.xlarge,2,m6i.xlarge,2`
3. See the property change fails to validate

### Expected behaviour

We should be able to set the same weight for multiple instance types on any instance types property.

Changed files:
java/configuration/src/main/java/sleeper/configuration/properties/validation/EmrInstanceTypeConfig.java
java/configuration/src/test/java/sleeper/configuration/properties/validation/EmrInstanceTypeConfigTest.java

diff --git a/java/configuration/src/main/java/sleeper/configuration/properties/validation/EmrInstanceTypeConfig.java b/java/configuration/src/main/java/sleeper/configuration/properties/validation/EmrInstanceTypeConfig.java
index 73c852553..9d5f312f5 100644
--- a/java/configuration/src/main/java/sleeper/configuration/properties/validation/EmrInstanceTypeConfig.java
+++ b/java/configuration/src/main/java/sleeper/configuration/properties/validation/EmrInstanceTypeConfig.java
@@ -75,6 +75,9 @@ public class EmrInstanceTypeConfig {
     }
 
     public static boolean isValidInstanceTypes(String value) {
+        if (value == null) {
+            return false;
+        }
         try {
             List<String> instanceTypes = readInstanceTypesProperty(readList(value), X86_64)
                     .map(EmrInstanceTypeConfig::getInstanceType)
diff --git a/java/configuration/src/test/java/sleeper/configuration/properties/validation/EmrInstanceTypeConfigTest.java b/java/configuration/src/test/java/sleeper/configuration/properties/validation/EmrInstanceTypeConfigTest.java
index 6231d6fa0..d1f14d7da 100644
--- a/java/configuration/src/test/java/sleeper/configuration/properties/validation/EmrInstanceTypeConfigTest.java
+++ b/java/configuration/src/test/java/sleeper/configuration/properties/validation/EmrInstanceTypeConfigTest.java
@@ -209,6 +209,12 @@ public class EmrInstanceTypeConfigTest {
             assertThat(EmrInstanceTypeConfig.isValidInstanceTypes("1,type-a"))
                     .isFalse();
         }
+
+        @Test
+        void shouldFailValidationWhenInstanceTypesPropertyIsNull() {
+            assertThat(EmrInstanceTypeConfig.isValidInstanceTypes(null))
+                    .isFalse();
+        }
     }
 
     public static Stream<EmrInstanceTypeConfig> readInstanceTypesProperty(List<String> instanceTypeEntries) {
Repository: gchq/sleeper
Issue: DeployNewInstance uses incorrect number of minimum arguments

### Description

When you run `scripts/deploy/deployNew.sh` it invokes `DeployNewInstance`. If you don't specify your own instance.properties file, it fails and you get a usage message.

In issue https://github.com/gchq/sleeper/issues/993, we corrected the minimum number of arguments in the shell script, but not in `DeployNewInstance`.

### Steps to reproduce

Try to deploy an instance with `scripts/deploy/deployNew.sh`, setting just the instance ID, VPC, subnet and table name.

You'll see the usage message coming from `DeployNewInstance`.

### Expected behavior

It should deploy an instance, using the template for the instance.properties.


Changed files:
java/clients/src/main/java/sleeper/clients/deploy/DeployNewInstance.java

diff --git a/java/clients/src/main/java/sleeper/clients/deploy/DeployNewInstance.java b/java/clients/src/main/java/sleeper/clients/deploy/DeployNewInstance.java
index 4064287d8..1b37910a7 100644
--- a/java/clients/src/main/java/sleeper/clients/deploy/DeployNewInstance.java
+++ b/java/clients/src/main/java/sleeper/clients/deploy/DeployNewInstance.java
@@ -82,7 +82,7 @@ public class DeployNewInstance {
     }
 
     public static void main(String[] args) throws IOException, InterruptedException {
-        if (args.length < 6 || args.length > 8) {
+        if (args.length < 5 || args.length > 8) {
             throw new IllegalArgumentException("Usage: <scripts-dir> <instance-id> <vpc> <subnet> <table-name> " +
                     "<optional-instance-properties-file> <optional-deploy-paused-flag> <optional-split-points-file>");
         }
Repository: gchq/sleeper
Issue: Bulk import fails with serialisation error

A recent change has caused bulk import jobs to fail with an error due to Kryo serialisation being unable to deal with the list of row key types in a partition being an unmodifiable list. This change has been introduced since the last release, and is due to the change in `getMappedFields` in `Schema` to return an unmodifiable list.

Steps to reproduce the problem:

- Run the system tests with ingest mode set to queue.
- Pause the system so the ingest tasks don't run.
- Wait for some unsorted, uningested files to have been written.
- Reinitialise the table with the 512 split points file from scripts/test/splitpoint.
- Put a JSON message on the bulk import queue telling it to ingest the files that the ingest tasks wrote.
- Look at the steps tab on the EMR cluster that will fire up.

Changed files:
java/core/src/main/java/sleeper/core/schema/Schema.java

diff --git a/java/core/src/main/java/sleeper/core/schema/Schema.java b/java/core/src/main/java/sleeper/core/schema/Schema.java
index e7d806c6a..fcfe982e2 100644
--- a/java/core/src/main/java/sleeper/core/schema/Schema.java
+++ b/java/core/src/main/java/sleeper/core/schema/Schema.java
@@ -103,7 +103,7 @@ public class Schema {
     private <T> List<T> getMappedFields(Stream<Field> fields, Function<Field, T> mapping) {
         return fields
                 .map(mapping)
-                .collect(Collectors.toUnmodifiableList());
+                .collect(Collectors.toList());
     }
 
     public List<Field> getAllFields() {
Repository: gchq/sleeper
Issue: Can't deploy environment EC2 into existing VPC

The documentation suggests that the following should allow you to use the Environment stack to deploy an EC2 only, but it fails with the error "Caused by: java.lang.RuntimeException: Error: App at '' should be created in the scope of a Stack, but no Stack found":

    cdk deploy -c instanceId=myenv -c vpcId=myvpc "*-BuildEC2"

Changed files:
java/cdk-environment/src/main/java/sleeper/environment/cdk/buildec2/BuildEC2Stack.java

diff --git a/java/cdk-environment/src/main/java/sleeper/environment/cdk/buildec2/BuildEC2Stack.java b/java/cdk-environment/src/main/java/sleeper/environment/cdk/buildec2/BuildEC2Stack.java
index f116d7e26..cdb7e8fbb 100644
--- a/java/cdk-environment/src/main/java/sleeper/environment/cdk/buildec2/BuildEC2Stack.java
+++ b/java/cdk-environment/src/main/java/sleeper/environment/cdk/buildec2/BuildEC2Stack.java
@@ -52,7 +52,7 @@ public class BuildEC2Stack extends Stack {
         AppContext context = AppContext.of(this);
         BuildEC2Parameters params = BuildEC2Parameters.from(context);
         vpc = context.get(VPC_ID)
-                .map(vpcId -> Vpc.fromLookup(scope, "Vpc", VpcLookupOptions.builder().vpcId(vpcId).build()))
+                .map(vpcId -> Vpc.fromLookup(this, "Vpc", VpcLookupOptions.builder().vpcId(vpcId).build()))
                 .orElse(inheritVpc);
         BuildEC2Image image = params.image();
Repository: gchq/sleeper
Issue: Cannot set a defaulted list property to an empty list

For some list properties that have a default value, there isn't a way to set the property to an empty list.
```properties
sleeper.list.property=
```
does not work as `getList()` returns a list containing the empty string, instead of an empty list

Changed files:
java/configuration/src/main/java/sleeper/configuration/properties/SleeperProperties.java
java/configuration/src/test/java/sleeper/configuration/properties/SleeperPropertiesTest.java

diff --git a/java/configuration/src/main/java/sleeper/configuration/properties/SleeperProperties.java b/java/configuration/src/main/java/sleeper/configuration/properties/SleeperProperties.java
index 993a4394c..ab7cdd170 100644
--- a/java/configuration/src/main/java/sleeper/configuration/properties/SleeperProperties.java
+++ b/java/configuration/src/main/java/sleeper/configuration/properties/SleeperProperties.java
@@ -114,7 +114,13 @@ public abstract class SleeperProperties<T extends SleeperProperty> {
     }
 
     public static List<String> readList(String value) {
-        return value == null ? null : Lists.newArrayList(value.split(","));
+        if (value == null) {
+            return null;
+        } else if ("".equals(value)) {
+            return List.of();
+        } else {
+            return Lists.newArrayList(value.split(","));
+        }
     }
 
     public void setNumber(T property, Number number) {
diff --git a/java/configuration/src/test/java/sleeper/configuration/properties/SleeperPropertiesTest.java b/java/configuration/src/test/java/sleeper/configuration/properties/SleeperPropertiesTest.java
index fd4a4efd2..3445b9db0 100644
--- a/java/configuration/src/test/java/sleeper/configuration/properties/SleeperPropertiesTest.java
+++ b/java/configuration/src/test/java/sleeper/configuration/properties/SleeperPropertiesTest.java
@@ -160,6 +160,19 @@ class SleeperPropertiesTest {
         assertThat(list).isNull();
     }
 
+    @Test
+    void shouldReturnEmptyListIfListPropertyIsSetToEmptyString() {
+        // Given
+        TestSleeperProperties testSleeperProperties = new TestSleeperProperties();
+        testSleeperProperties.set(OPTIONAL_STACKS, "");
+
+        // When
+        List<String> list = testSleeperProperties.getList(OPTIONAL_STACKS);
+
+        // Then
+        assertThat(list).isEmpty();
+    }
+
     private static class TestSleeperProperties extends SleeperProperties<SleeperProperty> {
 
         private TestSleeperProperties() {
Repository: gchq/sleeper
Issue: Bulk import performance test fails as BulkImportStarterLambda times out processing all jobs

With the new validation changes, the BulkImportStarterLambda reaches the timeout of 20 seconds when trying to process all 5 jobs and record their validation status. We should increase this timeout so that jobs have enough time to be processed.

This has failed the bulk import performance test as the same execution of the Lambda picked up 3 bulk import jobs from the queue all at once. It couldn't process all 3 within 20 seconds, although any one job would have completed on its own.

It might good if we can set a timeout per message processed, rather than an absolute timeout. An alternative would be to prevent it processing multiple messages in one execution.

The current timeout is configured in CommonEmrBulkImportHelper.createJobStarterFunction.

Changed files:
java/cdk/src/main/java/sleeper/cdk/stack/bulkimport/CommonEmrBulkImportHelper.java

diff --git a/java/cdk/src/main/java/sleeper/cdk/stack/bulkimport/CommonEmrBulkImportHelper.java b/java/cdk/src/main/java/sleeper/cdk/stack/bulkimport/CommonEmrBulkImportHelper.java
index 7ba3d0a23..840e4d62d 100644
--- a/java/cdk/src/main/java/sleeper/cdk/stack/bulkimport/CommonEmrBulkImportHelper.java
+++ b/java/cdk/src/main/java/sleeper/cdk/stack/bulkimport/CommonEmrBulkImportHelper.java
@@ -123,12 +123,12 @@ public class CommonEmrBulkImportHelper {
                 .functionName(functionName)
                 .description("Function to start " + shortId + " bulk import jobs")
                 .memorySize(1024)
-                .timeout(Duration.seconds(20))
+                .timeout(Duration.minutes(2))
                 .environment(env)
                 .runtime(software.amazon.awscdk.services.lambda.Runtime.JAVA_11)
                 .handler("sleeper.bulkimport.starter.BulkImportStarterLambda")
                 .logRetention(Utils.getRetentionDays(instanceProperties.getInt(LOG_RETENTION_IN_DAYS)))
-                .events(Lists.newArrayList(new SqsEventSource(jobQueue))));
+                .events(Lists.newArrayList(SqsEventSource.Builder.create(jobQueue).batchSize(1).build())));
 
         configBucket.grantRead(function);
         importBucket.grantReadWrite(function);
Repository: gchq/sleeper
Issue: Bulk import stack does not deploy because queue timeout is less than function timeout

When the bulk import performance test ran, we found this error trying to deploy to CloudFormation:

Resource handler returned message: "Invalid request provided: Queue visibility timeout: 30 seconds is less than Function timeout: 120 seconds (Service: Lambda, Status Code: 400, Request ID: 123)" (RequestToken: abc, HandlerErrorCode: InvalidRequest)

It looks like this was caused by the changes for issue #960, in PR https://github.com/gchq/sleeper/pull/969

Changed files:
java/cdk/src/main/java/sleeper/cdk/stack/bulkimport/CommonEmrBulkImportHelper.java

diff --git a/java/cdk/src/main/java/sleeper/cdk/stack/bulkimport/CommonEmrBulkImportHelper.java b/java/cdk/src/main/java/sleeper/cdk/stack/bulkimport/CommonEmrBulkImportHelper.java
index 840e4d62d..3492e256d 100644
--- a/java/cdk/src/main/java/sleeper/cdk/stack/bulkimport/CommonEmrBulkImportHelper.java
+++ b/java/cdk/src/main/java/sleeper/cdk/stack/bulkimport/CommonEmrBulkImportHelper.java
@@ -98,6 +98,7 @@ public class CommonEmrBulkImportHelper {
         Queue emrBulkImportJobQueue = Queue.Builder
                 .create(scope, "BulkImport" + shortId + "JobQueue")
                 .deadLetterQueue(deadLetterQueue)
+                .visibilityTimeout(Duration.minutes(3))
                 .queueName(instanceId + "-BulkImport" + shortId + "Q")
                 .build();
Repository: wso2/testgrid
Issue: Code violation: incorrect closing of inputstream.

**Description:**
  Incorrect closing of inputstream: 

 https://github.com/wso2/testgrid/blob/03d4ba54c56d2c06287a6f66f19951d1624a2f11/common/src/main/java/org/wso2/testgrid/common/util/FileUtil.java#L43                                                                                                                                              

**Affected Product Version:**
 0.9.0-m10                                                                                                                       

**OS, DB, other environment details and versions:**
  N/A                                                                                                      
**Steps to reproduce:**
  See above                                                                                                                                     
**Related Issues:**
 N/A                                                                                                      


Changed files:
automation/src/test/java/org/wso2/testgrid/automation/executor/JMeterExecutorTest.java
common/src/main/java/org/wso2/testgrid/common/util/FileUtil.java

diff --git a/automation/src/test/java/org/wso2/testgrid/automation/executor/JMeterExecutorTest.java b/automation/src/test/java/org/wso2/testgrid/automation/executor/JMeterExecutorTest.java
index 8722946b..280ad260 100644
--- a/automation/src/test/java/org/wso2/testgrid/automation/executor/JMeterExecutorTest.java
+++ b/automation/src/test/java/org/wso2/testgrid/automation/executor/JMeterExecutorTest.java
@@ -65,9 +65,6 @@ public class JMeterExecutorTest {
         URL resource = classLoader.getResource("test-grid-is-resources");
         Assert.assertNotNull(resource);
 
-        String testScript = Paths.get(resource.getPath(), "SolutionPattern22", "Tests", "jmeter", "mock.jmx")
-                .toAbsolutePath().toString();
-
         String testLocation = Paths.get(resource.getPath(), "SolutionPattern22", "Tests")
                 .toAbsolutePath().toString();
         TestExecutor testExecutor = new JMeterExecutor();
diff --git a/common/src/main/java/org/wso2/testgrid/common/util/FileUtil.java b/common/src/main/java/org/wso2/testgrid/common/util/FileUtil.java
index b9fc76fa..373b8c5d 100644
--- a/common/src/main/java/org/wso2/testgrid/common/util/FileUtil.java
+++ b/common/src/main/java/org/wso2/testgrid/common/util/FileUtil.java
@@ -38,9 +38,8 @@ public class FileUtil {
      * @throws IOException thrown when no file is found in the given location or when error on closing file input stream
      */
     public static <T> T readConfigurationFile(String location, Class<T> type) throws IOException {
-        FileInputStream fileInputStream = new FileInputStream(new File(location));
-        T configuration = new Yaml().loadAs(fileInputStream, type);
-        fileInputStream.close();
-        return configuration;
+        try (FileInputStream fileInputStream = new FileInputStream(new File(location))) {
+            return new Yaml().loadAs(fileInputStream, type);
+        }
     }
 }
Repository: wso2/testgrid
Issue: job-config.yaml cannot contain absolute paths

**Description:**
When absolute paths are given for infra, deployment and scenario repo locations, generate-test-plan command fails when resolving the path.

**Suggested Labels:**
Type/Bug

**Suggested Assignees:**
AsmaJ

Changed files:
core/src/main/java/org/wso2/testgrid/core/command/GenerateTestPlanCommand.java

diff --git a/core/src/main/java/org/wso2/testgrid/core/command/GenerateTestPlanCommand.java b/core/src/main/java/org/wso2/testgrid/core/command/GenerateTestPlanCommand.java
index 22495490..922b1e32 100644
--- a/core/src/main/java/org/wso2/testgrid/core/command/GenerateTestPlanCommand.java
+++ b/core/src/main/java/org/wso2/testgrid/core/command/GenerateTestPlanCommand.java
@@ -221,7 +221,7 @@ public class GenerateTestPlanCommand implements Command {
      */
     private void resolvePaths(JobConfigFile jobConfigFile) {
         String parent = jobConfigFile.getWorkingDir();
-        if (jobConfigFile.isRelativePaths() || parent != null) {
+        if (jobConfigFile.isRelativePaths() && parent != null) {
             //infra
             Path repoPath = Paths.get(parent, jobConfigFile.getInfrastructureRepository());
             jobConfigFile.setInfrastructureRepository(resolvePath(repoPath, jobConfigFile));
Repository: wso2/testgrid
Issue: Support DBEngine, DBEngineVersion as infrastructure parameters.

**Description:**
Support DBEngine, DBEngineVersion as infrastructure parameters.                                                                                                                                              

**Affected Product Version:**
 0.9.0-m10                                                                                                                       

**OS, DB, other environment details and versions:**
  N/A                                                                                                      
**Steps to reproduce:**
  See above                                                                                                                                     
**Related Issues:**
 N/A                                                                                                      


Changed files:
common/src/main/java/org/wso2/testgrid/common/infrastructure/InfrastructureParameter.java

diff --git a/common/src/main/java/org/wso2/testgrid/common/infrastructure/InfrastructureParameter.java b/common/src/main/java/org/wso2/testgrid/common/infrastructure/InfrastructureParameter.java
index f313bee5..5ce13073 100644
--- a/common/src/main/java/org/wso2/testgrid/common/infrastructure/InfrastructureParameter.java
+++ b/common/src/main/java/org/wso2/testgrid/common/infrastructure/InfrastructureParameter.java
@@ -200,6 +200,7 @@ public class InfrastructureParameter extends AbstractUUIDEntity implements
      */
     public enum Type {
         OPERATING_SYSTEM("operating_system"),
+        DATABASE("database"),
         DBEngine("DBEngine"),
         DBEngineVersion("DBEngineVersion"),
         JDK("JDK");
Repository: wso2/testgrid
Issue: Absence of TESTGRID_HOME breaks shell execution

**Description:**
In ShellDeployer we are retrieving the TESTGRID_HOME environment variable. If TG Home is not set this will break the execution.

https://github.com/wso2/testgrid/blob/master/deployment/src/main/java/org/wso2/testgrid/deployment/deployers/ShellDeployer.java#L49

**Suggested Labels:**
Bug


Changed files:
deployment/src/main/java/org/wso2/testgrid/deployment/deployers/ShellDeployer.java

diff --git a/deployment/src/main/java/org/wso2/testgrid/deployment/deployers/ShellDeployer.java b/deployment/src/main/java/org/wso2/testgrid/deployment/deployers/ShellDeployer.java
index 0ab3557d..5ebdebf9 100644
--- a/deployment/src/main/java/org/wso2/testgrid/deployment/deployers/ShellDeployer.java
+++ b/deployment/src/main/java/org/wso2/testgrid/deployment/deployers/ShellDeployer.java
@@ -24,7 +24,9 @@ import org.wso2.testgrid.common.Deployment;
 import org.wso2.testgrid.common.ShellExecutor;
 import org.wso2.testgrid.common.exception.CommandExecutionException;
 import org.wso2.testgrid.common.exception.TestGridDeployerException;
+import org.wso2.testgrid.common.util.TestGridUtil;
 
+import java.io.IOException;
 import java.nio.file.Paths;
 
 /**
@@ -46,14 +48,16 @@ public class ShellDeployer implements DeployerService {
     @Override
     public Deployment deploy(Deployment deployment) throws TestGridDeployerException {
         logger.info("Performing the Deployment " + deployment.getName());
-        ShellExecutor shellExecutor = new ShellExecutor(Paths.get(System.getenv("TESTGRID_HOME")));
         try {
+        ShellExecutor shellExecutor = new ShellExecutor(Paths.get(TestGridUtil.getTestGridHomePath()));
             if (!shellExecutor
                     .executeCommand("bash " + Paths.get(deployment.getDeploymentScriptsDir(), DEPLOY_SCRIPT_NAME))) {
                 throw new TestGridDeployerException("Error occurred while executing the deploy script");
             }
         } catch (CommandExecutionException e) {
             throw new TestGridDeployerException(e);
+        } catch (IOException e) {
+            throw new TestGridDeployerException("Error occurred while retrieving the Testgrid_home ", e);
         }
 
         return new Deployment();
Repository: wso2/testgrid
Issue: Report Displaying duplicate entries

**Description:**
The final report is generated considering all the tests for all the deployments and infra parameters. However, the detailed report may list the same entry multiple times (actually different test cases). The distinct entries should be displayed instead.

Changed files:
reporting/src/main/java/org/wso2/testgrid/reporting/TestReportEngine.java

diff --git a/reporting/src/main/java/org/wso2/testgrid/reporting/TestReportEngine.java b/reporting/src/main/java/org/wso2/testgrid/reporting/TestReportEngine.java
index 23e0b779..c8f9adb6 100755
--- a/reporting/src/main/java/org/wso2/testgrid/reporting/TestReportEngine.java
+++ b/reporting/src/main/java/org/wso2/testgrid/reporting/TestReportEngine.java
@@ -26,6 +26,7 @@ import org.wso2.testgrid.common.TestPlan;
 import org.wso2.testgrid.common.TestScenario;
 import org.wso2.testgrid.common.util.StringUtil;
 import org.wso2.testgrid.common.util.TestGridUtil;
+import org.wso2.testgrid.dao.uow.TestPlanUOW;
 import org.wso2.testgrid.reporting.model.GroupBy;
 import org.wso2.testgrid.reporting.model.PerAxisHeader;
 import org.wso2.testgrid.reporting.model.PerAxisSummary;
@@ -556,18 +557,12 @@ public class TestReportEngine {
      */
     private List<ReportElement> constructReportElements(Product product, AxisColumn groupByAxisColumn) {
         List<ReportElement> reportElements = new ArrayList<>();
-
-        // Deployment patterns
-        List<DeploymentPattern> deploymentPatterns = product.getDeploymentPatterns();
-        for (DeploymentPattern deploymentPattern : deploymentPatterns) {
-
-            // Test plans
-            List<TestPlan> testPlans = deploymentPattern.getTestPlans();
-            for (TestPlan testPlan : testPlans) {
-                List<ReportElement> reportElementsForTestPlan = createReportElementsForTestPlan(testPlan,
-                        deploymentPattern, groupByAxisColumn);
-                reportElements.addAll(reportElementsForTestPlan);
-            }
+        TestPlanUOW testPlanUOW = new TestPlanUOW();
+        List<TestPlan> testPlans = testPlanUOW.getLatestTestPlans(product);
+        for (TestPlan testPlan : testPlans) {
+            List<ReportElement> reportElementsForTestPlan = createReportElementsForTestPlan(testPlan,
+                    testPlan.getDeploymentPattern(), groupByAxisColumn);
+            reportElements.addAll(reportElementsForTestPlan);
         }
         return reportElements;
     }
Repository: wso2/testgrid
Issue: Testcase persistence fails with "data too long for failure message"

**Description:**
Response data in testcase failure message is too long for the failure_message field in the database. This causes in persistence failure.

**Suggested Labels:**
Type/Bug

**Suggested Assignees:**

AsmaJ

Changed files:
automation/src/main/java/org/wso2/testgrid/automation/executor/JMeterResultCollector.java

diff --git a/automation/src/main/java/org/wso2/testgrid/automation/executor/JMeterResultCollector.java b/automation/src/main/java/org/wso2/testgrid/automation/executor/JMeterResultCollector.java
index 10b746ae..5244d379 100644
--- a/automation/src/main/java/org/wso2/testgrid/automation/executor/JMeterResultCollector.java
+++ b/automation/src/main/java/org/wso2/testgrid/automation/executor/JMeterResultCollector.java
@@ -62,9 +62,7 @@ public class JMeterResultCollector extends ResultCollector {
                 message = StringUtil.concatStrings("{ \\"Status code\\": \\"",
                         result.getResponseCode().replaceAll("\\"", "\\\\\\""),
                         "\\", \\"Response Message\\": \\"",
-                        result.getResponseMessage().replaceAll("\\"", "\\\\\\""),
-                        "\\", \\"Response Data\\": \\"",
-                        result.getResponseDataAsString().replaceAll("\\"", "\\\\\\""), "\\"}");
+                        result.getResponseMessage().replaceAll("\\"", "\\\\\\""), "\\"}");
 
                 logMessage = StringUtil.concatStrings("{ \\"Status code\\": \\"",
                         result.getResponseCode().replaceAll("\\"", "\\\\\\""),
Repository: wso2/testgrid
Issue: Scenario tests execution hangs

**Description:**
Scenario test execution hangs just after the server startup. 

**Affected Product Version:**
0.9.0-m18

**OS, DB, other environment details and versions:**    
N/A

**Steps to reproduce:**
- Generate test palns
- Execute one test-plan


Changed files:
infrastructure/src/main/java/org/wso2/testgrid/infrastructure/providers/AWSProvider.java
deployment/src/main/java/org/wso2/testgrid/deployment/deployers/ShellDeployer.java

diff --git a/deployment/src/main/java/org/wso2/testgrid/deployment/deployers/ShellDeployer.java b/deployment/src/main/java/org/wso2/testgrid/deployment/deployers/ShellDeployer.java
index e1e98acf..1f995f53 100644
--- a/deployment/src/main/java/org/wso2/testgrid/deployment/deployers/ShellDeployer.java
+++ b/deployment/src/main/java/org/wso2/testgrid/deployment/deployers/ShellDeployer.java
@@ -99,7 +99,7 @@ public class ShellDeployer implements Deployer {
         List<Host> hosts = new ArrayList<>();
         Host tomcatHost = new Host();
         tomcatHost.setLabel("tomcatHost");
-        tomcatHost.setIp("ec2-52-54-230-106.compute-1.amazonaws.com");
+        tomcatHost.setIp("ec2-34-204-80-18.compute-1.amazonaws.com");
         Host tomcatPort = new Host();
         tomcatPort.setLabel("tomcatPort");
         tomcatPort.setIp("8080");
diff --git a/infrastructure/src/main/java/org/wso2/testgrid/infrastructure/providers/AWSProvider.java b/infrastructure/src/main/java/org/wso2/testgrid/infrastructure/providers/AWSProvider.java
index 4d78340a..7bd356fa 100644
--- a/infrastructure/src/main/java/org/wso2/testgrid/infrastructure/providers/AWSProvider.java
+++ b/infrastructure/src/main/java/org/wso2/testgrid/infrastructure/providers/AWSProvider.java
@@ -211,7 +211,7 @@ public class AWSProvider implements InfrastructureProvider {
             List<Host> hosts = new ArrayList<>();
             Host tomcatHost = new Host();
             tomcatHost.setLabel("tomcatHost");
-            tomcatHost.setIp("ec2-52-54-230-106.compute-1.amazonaws.com");
+            tomcatHost.setIp("ec2-34-204-80-18.compute-1.amazonaws.com");
             Host tomcatPort = new Host();
             tomcatPort.setLabel("tomcatPort");
             tomcatPort.setIp("8080");
Repository: wso2/testgrid
Issue: generate-test-plan command fails for incomplete testgrid.yaml

**Description:**

When testgrid.yaml does not contain scenarioConfig, the file is not ignored.
Also, TestGrid does not support config-change-sets yet. Therefore, this missing property in testgrid.yaml should be ignored which otherwise breaks the flow.

**Suggested Labels:**

Type/Bug

**Suggested Assignees:**

AsmaJ

Changed files:
core/src/main/java/org/wso2/testgrid/core/command/GenerateTestPlanCommand.java

diff --git a/core/src/main/java/org/wso2/testgrid/core/command/GenerateTestPlanCommand.java b/core/src/main/java/org/wso2/testgrid/core/command/GenerateTestPlanCommand.java
index d1662a38..604f88df 100644
--- a/core/src/main/java/org/wso2/testgrid/core/command/GenerateTestPlanCommand.java
+++ b/core/src/main/java/org/wso2/testgrid/core/command/GenerateTestPlanCommand.java
@@ -47,6 +47,7 @@ import org.wso2.testgrid.infrastructure.InfrastructureCombinationsProvider;
 import org.wso2.testgrid.logging.plugins.LogFilePathLookup;
 import org.yaml.snakeyaml.DumperOptions;
 import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
 import org.yaml.snakeyaml.introspector.Property;
 import org.yaml.snakeyaml.nodes.NodeTuple;
 import org.yaml.snakeyaml.nodes.Tag;
@@ -366,7 +367,7 @@ public class GenerateTestPlanCommand implements Command {
                     TestGridConstants.TESTGRID_YAML, " is missing in ", deployRepositoryLocation));
         }
         testgridYamlContent = testgridYamlBuilder.toString().trim();
-        if (testgridYamlContent.isEmpty()) {
+        if (testgridYamlContent.isEmpty() || !testgridYamlContent.contains("scenarioConfig")) {
             testgridYamlContent = getTestgridYamlFor(Paths.get(testgridYamlLocation)).trim();
         }
 
@@ -378,7 +379,12 @@ public class GenerateTestPlanCommand implements Command {
                     + "could not be resolved via the job-config.yaml at: " + this.jobConfigFile);
         }
 
-        TestgridYaml testgridYaml = new Yaml().loadAs(testgridYamlContent, TestgridYaml.class);
+        Representer representer = new Representer();
+
+        // Skip missing properties in testgrid.yaml
+        representer.getPropertyUtils().setSkipMissingProperties(true);
+        TestgridYaml testgridYaml = new Yaml(new Constructor(TestgridYaml.class), representer)
+                .loadAs(testgridYamlContent, TestgridYaml.class);
         testgridYaml.setInfrastructureRepository(jobConfigFile.getInfrastructureRepository());
         testgridYaml.setDeploymentRepository(jobConfigFile.getDeploymentRepository());
         testgridYaml.setScenarioTestsRepository(jobConfigFile.getScenarioTestsRepository());
Repository: wso2/testgrid
Issue: Test scenarios are duplicated

**Description:**

Test scenarios are duplicated due to a bug in persistence logic in TestPlanExecutor#runScenarioTests.

**Suggested Labels:**

Type/Bug, Priority/Highest, Severity/Critical

**Suggested Assignees:**

AsmaJ

Changed files:
core/src/main/java/org/wso2/testgrid/core/TestPlanExecutor.java

diff --git a/core/src/main/java/org/wso2/testgrid/core/TestPlanExecutor.java b/core/src/main/java/org/wso2/testgrid/core/TestPlanExecutor.java
index 717f9fe5..0d102084 100644
--- a/core/src/main/java/org/wso2/testgrid/core/TestPlanExecutor.java
+++ b/core/src/main/java/org/wso2/testgrid/core/TestPlanExecutor.java
@@ -115,7 +115,16 @@ public class TestPlanExecutor {
      * @param deploymentCreationResult the result of the previous build step
      */
     private void runScenarioTests(TestPlan testPlan, DeploymentCreationResult deploymentCreationResult) {
+
+        /* Set dir for scenarios from values matched from test-plan yaml file */
         for (TestScenario testScenario : testPlan.getScenarioConfig().getScenarios()) {
+            for (TestScenario testScenario1 : testPlan.getTestScenarios()) {
+                if (testScenario.getName().equals(testScenario1.getName())) {
+                    testScenario1.setDir(testScenario.getDir());
+                }
+            }
+        }
+        for (TestScenario testScenario : testPlan.getTestScenarios()) {
             try {
                 scenarioExecutor.execute(testScenario, deploymentCreationResult, testPlan);
             } catch (Exception e) {
Repository: wso2/testgrid
Issue: Stack deletion does not get notified to the TestGrid

**Description:**

TestGrid waits indefinitely for stack delete response from AWS waiters. This causes the build jobs to hang in stack deletion request forever.

**Affected Product Version:**
0.9.0-m20

**Steps to reproduce:**
1. Run a job in TestGrid dev or prod environments
2. Check for stack delete request
3. TestGrid stucks in the same place even though the stack has deleted

Changed files:
infrastructure/src/main/java/org/wso2/testgrid/infrastructure/providers/AWSProvider.java

diff --git a/infrastructure/src/main/java/org/wso2/testgrid/infrastructure/providers/AWSProvider.java b/infrastructure/src/main/java/org/wso2/testgrid/infrastructure/providers/AWSProvider.java
index 3f407582..5defdaba 100644
--- a/infrastructure/src/main/java/org/wso2/testgrid/infrastructure/providers/AWSProvider.java
+++ b/infrastructure/src/main/java/org/wso2/testgrid/infrastructure/providers/AWSProvider.java
@@ -271,7 +271,8 @@ public class AWSProvider implements InfrastructureProvider {
         Waiter<DescribeStacksRequest> describeStacksRequestWaiter = new
                 AmazonCloudFormationWaiters(stackdestroy).stackDeleteComplete();
         try {
-            describeStacksRequestWaiter.run(new WaiterParameters<>(new DescribeStacksRequest()));
+            describeStacksRequestWaiter.run(new WaiterParameters<>(new DescribeStacksRequest()
+                    .withStackName(stackName)));
         } catch (WaiterUnrecoverableException e) {
             throw new TestGridInfrastructureException("Error occured while waiting for Stack :"
                     + stackName + " deletion !");
Repository: wso2/testgrid
Issue: Thread hangs when a shell command is executed

**Description:**

Thread hangs when a shell command is executed. The shutdown method is not called in the ShellExecutor. 

Changed files:
common/src/main/java/org/wso2/testgrid/common/ShellExecutor.java

diff --git a/common/src/main/java/org/wso2/testgrid/common/ShellExecutor.java b/common/src/main/java/org/wso2/testgrid/common/ShellExecutor.java
index d0be5ae9..e3acb5a6 100644
--- a/common/src/main/java/org/wso2/testgrid/common/ShellExecutor.java
+++ b/common/src/main/java/org/wso2/testgrid/common/ShellExecutor.java
@@ -30,6 +30,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Path;
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.function.Consumer;
 
@@ -96,6 +97,8 @@ public class ShellExecutor {
             logger.debug("Running shell command : " + command + ", from directory : " + workingDirectory.toString());
         }
         ProcessBuilder processBuilder = new ProcessBuilder("/bin/bash", "-c", command);
+        ExecutorService executor = Executors.newFixedThreadPool(2);
+
         try {
             if (workingDirectory != null) {
                 File workDirectory = workingDirectory.toFile();
@@ -107,8 +110,9 @@ public class ShellExecutor {
 
             StreamGobbler outputStreamGobbler = new StreamGobbler(process.getInputStream(), logger::info);
             StreamGobbler errorStreamGobbler = new StreamGobbler(process.getErrorStream(), logger::error);
-            Executors.newSingleThreadExecutor().submit(outputStreamGobbler);
-            Executors.newSingleThreadExecutor().submit(errorStreamGobbler);
+
+            executor.submit(outputStreamGobbler);
+            executor.submit(errorStreamGobbler);
 
             return process.waitFor() == 0;
 
@@ -120,6 +124,8 @@ public class ShellExecutor {
             throw new CommandExecutionException(
                     "InterruptedException occurred while executing the command '" + command + "', " + "from directory '"
                             + workingDirectory.toString(), e);
+        } finally {
+            executor.shutdownNow();
         }
     }
 }
Repository: wso2/testgrid
Issue: Tests fail in testgrid-core 

**Description:**
Build in jenkins goes unstable due to failing tests in org.wso2.testgrid.core

**Suggested Labels:**
Type/Bug

**Suggested Assignees:**
AsmaJ

Changed files:
core/src/main/java/org/wso2/testgrid/core/TestPlanExecutor.java

diff --git a/core/src/main/java/org/wso2/testgrid/core/TestPlanExecutor.java b/core/src/main/java/org/wso2/testgrid/core/TestPlanExecutor.java
index a11f1d4f..1951d5c1 100644
--- a/core/src/main/java/org/wso2/testgrid/core/TestPlanExecutor.java
+++ b/core/src/main/java/org/wso2/testgrid/core/TestPlanExecutor.java
@@ -90,7 +90,6 @@ public class TestPlanExecutor {
             for (TestScenario testScenario : testPlan.getTestScenarios()) {
                 testScenario.setStatus(Status.DID_NOT_RUN);
             }
-            TestPlanUOW testPlanUOW = new TestPlanUOW();
             testPlanUOW.persistTestPlan(testPlan);
             logger.error(StringUtil.concatStrings(
                     "Error occurred while performing deployment for test plan", testPlan.getId(),
Repository: wso2/testgrid
Issue: Test results download in the dashboard fails

**Description:**
Test results download in the dashboard fails though results exist in S3.



Changed files:
common/src/main/java/org/wso2/testgrid/common/plugins/AWSArtifactReader.java

diff --git a/common/src/main/java/org/wso2/testgrid/common/plugins/AWSArtifactReader.java b/common/src/main/java/org/wso2/testgrid/common/plugins/AWSArtifactReader.java
index 5eb25ee4..e9e2c698 100644
--- a/common/src/main/java/org/wso2/testgrid/common/plugins/AWSArtifactReader.java
+++ b/common/src/main/java/org/wso2/testgrid/common/plugins/AWSArtifactReader.java
@@ -104,6 +104,7 @@ public class AWSArtifactReader implements ArtifactReadable {
 
     @Override
     public Boolean isArtifactExist(String key) {
-        return amazonS3.doesObjectExist(bucketName, key);
+        return amazonS3.doesObjectExist(bucketName, key) ||
+                amazonS3.listObjectsV2(bucketName, key).getKeyCount() > 0;
     }
 }
Repository: wso2/testgrid
Issue: Parameters have extra surrounding spaces

**Description:**
Parameters that are replaced in the jmx files contain extra spaces.



Changed files:
automation/src/main/java/org/wso2/testgrid/automation/executor/JMeterExecutor.java

diff --git a/automation/src/main/java/org/wso2/testgrid/automation/executor/JMeterExecutor.java b/automation/src/main/java/org/wso2/testgrid/automation/executor/JMeterExecutor.java
index 27c6c685..d4a68cbd 100644
--- a/automation/src/main/java/org/wso2/testgrid/automation/executor/JMeterExecutor.java
+++ b/automation/src/main/java/org/wso2/testgrid/automation/executor/JMeterExecutor.java
@@ -205,7 +205,7 @@ public class JMeterExecutor extends TestExecutor {
             Enumeration<?> enumeration = jMeterProperties.propertyNames();
             while (enumeration.hasMoreElements()) {
                 String name = (String) enumeration.nextElement();
-                jmx = jmx.replaceAll("\\\\$\\\\{__property\\\\(" + name + "\\\\)\\\\}", JMeterUtils.getProperty(name));
+                jmx = jmx.replaceAll("\\\\$\\\\{__property\\\\(" + name + "\\\\)\\\\}", JMeterUtils.getProperty(name).trim());
             }
             String[] split = script.split(File.separatorChar == '\\\\' ? "\\\\\\\\" : File.separator);
             StringBuilder buffer = new StringBuilder();
Repository: wso2/testgrid
Issue: Report generation is not done to the latest product test plan

**Description:**
Report generation is not done to the latest product test plan

Changed files:
dao/src/main/java/org/wso2/testgrid/dao/uow/ReportGenerationUOW.java

diff --git a/dao/src/main/java/org/wso2/testgrid/dao/uow/ReportGenerationUOW.java b/dao/src/main/java/org/wso2/testgrid/dao/uow/ReportGenerationUOW.java
index 3eb0956d..ad79e200 100644
--- a/dao/src/main/java/org/wso2/testgrid/dao/uow/ReportGenerationUOW.java
+++ b/dao/src/main/java/org/wso2/testgrid/dao/uow/ReportGenerationUOW.java
@@ -65,7 +65,7 @@ public class ReportGenerationUOW {
         // JPQL  query to get the latest modifies product test plan for product name and version
         String sqlQuery = StringUtil.concatStrings("SELECT c FROM ", ProductTestPlan.class.getSimpleName(),
                 " c WHERE c.productName=\\"", productName, "\\" AND ",
-                "c.productVersion=\\"", productVersion, "\\" ORDER BY c.modifiedTimestamp");
+                "c.productVersion=\\"", productVersion, "\\" ORDER BY c.modifiedTimestamp DESC");
         return productTestPlanRepository.executeTypedQuary(sqlQuery, ProductTestPlan.class, 1);
     }
Repository: wso2/testgrid
Issue: Build fails due to a Checkstyle error

**Description:**
Project build fails due to a Checkstyle error caused by an unused import.

**Suggested Labels:**
Type/Bug
**Suggested Assignees:**
AsmaJ

Changed files:
infrastructure/src/main/java/org/wso2/testgrid/infrastructure/aws/AWSManager.java

diff --git a/infrastructure/src/main/java/org/wso2/testgrid/infrastructure/aws/AWSManager.java b/infrastructure/src/main/java/org/wso2/testgrid/infrastructure/aws/AWSManager.java
index 915fe06f..f1f4ab74 100644
--- a/infrastructure/src/main/java/org/wso2/testgrid/infrastructure/aws/AWSManager.java
+++ b/infrastructure/src/main/java/org/wso2/testgrid/infrastructure/aws/AWSManager.java
@@ -46,7 +46,6 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 import java.util.Properties;
Repository: ballerina-platform/module-ballerina-c2c
Issue: Secrets are not getting loaded to yaml when Cloud.toml does not exist

**Description:**
$Subject.


**Suggested Labels:**
<!-- Optional comma separated list of suggested labels. Non committers can’t assign labels to issues, so this will help issue creators who are not a committer to suggest possible labels-->

**Suggested Assignees:**
<!--Optional comma separated list of suggested team members who should attend the issue. Non committers can’t assign issues to assignees, so this will help issue creators who are not a committer to suggest possible assignees-->

**Affected Product Version:**

**OS, DB, other environment details and versions:**    

**Steps to reproduce:**


**Related Issues:**
<!-- Any related issues such as sub tasks, issues reported in other repositories (e.g component repositories), similar problems, etc. -->

Changed files:
c2c-extension/src/main/java/io/ballerina/c2c/CloudTomlResolver.java, c2c-extension/src/main/java/io/ballerina/c2c/ArtifactManager.java

diff --git a/c2c-extension/src/main/java/io/ballerina/c2c/ArtifactManager.java b/c2c-extension/src/main/java/io/ballerina/c2c/ArtifactManager.java
index e0083ab..e262ae8 100644
--- a/c2c-extension/src/main/java/io/ballerina/c2c/ArtifactManager.java
+++ b/c2c-extension/src/main/java/io/ballerina/c2c/ArtifactManager.java
@@ -24,6 +24,7 @@ import io.ballerina.c2c.handlers.DeploymentHandler;
 import io.ballerina.c2c.handlers.DockerHandler;
 import io.ballerina.c2c.handlers.HPAHandler;
 import io.ballerina.c2c.handlers.JobHandler;
+import io.ballerina.c2c.handlers.SecretHandler;
 import io.ballerina.c2c.handlers.ServiceHandler;
 import io.ballerina.c2c.models.DeploymentModel;
 import io.ballerina.c2c.models.KubernetesContext;
@@ -85,6 +86,7 @@ public class ArtifactManager {
             new ConfigMapHandler().createArtifacts();
             new DeploymentHandler().createArtifacts();
             new HPAHandler().createArtifacts();
+            new SecretHandler().createArtifacts();
         }
         new DockerHandler().createArtifacts();
         printInstructions();
diff --git a/c2c-extension/src/main/java/io/ballerina/c2c/CloudTomlResolver.java b/c2c-extension/src/main/java/io/ballerina/c2c/CloudTomlResolver.java
index 5298539..aab6e72 100644
--- a/c2c-extension/src/main/java/io/ballerina/c2c/CloudTomlResolver.java
+++ b/c2c-extension/src/main/java/io/ballerina/c2c/CloudTomlResolver.java
@@ -21,7 +21,6 @@ package io.ballerina.c2c;
 import io.ballerina.c2c.diagnostics.C2CDiagnosticCodes;
 import io.ballerina.c2c.diagnostics.NullLocation;
 import io.ballerina.c2c.exceptions.KubernetesPluginException;
-import io.ballerina.c2c.handlers.SecretHandler;
 import io.ballerina.c2c.models.ConfigMapModel;
 import io.ballerina.c2c.models.DeploymentModel;
 import io.ballerina.c2c.models.KubernetesContext;
@@ -264,7 +263,6 @@ public class CloudTomlResolver {
                 dataHolder.addSecrets(Collections.singleton(secretModel));
             }
         }
-        new SecretHandler().createArtifacts();
     }
 
     private Path validatePaths(Path path, Path mountPath) throws KubernetesPluginException {