Skip to content

Commit d363235

Browse files
nakshatrisSuman Nakshatri
andauthored
SRE-35206: integration test pipeline (#402)
* SRE-35206: Create Integration test pipeline with test_support * SRE-35209: Project and script integration tests Co-authored-by: Suman Nakshatri <suman_nakshatri@intuit.com>
1 parent a2d42f0 commit d363235

File tree

19 files changed

+2166
-100
lines changed

19 files changed

+2166
-100
lines changed

buildspec.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,20 @@ phases:
1313
build:
1414
commands:
1515
- java -version
16+
# Run the complete build with both unit and integration tests
1617
- mvn clean install surefire-report:report -P release
1718

1819
reports:
19-
SurefireReports: # CodeBuild will create a report group called "SurefireReports".
20-
files: #Store all of the files
21-
- '**/*'
22-
base-directory: 'web/web_support/target/surefire-reports' # Location of the reports
20+
UnitTestReports:
21+
files:
22+
- '**/target/surefire-reports/TEST-*.xml'
23+
- '**/target/surefire-reports/*.txt'
24+
base-directory: '.'
25+
IntegrationTestReports:
26+
files:
27+
- '**/target/failsafe-reports/TEST-*.xml'
28+
- '**/target/failsafe-reports/*.txt'
29+
base-directory: '.'
2330

2431
artifacts:
2532
files:

data_access/src/main/java/com/intuit/tank/dao/ProjectDao.java

Lines changed: 55 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@
4343

4444
/**
4545
* ProductDao
46-
*
46+
*
4747
* @author dangleton
48-
*
4948
*/
5049
public class ProjectDao extends OwnableDao<Project> {
5150
private static final Logger LOG = LogManager.getLogger(ProjectDao.class);
@@ -62,25 +61,25 @@ public ProjectDao() {
6261
* @return
6362
*/
6463
public Project findByName(@Nonnull String name) {
65-
Project project = null;
66-
EntityManager em = getEntityManager();
67-
try {
68-
begin();
69-
CriteriaBuilder cb = em.getCriteriaBuilder();
70-
CriteriaQuery<Project> query = cb.createQuery(Project.class);
71-
Root<Project> root = query.from(Project.class);
72-
query.select(root);
73-
query.where(cb.equal(root.<String>get(Project.PROPERTY_NAME), name));
74-
project = em.createQuery(query).getSingleResult();
75-
commit();
64+
Project project = null;
65+
EntityManager em = getEntityManager();
66+
try {
67+
begin();
68+
CriteriaBuilder cb = em.getCriteriaBuilder();
69+
CriteriaQuery<Project> query = cb.createQuery(Project.class);
70+
Root<Project> root = query.from(Project.class);
71+
query.select(root);
72+
query.where(cb.equal(root.<String>get(Project.PROPERTY_NAME), name));
73+
project = em.createQuery(query).getSingleResult();
74+
commit();
7675
} catch (Exception e) {
77-
rollback();
76+
rollback();
7877
e.printStackTrace();
7978
throw new RuntimeException(e);
80-
} finally {
81-
cleanup();
82-
}
83-
return project;
79+
} finally {
80+
cleanup();
81+
}
82+
return project;
8483
}
8584

8685
/**
@@ -107,71 +106,68 @@ public Project saveOrUpdate(@Nonnull Project entity) throws HibernateException {
107106
entity.setModified(new Date());
108107
return super.saveOrUpdate(entity);
109108
}
110-
109+
111110
/**
112111
* Deep lookup of full project, initiate eager loading when needed.
113-
*
114-
* @param id
115-
* the primary key
112+
*
113+
* @param id the primary key
116114
* @return the entity or null
117115
*/
118116
@Nullable
119117
public Project findByIdEager(@Nonnull Integer id) {
120-
Project project = null;
121-
try {
122-
begin();
123-
project = getEntityManager().find(Project.class, id);
124-
Hibernate.initialize(project.getWorkloads().get(0).getJobConfiguration());
125-
Hibernate.initialize(project.getWorkloads().get(0).getTestPlans());
126-
commit();
118+
Project project = null;
119+
try {
120+
begin();
121+
project = getEntityManager().find(Project.class, id);
122+
Hibernate.initialize(project.getWorkloads().get(0).getJobConfiguration());
123+
Hibernate.initialize(project.getWorkloads().get(0).getTestPlans());
124+
commit();
127125
} catch (Exception e) {
128-
rollback();
126+
rollback();
129127
LOG.info("No entities for Project id " + id);
130-
} finally {
131-
cleanup();
132-
}
133-
return project;
128+
} finally {
129+
cleanup();
130+
}
131+
return project;
134132
}
135133

136134
/**
137135
* Override BaseDao to deep lookup finaAll Projects
138136
* This is very slow, thousands of queries, don't use this.
139-
*
137+
*
140138
* @return the nonnull list of entities
141-
* @throws HibernateException
142-
* if there is an error in persistence
139+
* @throws HibernateException if there is an error in persistence
143140
*/
144141
@Nonnull
145142
@Override
146143
public List<Project> findAll() throws HibernateException {
147-
List<Project> results = Collections.emptyList();
148-
EntityManager em = getEntityManager();
149-
try {
150-
begin();
151-
CriteriaBuilder cb = em.getCriteriaBuilder();
152-
CriteriaQuery<Project> query = cb.createQuery(Project.class);
153-
Root<Project> root = query.from(Project.class);
154-
Fetch<Project, Workload> wl = root.fetch(Project.PROPERTY_WORKLOADS);
155-
wl.fetch(Workload.PROPERTY_JOB_CONFIGURATION);
156-
query.select(root);
157-
results = em.createQuery(query).getResultList();
158-
commit();
144+
List<Project> results = Collections.emptyList();
145+
EntityManager em = getEntityManager();
146+
try {
147+
begin();
148+
CriteriaBuilder cb = em.getCriteriaBuilder();
149+
CriteriaQuery<Project> query = cb.createQuery(Project.class);
150+
Root<Project> root = query.from(Project.class);
151+
Fetch<Project, Workload> wl = root.fetch(Project.PROPERTY_WORKLOADS);
152+
wl.fetch(Workload.PROPERTY_JOB_CONFIGURATION);
153+
query.select(root);
154+
results = em.createQuery(query).getResultList();
155+
commit();
159156
} catch (Exception e) {
160-
rollback();
157+
rollback();
161158
e.printStackTrace();
162159
LOG.info("No entities found at all for Project");
163-
} finally {
164-
cleanup();
165-
}
166-
return results;
160+
} finally {
161+
cleanup();
162+
}
163+
return results;
167164
}
168165

169166
/**
170167
* Shallow find of all Projects, used for debugger request.
171168
*
172169
* @return the nonnull list of entities
173-
* @throws HibernateException
174-
* if there is an error in persistence
170+
* @throws HibernateException if there is an error in persistence
175171
*/
176172
@Nonnull
177173
public List<Project> findAllFast() throws HibernateException {
@@ -194,11 +190,11 @@ public List<Project> findAllFast() throws HibernateException {
194190
}
195191
return results;
196192
}
197-
193+
198194
@Nullable
199195
public Project loadScripts(Integer ProjectId) {
200-
Project project = findByIdEager(ProjectId);
201-
if (project != null) {
196+
Project project = findByIdEager(ProjectId);
197+
if (project != null) {
202198
ScriptDao dao = new ScriptDao();
203199
for (TestPlan testPlan : project.getWorkloads().get(0).getTestPlans()) {
204200
for (ScriptGroup scriptGroup : testPlan.getScriptGroups()) {

pom.xml

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<version.primefaces-ext>14.0.15</version.primefaces-ext>
4545
<version.jsr166>1.7.0</version.jsr166>
4646
<version.surefire>3.5.3</version.surefire>
47+
<version.jacoco>0.8.11</version.jacoco>
4748
<version.junit>5.12.2</version.junit>
4849
<version.mockito>5.14.2</version.mockito>
4950
<version.httpclient>4.5.14</version.httpclient>
@@ -114,12 +115,14 @@
114115
<plugin>
115116
<groupId>org.jacoco</groupId>
116117
<artifactId>jacoco-maven-plugin</artifactId>
118+
<version>${version.jacoco}</version>
117119
<configuration>
118120
<excludes>
119121
<exclude>org/fife/**/*</exclude>
120122
</excludes>
121123
</configuration>
122124
<executions>
125+
<!-- Unit test coverage -->
123126
<execution>
124127
<id>default-prepare-agent</id>
125128
<goals>
@@ -133,6 +136,8 @@
133136
<goal>report</goal>
134137
</goals>
135138
</execution>
139+
140+
<!-- Check rules -->
136141
<execution>
137142
<id>default-check</id>
138143
<goals>
@@ -855,6 +860,28 @@
855860
<groupId>org.apache.maven.plugins</groupId>
856861
<artifactId>maven-surefire-report-plugin</artifactId>
857862
<version>${version.surefire}</version>
863+
<executions>
864+
<execution>
865+
<id>unit-test-report</id>
866+
<phase>verify</phase>
867+
<goals>
868+
<goal>report</goal>
869+
</goals>
870+
<configuration>
871+
<outputName>unit-test-report</outputName>
872+
</configuration>
873+
</execution>
874+
<execution>
875+
<id>integration-test-report</id>
876+
<phase>verify</phase>
877+
<goals>
878+
<goal>report</goal>
879+
</goals>
880+
<configuration>
881+
<outputName>integration-test-report</outputName>
882+
</configuration>
883+
</execution>
884+
</executions>
858885
</plugin>
859886

860887
<plugin>
@@ -1013,6 +1040,7 @@
10131040
<path>
10141041
<groupId>org.projectlombok</groupId>
10151042
<artifactId>lombok</artifactId>
1043+
<version>1.18.38</version>
10161044
</path>
10171045
</annotationProcessorPaths>
10181046
</configuration>
@@ -1048,23 +1076,49 @@
10481076
<groupId>org.apache.maven.plugins</groupId>
10491077
<artifactId>maven-project-info-reports-plugin</artifactId>
10501078
</plugin>
1079+
1080+
<!-- Unit Tests Configuration -->
10511081
<plugin>
10521082
<groupId>org.apache.maven.plugins</groupId>
10531083
<artifactId>maven-surefire-plugin</artifactId>
1084+
<version>${version.surefire}</version>
10541085
<configuration>
10551086
<!-- Sets the VM argument line used when unit tests are run. -->
10561087
<argLine>${argLine}</argLine>
1057-
<excludedGroups>manual,integration,experimental</excludedGroups>
10581088
<includes>
10591089
<include>**/*Test.java</include>
10601090
<include>**/*Spec.groovy</include>
10611091
</includes>
1092+
<excludes>
1093+
<exclude>**/*IT.java</exclude>
1094+
<exclude>**/integration/**/*.java</exclude>
1095+
</excludes>
1096+
<excludedGroups>manual,integration,experimental</excludedGroups>
1097+
</configuration>
1098+
</plugin>
1099+
<!-- Integration Tests Configuration -->
1100+
<plugin>
1101+
<groupId>org.apache.maven.plugins</groupId>
1102+
<artifactId>maven-failsafe-plugin</artifactId>
1103+
<version>${version.surefire}</version>
1104+
<executions>
1105+
<execution>
1106+
<goals>
1107+
<goal>integration-test</goal>
1108+
<goal>verify</goal>
1109+
</goals>
1110+
</execution>
1111+
</executions>
1112+
<configuration>
1113+
<includes>
1114+
<include>**/*IT.java</include>
1115+
<include>**/integration/**/*.java</include>
1116+
</includes>
10621117
</configuration>
10631118
</plugin>
10641119
</plugins>
10651120
</build>
10661121

1067-
10681122
<reporting>
10691123
<outputDirectory>${project.build.directory}/site</outputDirectory>
10701124
<plugins>

readme.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ There are several profiles (for the initial build you should build the release p
2929
* coverage -- runs jacoco code coverage.
3030
* static-analysis -- runs checkstyle and findbugs.
3131

32+
`mvn clean install` runs all unit tests and integration tests by default under their respective maven stages - `test` and `verify`.
3233

3334
There are several artifacts that are important.
3435
* web/web_ui/target/tank.war -- the main deployment file. Intended for deployment to a tomcat web server.
3536
* agent/agentManager_pkg/target/agent-startup-pkg.zip -- the agent app that gets started when the agent starts and manages communicating with the tank controller and coordinating the tests.
3637
* tools/agent_debugger_pkg/target/Tank-Debugger-all.jar -- the visual debugger jar. can be launched to debug scripts or projects.
3738
* tools/script_filter_pkg/target/Tank-Script-Runner-all.jar -- the visual script filter tool for writing scripts to filter or manipulate scripts on import.
38-
* proxy-parent/proxy_pkg/target/Tank-Proxy-pkg.jar -- the proxy recording tool. A Tool to record scripts using your browser.
39+
* proxy-parent/proxy_pkg/target/Tank-Proxy-pkg.jar -- the proxy recording tool. A Tool to record scripts using your browser.
3940

4041
## Quickstart
4142
There is a shell script to install and configure a standalone controller and agent and configured with a java database for
@@ -44,6 +45,11 @@ It can be downloaded from our [public site](http://tank-public.s3-website-us-eas
4445
in the root of the distribution. You can use this version for small tests to try out the tools but should not use
4546
it for large scale or production testing.
4647

48+
## Integration Tests
49+
50+
The integration tests are located in the `test_support` module. They are designed to test the REST API endpoints against the QA Tank environment.
51+
You can find more information in the [README](test_support/README.md) file in that module.
52+
4753
## Guides
4854
Installation guide and User guide can be found in the docs folder and are built with the source. and can also be found on our [wiki](https://github.com/intuit/Tank/wiki).
4955

test_support/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target
2+
/src/test/resources/test-config.properties

0 commit comments

Comments
 (0)