Skip to content

Commit 6fb2768

Browse files
authored
Merge pull request #218 from vidurananayakkara/issue-205
Implement generate infrastructures based on user input
2 parents 4b57343 + 5fcc496 commit 6fb2768

File tree

36 files changed

+937
-3574
lines changed

36 files changed

+937
-3574
lines changed

common/src/main/java/org/wso2/testgrid/common/Database.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.wso2.carbon.config.annotation.Element;
2222

2323
import java.io.Serializable;
24+
import java.util.Objects;
2425
import javax.persistence.Column;
2526
import javax.persistence.Entity;
2627
import javax.persistence.EnumType;
@@ -99,6 +100,23 @@ public void setVersion(String version) {
99100
this.version = version;
100101
}
101102

103+
@Override
104+
public boolean equals(Object object) {
105+
if (this == object) {
106+
return true;
107+
}
108+
if (!(object instanceof Database)) {
109+
return false;
110+
}
111+
Database database = (Database) object;
112+
return engine == database.engine && Objects.equals(version, database.version);
113+
}
114+
115+
@Override
116+
public int hashCode() {
117+
return Objects.hash(engine, version);
118+
}
119+
102120
@Override
103121
public String toString() {
104122
return "Database{" +

common/src/main/java/org/wso2/testgrid/common/InfraCombination.java

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.wso2.carbon.config.annotation.Element;
2121

2222
import java.io.Serializable;
23+
import java.util.Objects;
2324
import javax.persistence.CascadeType;
2425
import javax.persistence.Column;
2526
import javax.persistence.Entity;
@@ -72,16 +73,6 @@ public class InfraCombination extends AbstractUUIDEntity implements Serializable
7273
@Element(description = "Defines the database configuration")
7374
private Database database;
7475

75-
@Override
76-
public String toString() {
77-
return "InfraCombination{" +
78-
"id='" + this.getId() + '\'' +
79-
", jdk=" + jdk +
80-
", operatingSystem=" + operatingSystem +
81-
", database=" + database +
82-
'}';
83-
}
84-
8576
/**
8677
* Returns the JDK for the infra-combination.
8778
*
@@ -136,6 +127,34 @@ public void setDatabase(Database database) {
136127
this.database = database;
137128
}
138129

130+
@Override
131+
public boolean equals(Object object) {
132+
if (this == object) {
133+
return true;
134+
}
135+
if (!(object instanceof InfraCombination)) {
136+
return false;
137+
}
138+
InfraCombination that = (InfraCombination) object;
139+
return jdk == that.jdk && Objects.equals(operatingSystem, that.operatingSystem) &&
140+
Objects.equals(database, that.database);
141+
}
142+
143+
@Override
144+
public int hashCode() {
145+
return Objects.hash(jdk, operatingSystem, database);
146+
}
147+
148+
@Override
149+
public String toString() {
150+
return "InfraCombination{" +
151+
"id='" + this.getId() + '\'' +
152+
", jdk=" + jdk +
153+
", operatingSystem=" + operatingSystem +
154+
", database=" + database +
155+
'}';
156+
}
157+
139158
/**
140159
* This defines the possible JDKs of the {@link InfraCombination}.
141160
*

common/src/main/java/org/wso2/testgrid/common/Infrastructure.java

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,27 @@
1818

1919
package org.wso2.testgrid.common;
2020

21-
import org.wso2.carbon.config.annotation.Configuration;
22-
import org.wso2.carbon.config.annotation.Element;
23-
2421
import java.io.Serializable;
2522
import java.util.List;
2623
import java.util.Map;
2724

2825
/**
2926
* Defines a model object for a Infrastructure.
27+
*
28+
* @since 1.0.0
3029
*/
31-
@Configuration(namespace = "wso2.testgrid.infrastructure",
32-
description = "TestGrid Infrastructure Configuration Parameters")
3330
public class Infrastructure implements Serializable {
3431

3532
private static final long serialVersionUID = -1660815137752094462L;
3633

37-
@Element(description = "defines the name of this infrastructure")
3834
private String name;
39-
@Element(description = "defines the infrastructure provider type (i.e. AWS, OpenStack)")
4035
private ProviderType providerType;
41-
@Element(description = "defines the required instance type (i.e. EC2, Docker)")
4236
private InstanceType instanceType;
43-
@Element(description = "defines the required cluster type (i.e. ECS, Kubernetes)")
4437
private ClusterType clusterType;
45-
@Element(description = "defines the required infrastructure combination")
4638
private InfraCombination infraCombination;
47-
@Element(description = "holds the required properties for security related stuff")
4839
private Map<String, String> securityProperties;
49-
@Element(description = "holds the list of customized scripts if provided")
5040
private List<Script> scripts;
51-
@Element(description = "defines the region in which the infrastructure should be created")
5241
private String region;
53-
@Element(description = "holds the additional properties for the infrastructure")
54-
private Map<String, String> infraArguments;
55-
@Element(description = "defines the image to be used when setting up the instances")
5642
private String imageId;
5743

5844
/**
@@ -199,24 +185,6 @@ public void setRegion(String region) {
199185
this.region = region;
200186
}
201187

202-
/**
203-
* Returns the infrastructure arguments.
204-
*
205-
* @return the infrastructure arguments
206-
*/
207-
public Map<String, String> getInfraArguments() {
208-
return infraArguments;
209-
}
210-
211-
/**
212-
* Sets the the infrastructure arguments.
213-
*
214-
* @param infraArguments the infrastructure arguments
215-
*/
216-
public void setInfraArguments(Map<String, String> infraArguments) {
217-
this.infraArguments = infraArguments;
218-
}
219-
220188
/**
221189
* Returns the image id of the infrastructure.
222190
*

common/src/main/java/org/wso2/testgrid/common/OperatingSystem.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.wso2.carbon.config.annotation.Element;
2222

2323
import java.io.Serializable;
24+
import java.util.Objects;
2425
import javax.persistence.Column;
2526
import javax.persistence.Entity;
2627
import javax.persistence.Table;
@@ -96,6 +97,23 @@ public void setVersion(String version) {
9697
this.version = version;
9798
}
9899

100+
@Override
101+
public boolean equals(Object object) {
102+
if (this == object) {
103+
return true;
104+
}
105+
if (!(object instanceof OperatingSystem)) {
106+
return false;
107+
}
108+
OperatingSystem that = (OperatingSystem) object;
109+
return Objects.equals(name, that.name) && Objects.equals(version, that.version);
110+
}
111+
112+
@Override
113+
public int hashCode() {
114+
return Objects.hash(name, version);
115+
}
116+
99117
@Override
100118
public String toString() {
101119
return "OperatingSystem{" +

common/src/main/java/org/wso2/testgrid/common/TestPlan.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@ public class TestPlan extends AbstractUUIDEntity implements Serializable {
117117
@Transient
118118
private Deployment deployment;
119119

120-
@Transient
121-
@Element(description = "flag to enable or disable the testplan")
122-
private boolean enabled;
123-
124120
@Transient
125121
private String testRepoDir;
126122

@@ -333,24 +329,6 @@ public void setDeployment(Deployment deployment) {
333329
this.deployment = deployment;
334330
}
335331

336-
/**
337-
* Returns if the test plan is enabled or not.
338-
*
339-
* @return if the test plan is enabled or not
340-
*/
341-
public boolean isEnabled() {
342-
return enabled;
343-
}
344-
345-
/**
346-
* Sets if the test plan is enabled or not.
347-
*
348-
* @param enabled test plan is enabled or not
349-
*/
350-
public void setEnabled(boolean enabled) {
351-
this.enabled = enabled;
352-
}
353-
354332
/**
355333
* Returns the path of the test plans' test artifacts.
356334
*
@@ -439,7 +417,6 @@ public String toString() {
439417
", testScenarios=" + testScenarios +
440418
", deployerType=" + deployerType +
441419
", deployment=" + deployment +
442-
", enabled=" + enabled +
443420
", testRepoDir='" + testRepoDir + '\'' +
444421
", infraRepoDir='" + infraRepoDir + '\'' +
445422
", infrastructureScript=" + infrastructureScript +

common/src/main/java/org/wso2/testgrid/common/TestScenario.java

Lines changed: 32 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import javax.persistence.OneToMany;
3434
import javax.persistence.PrimaryKeyJoinColumn;
3535
import javax.persistence.Table;
36-
import javax.persistence.Transient;
3736

3837

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

6262
private static final long serialVersionUID = -2666342786241472418L;
6363

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

79-
@Transient
80-
@Element(description = "flag to enable or disable the test scenario")
81-
private boolean enabled;
82-
83-
@Transient
84-
@Element(description = "holds the test engine type (i.e. JMETER, TESTNG)")
85-
private TestEngine testEngine;
86-
8779
@Column(name = "is_pre_script_success")
8880
@Element(description = "holds the status true if pre script is successful")
8981
private boolean isPreScriptSuccessful = false;
@@ -92,6 +84,11 @@ public class TestScenario extends AbstractUUIDEntity implements Serializable {
9284
@Element(description = "holds the status true if post script is successful")
9385
private boolean isPostScriptSuccessful = false;
9486

87+
@Enumerated(EnumType.STRING)
88+
@Column(name = "test_engine", nullable = false)
89+
@Element(description = "holds the test engine type (i.e. JMETER, TESTNG)")
90+
private TestEngine testEngine;
91+
9592
/**
9693
* Returns the status of the test scenario.
9794
*
@@ -165,23 +162,39 @@ public void setTestCases(List<TestCase> testCases) {
165162
}
166163

167164
/**
168-
* Returns whether the test scenario is enabled or not.
169-
* <p>
170-
* Returns {@code true} if the test scenario is enabled, {@code false} otherwise
165+
* Checks if pre script is successful.
171166
*
172-
* @return is test scenario enabled or not
167+
* @return {@code true} if the pre script is successful, {@code false} otherwise
173168
*/
174-
public boolean isEnabled() {
175-
return enabled;
169+
public boolean isPreScriptSuccessful() {
170+
return isPreScriptSuccessful;
176171
}
177172

178173
/**
179-
* Sets whether the test scenario is enabled or not.
174+
* Sets the status of the pre script execution.
180175
*
181-
* @param enabled is test scenario enabled or not
176+
* @param isPreScriptSuccessful Status of pre script execution
182177
*/
183-
public void setEnabled(boolean enabled) {
184-
this.enabled = enabled;
178+
public void setIsPreScriptSuccessful(boolean isPreScriptSuccessful) {
179+
this.isPreScriptSuccessful = isPreScriptSuccessful;
180+
}
181+
182+
/**
183+
* Checks if post script is successful.
184+
*
185+
* @return {@code true} if the post script is successful, {@code false} otherwise
186+
*/
187+
public boolean isPostScriptSuccessful() {
188+
return isPostScriptSuccessful;
189+
}
190+
191+
/**
192+
* Sets the status of the post script execution.
193+
*
194+
* @param isPostScriptSuccessful Status of the post script execution
195+
*/
196+
public void setIsPostScriptSuccessful(boolean isPostScriptSuccessful) {
197+
this.isPostScriptSuccessful = isPostScriptSuccessful;
185198
}
186199

187200
/**
@@ -218,47 +231,10 @@ public String toString() {
218231
", status=" + status +
219232
", name='" + name + '\'' +
220233
", testPlan=" + testPlan +
221-
", enabled=" + enabled +
222234
", testEngine=" + testEngine +
223235
'}';
224236
}
225237

226-
/**
227-
* Sets the status of the pre script execution.
228-
*
229-
* @param isPreScriptSuccessful Status of pre script execution
230-
*/
231-
public void setIsPreScriptSuccessful(boolean isPreScriptSuccessful) {
232-
this.isPreScriptSuccessful = isPreScriptSuccessful;
233-
}
234-
235-
/**
236-
* Sets the status of the post script execution.
237-
*
238-
* @param isPostScriptSuccessful Status of the post script execution
239-
*/
240-
public void setIsPostScriptSuccessful(boolean isPostScriptSuccessful) {
241-
this.isPostScriptSuccessful = isPostScriptSuccessful;
242-
}
243-
244-
/**
245-
* Checks if pre script is successful.
246-
*
247-
* @return Status of the script execution
248-
*/
249-
public boolean isPreScriptSuccessful() {
250-
return isPreScriptSuccessful;
251-
}
252-
253-
/**
254-
* Checks if post script is successful.
255-
*
256-
* @return Status of the script execution
257-
*/
258-
public boolean isPostScriptSuccessful() {
259-
return isPostScriptSuccessful;
260-
}
261-
262238
/**
263239
* This defines the possible statuses of the {@link TestScenario}.
264240
*

0 commit comments

Comments
 (0)