Skip to content

Commit

Permalink
Merge pull request #218 from vidurananayakkara/issue-205
Browse files Browse the repository at this point in the history
Implement generate infrastructures based on user input
  • Loading branch information
azinneera authored Dec 8, 2017
2 parents 4b57343 + 5fcc496 commit 6fb2768
Show file tree
Hide file tree
Showing 36 changed files with 937 additions and 3,574 deletions.
18 changes: 18 additions & 0 deletions common/src/main/java/org/wso2/testgrid/common/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.wso2.carbon.config.annotation.Element;

import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
Expand Down Expand Up @@ -99,6 +100,23 @@ public void setVersion(String version) {
this.version = version;
}

@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (!(object instanceof Database)) {
return false;
}
Database database = (Database) object;
return engine == database.engine && Objects.equals(version, database.version);
}

@Override
public int hashCode() {
return Objects.hash(engine, version);
}

@Override
public String toString() {
return "Database{" +
Expand Down
39 changes: 29 additions & 10 deletions common/src/main/java/org/wso2/testgrid/common/InfraCombination.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.wso2.carbon.config.annotation.Element;

import java.io.Serializable;
import java.util.Objects;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
Expand Down Expand Up @@ -72,16 +73,6 @@ public class InfraCombination extends AbstractUUIDEntity implements Serializable
@Element(description = "Defines the database configuration")
private Database database;

@Override
public String toString() {
return "InfraCombination{" +
"id='" + this.getId() + '\'' +
", jdk=" + jdk +
", operatingSystem=" + operatingSystem +
", database=" + database +
'}';
}

/**
* Returns the JDK for the infra-combination.
*
Expand Down Expand Up @@ -136,6 +127,34 @@ public void setDatabase(Database database) {
this.database = database;
}

@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (!(object instanceof InfraCombination)) {
return false;
}
InfraCombination that = (InfraCombination) object;
return jdk == that.jdk && Objects.equals(operatingSystem, that.operatingSystem) &&
Objects.equals(database, that.database);
}

@Override
public int hashCode() {
return Objects.hash(jdk, operatingSystem, database);
}

@Override
public String toString() {
return "InfraCombination{" +
"id='" + this.getId() + '\'' +
", jdk=" + jdk +
", operatingSystem=" + operatingSystem +
", database=" + database +
'}';
}

/**
* This defines the possible JDKs of the {@link InfraCombination}.
*
Expand Down
36 changes: 2 additions & 34 deletions common/src/main/java/org/wso2/testgrid/common/Infrastructure.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,27 @@

package org.wso2.testgrid.common;

import org.wso2.carbon.config.annotation.Configuration;
import org.wso2.carbon.config.annotation.Element;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
* Defines a model object for a Infrastructure.
*
* @since 1.0.0
*/
@Configuration(namespace = "wso2.testgrid.infrastructure",
description = "TestGrid Infrastructure Configuration Parameters")
public class Infrastructure implements Serializable {

private static final long serialVersionUID = -1660815137752094462L;

@Element(description = "defines the name of this infrastructure")
private String name;
@Element(description = "defines the infrastructure provider type (i.e. AWS, OpenStack)")
private ProviderType providerType;
@Element(description = "defines the required instance type (i.e. EC2, Docker)")
private InstanceType instanceType;
@Element(description = "defines the required cluster type (i.e. ECS, Kubernetes)")
private ClusterType clusterType;
@Element(description = "defines the required infrastructure combination")
private InfraCombination infraCombination;
@Element(description = "holds the required properties for security related stuff")
private Map<String, String> securityProperties;
@Element(description = "holds the list of customized scripts if provided")
private List<Script> scripts;
@Element(description = "defines the region in which the infrastructure should be created")
private String region;
@Element(description = "holds the additional properties for the infrastructure")
private Map<String, String> infraArguments;
@Element(description = "defines the image to be used when setting up the instances")
private String imageId;

/**
Expand Down Expand Up @@ -199,24 +185,6 @@ public void setRegion(String region) {
this.region = region;
}

/**
* Returns the infrastructure arguments.
*
* @return the infrastructure arguments
*/
public Map<String, String> getInfraArguments() {
return infraArguments;
}

/**
* Sets the the infrastructure arguments.
*
* @param infraArguments the infrastructure arguments
*/
public void setInfraArguments(Map<String, String> infraArguments) {
this.infraArguments = infraArguments;
}

/**
* Returns the image id of the infrastructure.
*
Expand Down
18 changes: 18 additions & 0 deletions common/src/main/java/org/wso2/testgrid/common/OperatingSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.wso2.carbon.config.annotation.Element;

import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
Expand Down Expand Up @@ -96,6 +97,23 @@ public void setVersion(String version) {
this.version = version;
}

@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (!(object instanceof OperatingSystem)) {
return false;
}
OperatingSystem that = (OperatingSystem) object;
return Objects.equals(name, that.name) && Objects.equals(version, that.version);
}

@Override
public int hashCode() {
return Objects.hash(name, version);
}

@Override
public String toString() {
return "OperatingSystem{" +
Expand Down
23 changes: 0 additions & 23 deletions common/src/main/java/org/wso2/testgrid/common/TestPlan.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ public class TestPlan extends AbstractUUIDEntity implements Serializable {
@Transient
private Deployment deployment;

@Transient
@Element(description = "flag to enable or disable the testplan")
private boolean enabled;

@Transient
private String testRepoDir;

Expand Down Expand Up @@ -333,24 +329,6 @@ public void setDeployment(Deployment deployment) {
this.deployment = deployment;
}

/**
* Returns if the test plan is enabled or not.
*
* @return if the test plan is enabled or not
*/
public boolean isEnabled() {
return enabled;
}

/**
* Sets if the test plan is enabled or not.
*
* @param enabled test plan is enabled or not
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

/**
* Returns the path of the test plans' test artifacts.
*
Expand Down Expand Up @@ -439,7 +417,6 @@ public String toString() {
", testScenarios=" + testScenarios +
", deployerType=" + deployerType +
", deployment=" + deployment +
", enabled=" + enabled +
", testRepoDir='" + testRepoDir + '\'' +
", infraRepoDir='" + infraRepoDir + '\'' +
", infrastructureScript=" + infrastructureScript +
Expand Down
88 changes: 32 additions & 56 deletions common/src/main/java/org/wso2/testgrid/common/TestScenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import javax.persistence.OneToMany;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Transient;


/**
Expand All @@ -58,6 +57,7 @@ public class TestScenario extends AbstractUUIDEntity implements Serializable {
public static final String TEST_PLAN_COLUMN = "testPlan";
public static final String PRE_SCRIPT_STATUS_COLUMN = "isPreScriptSuccessful";
public static final String POST_SCRIPT_STATUS_COLUMN = "isPostScriptSuccessful";
public static final String TEST_ENGINE_COLUMN = "testEngine";

private static final long serialVersionUID = -2666342786241472418L;

Expand All @@ -76,14 +76,6 @@ public class TestScenario extends AbstractUUIDEntity implements Serializable {
@OneToMany(mappedBy = "testScenario", cascade = CascadeType.ALL, orphanRemoval = true)
private List<TestCase> testCases;

@Transient
@Element(description = "flag to enable or disable the test scenario")
private boolean enabled;

@Transient
@Element(description = "holds the test engine type (i.e. JMETER, TESTNG)")
private TestEngine testEngine;

@Column(name = "is_pre_script_success")
@Element(description = "holds the status true if pre script is successful")
private boolean isPreScriptSuccessful = false;
Expand All @@ -92,6 +84,11 @@ public class TestScenario extends AbstractUUIDEntity implements Serializable {
@Element(description = "holds the status true if post script is successful")
private boolean isPostScriptSuccessful = false;

@Enumerated(EnumType.STRING)
@Column(name = "test_engine", nullable = false)
@Element(description = "holds the test engine type (i.e. JMETER, TESTNG)")
private TestEngine testEngine;

/**
* Returns the status of the test scenario.
*
Expand Down Expand Up @@ -165,23 +162,39 @@ public void setTestCases(List<TestCase> testCases) {
}

/**
* Returns whether the test scenario is enabled or not.
* <p>
* Returns {@code true} if the test scenario is enabled, {@code false} otherwise
* Checks if pre script is successful.
*
* @return is test scenario enabled or not
* @return {@code true} if the pre script is successful, {@code false} otherwise
*/
public boolean isEnabled() {
return enabled;
public boolean isPreScriptSuccessful() {
return isPreScriptSuccessful;
}

/**
* Sets whether the test scenario is enabled or not.
* Sets the status of the pre script execution.
*
* @param enabled is test scenario enabled or not
* @param isPreScriptSuccessful Status of pre script execution
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
public void setIsPreScriptSuccessful(boolean isPreScriptSuccessful) {
this.isPreScriptSuccessful = isPreScriptSuccessful;
}

/**
* Checks if post script is successful.
*
* @return {@code true} if the post script is successful, {@code false} otherwise
*/
public boolean isPostScriptSuccessful() {
return isPostScriptSuccessful;
}

/**
* Sets the status of the post script execution.
*
* @param isPostScriptSuccessful Status of the post script execution
*/
public void setIsPostScriptSuccessful(boolean isPostScriptSuccessful) {
this.isPostScriptSuccessful = isPostScriptSuccessful;
}

/**
Expand Down Expand Up @@ -218,47 +231,10 @@ public String toString() {
", status=" + status +
", name='" + name + '\'' +
", testPlan=" + testPlan +
", enabled=" + enabled +
", testEngine=" + testEngine +
'}';
}

/**
* Sets the status of the pre script execution.
*
* @param isPreScriptSuccessful Status of pre script execution
*/
public void setIsPreScriptSuccessful(boolean isPreScriptSuccessful) {
this.isPreScriptSuccessful = isPreScriptSuccessful;
}

/**
* Sets the status of the post script execution.
*
* @param isPostScriptSuccessful Status of the post script execution
*/
public void setIsPostScriptSuccessful(boolean isPostScriptSuccessful) {
this.isPostScriptSuccessful = isPostScriptSuccessful;
}

/**
* Checks if pre script is successful.
*
* @return Status of the script execution
*/
public boolean isPreScriptSuccessful() {
return isPreScriptSuccessful;
}

/**
* Checks if post script is successful.
*
* @return Status of the script execution
*/
public boolean isPostScriptSuccessful() {
return isPostScriptSuccessful;
}

/**
* This defines the possible statuses of the {@link TestScenario}.
*
Expand Down
Loading

0 comments on commit 6fb2768

Please sign in to comment.