forked from tada/pljava
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
280 lines (239 loc) · 8.02 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
language: minimal
os:
- linux
arch:
- amd64
- ppc64le
dist: bionic
env:
- POSTGRESQL_VERSION: 12
JAVA_VERSION: 14
JVM_IMPL: hotspot
MVN_VERSION: 3.5.2
- POSTGRESQL_VERSION: 12
JAVA_VERSION: 14
JVM_IMPL: openj9
MVN_VERSION: 3.6.3
- POSTGRESQL_VERSION: 12
JAVA_VERSION: 11
JVM_IMPL: hotspot
MVN_VERSION: 3.6.3
- POSTGRESQL_VERSION: 12
JAVA_VERSION: 9
JVM_IMPL: hotspot
MVN_VERSION: 3.6.3
- POSTGRESQL_VERSION: 10
JAVA_VERSION: 14
JVM_IMPL: hotspot
MVN_VERSION: 3.6.3
- POSTGRESQL_VERSION: 9.5
JAVA_VERSION: 14
JVM_IMPL: hotspot
MVN_VERSION: 3.6.3
jobs:
exclude:
- arch: ppc64le
env:
POSTGRESQL_VERSION: 12
JAVA_VERSION: 9
JVM_IMPL: hotspot
MVN_VERSION: 3.6.3
include:
- os: osx
osx_image: xcode11
arch: amd64
env:
- POSTGRESQL_VERSION: 11
JAVA_VERSION: 14
JVM_IMPL: hotspot
MVN_VERSION: 3.6.3
- os: osx
osx_image: xcode11
arch: amd64
env:
- POSTGRESQL_VERSION: 10
JAVA_VERSION: 14
JVM_IMPL: hotspot
MVN_VERSION: 3.6.3
- os: osx
osx_image: xcode11
arch: amd64
env:
- POSTGRESQL_VERSION: 9.5
JAVA_VERSION: 14
JVM_IMPL: hotspot
MVN_VERSION: 3.6.3
cache:
directories:
- $HOME/.m2
before_install: |
javaUrl=https://api.adoptopenjdk.net/v3/binary/latest
javaUrl="$javaUrl/$JAVA_VERSION/ga/${TRAVIS_OS_NAME//osx/mac}"
javaUrl="$javaUrl/${TRAVIS_CPU_ARCH//amd64/x64}/jdk"
javaUrl="$javaUrl/$JVM_IMPL/normal/adoptopenjdk"
installJdk=$(false && which install-jdk.sh) || {
wget https://raw.githubusercontent.com/sormuras/bach/8c457fd6e46bd9f3f575867dd0c9af1d7edfd5b4/install-jdk.sh
installJdk=./install-jdk.sh
printf '%s\n%s\n%s\n%s\n%s\n' \
'--- install-jdk.sh' \
'+++ install-jdk.sh' \
'@@ -257 +257 @@' \
'- target="${workspace}"/$(tar --list ${tar_options} | head -2 | tail -1 | cut -f 2 -d '"'/' -)/Contents/Home" \
'+ target="${workspace}"/$(tar --list ${tar_options} | sed -n '"'/\/bin\/javac/s///p')" \
| patch "$installJdk"
}
[[ $JAVA_VERSION == 9 ]] && certs=--cacerts || unset certs
. "$installJdk" --url "$javaUrl" ${certs+"$certs"}
mvnUrl=https://archive.apache.org/dist/maven/maven-3
mvnUrl="$mvnUrl/$MVN_VERSION/binaries/apache-maven-$MVN_VERSION-bin.tar.gz"
wget --no-verbose "$mvnUrl" && tar xzf "apache-maven-$MVN_VERSION-bin.tar.gz"
mvn="./apache-maven-$MVN_VERSION/bin/mvn"
"$mvn" --version
. .travis/travis_install_postgresql.sh
install: |
"$pgConfig"
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
libjvm_name="libjli.dylib"
else
libjvm_name="libjvm.so"
fi
libjvm=$(find "$JAVA_HOME" -mindepth 2 -name $libjvm_name | head -n 1)
"$mvn" clean install --batch-mode \
-Dpgsql.pgconfig="$pgConfig" \
-Dpljava.libjvmdefault="$libjvm" \
-Psaxon-examples -Ppgjdbc-ng \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
script: |
packageJar=$(find pljava-packaging -name pljava-pg*.jar -print)
mavenRepo="$HOME/.m2/repository"
saxonVer=$(
find "$mavenRepo/net/sf/saxon/Saxon-HE" -name 'Saxon-HE-*.jar' -print |
sort |
tail -n 1
)
saxonVer=${saxonVer%/*}
saxonVer=${saxonVer##*/}
jdbcJar=$(
find "$mavenRepo/com/impossibl/pgjdbc-ng/pgjdbc-ng-all" \
-name 'pgjdbc-ng-all-*.jar' -print |
sort |
tail -n 1
)
sudo "$JAVA_HOME"/bin/java -Dpgconfig="$pgConfig" -jar "$packageJar"
"$JAVA_HOME"/bin/jshell \
-execution local \
"-J--class-path=$packageJar:$jdbcJar" \
"--class-path=$packageJar" \
"-J--add-modules=java.sql.rowset" \
"-J-Dpgconfig=$pgConfig" \
"-J-Dcom.impossibl.shadow.io.netty.noUnsafe=true" \
"-J-DmavenRepo=$mavenRepo" \
"-J-DsaxonVer=$saxonVer" - <<\ENDJSHELL && # continues after here document
boolean succeeding = false; // begin pessimistic
import static java.nio.file.Paths.get
import java.sql.Connection
import org.postgresql.pljava.packaging.Node
import static org.postgresql.pljava.packaging.Node.q
import static org.postgresql.pljava.packaging.Node.stateMachine
import static org.postgresql.pljava.packaging.Node.isVoidResultSet
String vmopts = "-enableassertions:org.postgresql.pljava... -Xcheck:jni"
Node n1 = Node.get_new_node("TestNode1")
/*
* Keep a tally of the three types of diagnostic notices that may be received,
* and, independently, how many represent no-good test results (error always,
* but also warning if seen from the tests in the examples.jar deployment
* descriptor).
*/
Map<String,Integer> results =
Stream.of("info", "warning", "error", "ng").collect(
LinkedHashMap<String,Integer>::new, (m,k) -> m.put(k, 0), (r,s) -> {})
boolean isDiagnostic(Object o, Set<String> whatIsNG)
{
if ( ! ( o instanceof Throwable ) )
return false;
String[] parts = Node.classify((Throwable)o);
String type = parts[0];
results.compute(type, (k,v) -> 1 + v);
if ( whatIsNG.contains(type) )
results.compute("ng", (k,v) -> 1 + v);
return true;
}
try (
AutoCloseable t1 = n1.initialized_cluster();
AutoCloseable t2 = n1.started_server(Map.of(
"client_min_messages", "info",
"pljava.vmoptions", vmopts
));
)
{
try ( Connection c = n1.connect() )
{
succeeding = true; // become optimistic, will be using &= below
succeeding &= stateMachine(
"create extension no result",
null,
q(c, "create extension pljava")
.flatMap(Node::semiFlattenDiagnostics)
.peek(Node::peek),
// state 1: consume any diagnostics, or go to state 2 without consuming
(o,p,q) -> isDiagnostic(o, Set.of("error")) ? 1 : -2,
// state 2: must be end of input
(o,p,q) -> null == o
);
}
/*
* Get a new connection; 'create extension' always sets a near-silent
* logging level, and PL/Java only checks once at VM start time, so in
* the same session where 'create extension' was done, logging is
* somewhat suppressed.
*/
try ( Connection c = n1.connect() )
{
succeeding &= stateMachine(
"saxon path examples path",
null,
Node.installSaxonAndExamplesAndPath(c,
System.getProperty("mavenRepo"),
System.getProperty("saxonVer"),
true)
.flatMap(Node::semiFlattenDiagnostics)
.peek(Node::peek),
// states 1,2: maybe diagnostics, then a void result set (saxon install)
(o,p,q) -> isDiagnostic(o, Set.of("error")) ? 1 : -2,
(o,p,q) -> isVoidResultSet(o, 1, 1) ? 3 : false,
// states 3,4: maybe diagnostics, then a void result set (set classpath)
(o,p,q) -> isDiagnostic(o, Set.of("error")) ? 3 : -4,
(o,p,q) -> isVoidResultSet(o, 1, 1) ? 5 : false,
// states 5,6: maybe diagnostics, then void result set (example install)
(o,p,q) -> isDiagnostic(o, Set.of("error", "warning")) ? 5 : -6,
(o,p,q) -> isVoidResultSet(o, 1, 1) ? 7 : false,
// states 7,8: maybe diagnostics, then a void result set (set classpath)
(o,p,q) -> isDiagnostic(o, Set.of("error")) ? 7 : -8,
(o,p,q) -> isVoidResultSet(o, 1, 1) ? 9 : false,
// state 9: must be end of input
(o,p,q) -> null == o
);
/*
* Also confirm that the generated undeploy actions work.
*/
succeeding &= stateMachine(
"remove jar void result",
null,
q(c, "SELECT sqlj.remove_jar('examples', true)")
.flatMap(Node::semiFlattenDiagnostics)
.peek(Node::peek),
(o,p,q) -> isDiagnostic(o, Set.of("error")) ? 1 : -2,
(o,p,q) -> isVoidResultSet(o, 1, 1) ? 3 : false,
(o,p,q) -> null == o
);
}
} catch ( Throwable t )
{
succeeding = false;
throw t;
}
System.out.println(results);
succeeding &= (0 == results.get("ng"));
System.exit(succeeding ? 0 : 1)
ENDJSHELL
: travis wants something after the end of the here document