Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit ed09cb8

Browse files
pervazeaapavlo
authored andcommitted
Integrate junit tests into Travis and Jenkins (#1278)
* Integrate junit tests into Travis and Jenkins * Add ant (for junit tests) * Fix .travis.yml, remove tabs * More JUnit fixes - Split prepared statement insert tests and non-prepared insert tests - Add a test for inserting with fewer items than column spec - switch to testconsole rather then ant junit runner * Disable test_2Tuple_NCS_2 until #1063 is merged * Update readme, remove (obsolete) Makefile, switch to ant junitrunner
1 parent 93743bf commit ed09cb8

File tree

9 files changed

+425
-161
lines changed

9 files changed

+425
-161
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ matrix:
9393
- bash ../script/testing/psql/psql_test.sh
9494
# run jdbc tests
9595
- python ../script/validators/jdbc_validator.py
96+
# run junit tests
97+
- python ../script/testing/junit/run_junit.py
9698
# upload coverage info
9799
- make coveralls
98100

@@ -134,6 +136,8 @@ matrix:
134136
- bash ../script/testing/psql/psql_test.sh
135137
# run jdbc tests
136138
- python ../script/validators/jdbc_validator.py
139+
# run junit tests
140+
- python ../script/testing/junit/run_junit.py
137141

138142
install:
139143
# setup environment

Jenkinsfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pipeline {
2323
sh 'cd build && bash ../script/testing/psql/psql_test.sh'
2424
sh 'sudo apt-get -qq update && sudo apt-get -qq -y --no-install-recommends install wget default-jdk default-jre' // prerequisites for jdbc_validator
2525
sh 'cd build && python ../script/validators/jdbc_validator.py'
26+
sh 'cd build && python ../script/testing/junit/run_junit.py'
2627
}
2728
}
2829

@@ -38,6 +39,7 @@ pipeline {
3839
sh 'cd build && bash ../script/testing/psql/psql_test.sh'
3940
sh 'sudo apt-get -qq update && sudo apt-get -qq -y --no-install-recommends install wget default-jdk default-jre' // prerequisites for jdbc_validator
4041
sh 'cd build && python ../script/validators/jdbc_validator.py'
42+
sh 'cd build && python ../script/testing/junit/run_junit.py'
4143
}
4244
}
4345

@@ -53,6 +55,7 @@ pipeline {
5355
sh 'cd build && bash ../script/testing/psql/psql_test.sh'
5456
sh 'sudo apt-get -qq update && sudo apt-get -qq -y --no-install-recommends install wget default-jdk default-jre' // prerequisites for jdbc_validator
5557
sh 'cd build && python ../script/validators/jdbc_validator.py'
58+
sh 'cd build && python ../script/testing/junit/run_junit.py'
5659
}
5760
}
5861

@@ -68,6 +71,7 @@ pipeline {
6871
sh 'cd build && bash ../script/testing/psql/psql_test.sh'
6972
sh 'sudo apt-get -qq update && sudo apt-get -qq -y --no-install-recommends install wget default-jdk default-jre' // prerequisites for jdbc_validator
7073
sh 'cd build && python ../script/validators/jdbc_validator.py'
74+
sh 'cd build && python ../script/testing/junit/run_junit.py'
7175
}
7276
}
7377

@@ -93,6 +97,7 @@ pipeline {
9397
// sh 'cd build && bash ../script/testing/psql/psql_test.sh'
9498
// sh 'sudo apt-get -qq update && sudo apt-get -qq -y --no-install-recommends install wget default-jdk default-jre' // prerequisites for jdbc_validator
9599
// sh 'cd build && python ../script/validators/jdbc_validator.py'
100+
// sh 'cd build && python ../script/testing/junit/run_junit.py'
96101
// }
97102
// }
98103

@@ -108,6 +113,7 @@ pipeline {
108113
// sh 'cd build && bash ../script/testing/psql/psql_test.sh'
109114
// sh 'sudo apt-get -qq update && sudo apt-get -qq -y --no-install-recommends install wget default-jdk default-jre' // prerequisites for jdbc_validator
110115
// sh 'cd build && python ../script/validators/jdbc_validator.py'
116+
// sh 'cd build && python ../script/testing/junit/run_junit.py'
111117
// }
112118
// }
113119

@@ -123,6 +129,7 @@ pipeline {
123129
// sh 'cd build && bash ../script/testing/psql/psql_test.sh'
124130
// sh 'sudo dnf -q install -y wget java-devel' // prerequisites for jdbc_validator
125131
// sh 'cd build && python ../script/validators/jdbc_validator.py'
132+
// sh 'cd build && python ../script/testing/junit/run_junit.py'
126133
// }
127134
// }
128135

@@ -138,6 +145,7 @@ pipeline {
138145
// sh 'cd build && bash ../script/testing/psql/psql_test.sh'
139146
// sh 'sudo dnf -q install -y wget java-devel' // prerequisites for jdbc_validator
140147
// sh 'cd build && python ../script/validators/jdbc_validator.py'
148+
// sh 'cd build && python ../script/testing/junit/run_junit.py'
141149
// }
142150
// }
143151

@@ -153,6 +161,7 @@ pipeline {
153161
// sh 'cd build && bash ../script/testing/psql/psql_test.sh'
154162
// sh 'sudo dnf -q install -y wget java-devel' // prerequisites for jdbc_validator
155163
// sh 'cd build && python ../script/validators/jdbc_validator.py'
164+
// sh 'cd build && python ../script/testing/junit/run_junit.py'
156165
// }
157166
// }
158167

@@ -168,6 +177,7 @@ pipeline {
168177
// sh 'cd build && bash ../script/testing/psql/psql_test.sh'
169178
// sh 'sudo dnf -q install -y wget java-devel' // prerequisites for jdbc_validator
170179
// sh 'cd build && python ../script/validators/jdbc_validator.py'
180+
// sh 'cd build && python ../script/testing/junit/run_junit.py'
171181
// }
172182
// }
173183

@@ -183,6 +193,7 @@ pipeline {
183193
// sh 'cd build && bash ../script/testing/psql/psql_test.sh'
184194
// sh 'sudo yum -q install -y wget java-devel' // prerequisites for jdbc_validator
185195
// sh 'cd build && python ../script/validators/jdbc_validator.py'
196+
// sh 'cd build && python ../script/testing/junit/run_junit.py'
186197
// }
187198
// }
188199

@@ -198,6 +209,7 @@ pipeline {
198209
// sh 'cd build && bash ../script/testing/psql/psql_test.sh'
199210
// sh 'sudo yum -q install -y wget java-devel' // prerequisites for jdbc_validator
200211
// sh 'cd build && python ../script/validators/jdbc_validator.py'
212+
// sh 'cd build && python ../script/testing/junit/run_junit.py'
201213
// }
202214
// }
203215
// end gcc builds

script/installation/packages.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ if [ "$DISTRO" = "UBUNTU" ]; then
161161
libtool \
162162
make \
163163
g++ \
164+
ant \
164165
unzip
165166
# Install version of protobuf needed by C-API
166167
install_protobuf3.4.0 "ubuntu"

script/testing/junit/InsertPSTest.java

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -397,102 +397,4 @@ public void testPS_2Tuple_CS_4() throws SQLException {
397397
new int [] {11, 0, 13});
398398
assertNoMoreRows(rs);
399399
}
400-
401-
402-
/* --------------------------------------------
403-
* simple (non-prepared) insert statement tests
404-
* ---------------------------------------------
405-
*/
406-
407-
/**
408-
* 1 tuple insert, with no column specification.
409-
*/
410-
@Test
411-
public void test_1Tuple_NCS() throws SQLException {
412-
413-
String sql = "INSERT INTO tbl VALUES (1, 2, 3);";
414-
Statement stmt = conn.createStatement();
415-
stmt.execute(sql);
416-
417-
String s_sql = "SELECT * FROM tbl;";
418-
Statement s_stmt = conn.createStatement();
419-
ResultSet rs = s_stmt.executeQuery(s_sql);
420-
421-
rs.next();
422-
assertEquals(rs.getInt("c1"), 1);
423-
assertEquals(rs.getInt("c2"), 2);
424-
assertEquals(rs.getInt("c3"), 3);
425-
assertNoMoreRows(rs);
426-
}
427-
428-
/**
429-
* 1 tuple insert, with columns inserted in schema order.
430-
*/
431-
@Test
432-
public void test_1Tuple_CS_1() throws SQLException {
433-
434-
String sql = "INSERT INTO tbl (c1, c2, c3) VALUES (1, 2, 3);";
435-
Statement stmt = conn.createStatement();
436-
stmt.execute(sql);
437-
438-
String s_sql = "SELECT * FROM tbl;";
439-
Statement s_stmt = conn.createStatement();
440-
ResultSet rs = s_stmt.executeQuery(s_sql);
441-
442-
rs.next();
443-
assertEquals(rs.getInt("c1"), 1);
444-
assertEquals(rs.getInt("c2"), 2);
445-
assertEquals(rs.getInt("c3"), 3);
446-
assertNoMoreRows(rs);
447-
}
448-
449-
/**
450-
* 1 tuple insert, with columns inserted in different order from schema.
451-
*/
452-
@Test
453-
public void test_1Tuple_CS_2() throws SQLException {
454-
455-
String sql = "INSERT INTO tbl (c3, c1, c2) VALUES (3, 1, 2);";
456-
Statement stmt = conn.createStatement();
457-
stmt.execute(sql);
458-
459-
String s_sql = "SELECT * FROM tbl;";
460-
Statement s_stmt = conn.createStatement();
461-
ResultSet rs = s_stmt.executeQuery(s_sql);
462-
463-
rs.next();
464-
assertEquals(rs.getInt("c1"), 1);
465-
assertEquals(rs.getInt("c2"), 2);
466-
assertEquals(rs.getInt("c3"), 3);
467-
assertNoMoreRows(rs);
468-
}
469-
470-
/* 2 tuple (non-prepared statement) inserts */
471-
472-
/**
473-
* 2 tuple insert, with no column specification.
474-
*/
475-
@Test
476-
public void test_2Tuple_NCS() throws SQLException {
477-
478-
String sql = "INSERT INTO tbl VALUES (1, 2, 3), (11, 12, 13);";
479-
Statement stmt = conn.createStatement();
480-
stmt.execute(sql);
481-
482-
String s_sql = "SELECT * FROM tbl;";
483-
Statement s_stmt = conn.createStatement();
484-
ResultSet rs = s_stmt.executeQuery(s_sql);
485-
486-
rs.next();
487-
assertEquals(rs.getInt("c1"), 1);
488-
assertEquals(rs.getInt("c2"), 2);
489-
assertEquals(rs.getInt("c3"), 3);
490-
491-
rs.next();
492-
assertEquals(rs.getInt("c1"), 11);
493-
assertEquals(rs.getInt("c2"), 12);
494-
assertEquals(rs.getInt("c3"), 13);
495-
496-
assertNoMoreRows(rs);
497-
}
498400
}

script/testing/junit/InsertTest.java

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Peloton
4+
//
5+
// InsertTest.java
6+
//
7+
// Identification: script/testing/junit/InsertTest.java
8+
//
9+
// Copyright (c) 2015-2018, Carnegie Mellon University Database Group
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
/**
14+
* Insert statement tests.
15+
*/
16+
17+
import java.sql.*;
18+
import org.junit.*;
19+
import static org.junit.Assert.assertEquals;
20+
21+
public class InsertTest extends PLTestBase {
22+
private Connection conn;
23+
private ResultSet rs;
24+
private String s_sql = "SELECT * FROM tbl;";
25+
26+
private static final String SQL_DROP_TABLE =
27+
"DROP TABLE IF EXISTS tbl;";
28+
29+
private static final String SQL_CREATE_TABLE =
30+
"CREATE TABLE tbl (" +
31+
"c1 int NOT NULL PRIMARY KEY, " +
32+
"c2 int," +
33+
"c3 int);";
34+
35+
/**
36+
* Initialize the database and table for testing
37+
*/
38+
private void InitDatabase() throws SQLException {
39+
Statement stmt = conn.createStatement();
40+
stmt.execute(SQL_DROP_TABLE);
41+
stmt.execute(SQL_CREATE_TABLE);
42+
}
43+
44+
/**
45+
* Get columns, for follow on value checking
46+
*/
47+
private void getResults() throws SQLException {
48+
Statement stmt = conn.createStatement();
49+
rs = stmt.executeQuery(s_sql);
50+
}
51+
52+
@Before
53+
public void Setup() throws SQLException {
54+
conn = makeDefaultConnection();
55+
conn.setAutoCommit(true);
56+
InitDatabase();
57+
}
58+
59+
@After
60+
public void Teardown() throws SQLException {
61+
Statement stmt = conn.createStatement();
62+
stmt.execute(SQL_DROP_TABLE);
63+
}
64+
65+
/* --------------------------------------------
66+
* Insert statement tests
67+
* ---------------------------------------------
68+
*/
69+
70+
/**
71+
* 1 tuple insert, with no column specification.
72+
*/
73+
@Test
74+
public void test_1Tuple_NCS() throws SQLException {
75+
76+
String sql = "INSERT INTO tbl VALUES (1, 2, 3);";
77+
Statement stmt = conn.createStatement();
78+
stmt.execute(sql);
79+
80+
getResults();
81+
rs.next();
82+
checkRow(rs,
83+
new String [] {"c1", "c2", "c3"},
84+
new int [] {1, 2, 3});
85+
assertNoMoreRows(rs);
86+
}
87+
88+
/**
89+
* 1 tuple insert, with columns inserted in schema order.
90+
*/
91+
@Test
92+
public void test_1Tuple_CS_1() throws SQLException {
93+
94+
String sql = "INSERT INTO tbl (c1, c2, c3) VALUES (1, 2, 3);";
95+
Statement stmt = conn.createStatement();
96+
stmt.execute(sql);
97+
98+
getResults();
99+
rs.next();
100+
checkRow(rs,
101+
new String [] {"c1", "c2", "c3"},
102+
new int [] {1, 2, 3});
103+
assertNoMoreRows(rs);
104+
}
105+
106+
/**
107+
* 1 tuple insert, with columns inserted in different order from schema.
108+
*/
109+
@Test
110+
public void test_1Tuple_CS_2() throws SQLException {
111+
112+
String sql = "INSERT INTO tbl (c3, c1, c2) VALUES (3, 1, 2);";
113+
Statement stmt = conn.createStatement();
114+
stmt.execute(sql);
115+
116+
getResults();
117+
rs.next();
118+
checkRow(rs,
119+
new String [] {"c1", "c2", "c3"},
120+
new int [] {1, 2, 3});
121+
assertNoMoreRows(rs);
122+
}
123+
124+
/* 2 tuple inserts */
125+
126+
/**
127+
* 2 tuple insert, with no column specification.
128+
*/
129+
@Test
130+
public void test_2Tuple_NCS_1() throws SQLException {
131+
132+
String sql = "INSERT INTO tbl VALUES (1, 2, 3), (11, 12, 13);";
133+
Statement stmt = conn.createStatement();
134+
stmt.execute(sql);
135+
136+
getResults();
137+
rs.next();
138+
checkRow(rs,
139+
new String [] {"c1", "c2", "c3"},
140+
new int [] {1, 2, 3});
141+
142+
rs.next();
143+
checkRow(rs,
144+
new String [] {"c1", "c2", "c3"},
145+
new int [] {11, 12, 13});
146+
assertNoMoreRows(rs);
147+
}
148+
149+
/**
150+
* 2 tuple insert, with no column specification, with fewer than
151+
* schema columns
152+
*/
153+
//@Test
154+
public void test_2Tuple_NCS_2() throws SQLException {
155+
156+
String sql = "INSERT INTO tbl VALUES (1), (11, 12);";
157+
Statement stmt = conn.createStatement();
158+
stmt.execute(sql);
159+
160+
getResults();
161+
rs.next();
162+
checkRow(rs,
163+
new String [] {"c1", "c2", "c3"},
164+
new int [] {1, 0, 0});
165+
rs.next();
166+
checkRow(rs,
167+
new String [] {"c1", "c2", "c3"},
168+
new int [] {11, 12, 0});
169+
assertNoMoreRows(rs);
170+
}
171+
}

0 commit comments

Comments
 (0)