Skip to content

Commit d1827fc

Browse files
authored
Merge pull request #136 from splunk/ci/java-versions
Update CI Java versions
2 parents 6f543e5 + a2479ce commit d1827fc

File tree

5 files changed

+55
-23
lines changed

5 files changed

+55
-23
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
notifications:
23
email: false
34

@@ -10,7 +11,7 @@ before_install:
1011
# Create .splunkrc file with default credentials
1112
- echo host=localhost >> $HOME/.splunkrc
1213
- echo username=admin >> $HOME/.splunkrc
13-
- echo password=changeme >> $HOME/.splunkrc
14+
- echo password=changed! >> $HOME/.splunkrc
1415
# Set env vars for TCP/UDP tests (we've punched these through Docker)
1516
- export TEST_TCP_PORT=10667
1617
- export TEST_UDP_PORT=10668
@@ -39,8 +40,8 @@ addons:
3940
- ant-optional
4041

4142
jdk:
42-
- oraclejdk8
43-
- openjdk7
43+
- openjdk8
44+
- openjdk11
4445

4546
before_script:
4647
- ant

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Here's what you need to get going with the Splunk SDK for Java.
4040
If you haven't already installed Splunk, download it
4141
[here](http://www.splunk.com/download). For more about installing and running
4242
Splunk and system requirements, see
43-
[Installing & Running Splunk](http://dev.splunk.com/view/SP-CAAADRV). The Splunk SDK for Java has been tested with Splunk Enterprise 6.6 and 7.0.
43+
[Installing & Running Splunk](http://dev.splunk.com/view/SP-CAAADRV). The Splunk SDK for Java has been tested with Splunk Enterprise 7.0 and 7.2.
4444

4545
#### Splunk SDK for Java
4646

@@ -51,7 +51,7 @@ If you want to contribute to the SDK, clone the repository from [GitHub](https:/
5151

5252
#### Java and Ant
5353

54-
You'll need Java version 7 or higher, from [OpenJDK](https://openjdk.java.net) or [Oracle](https://www.oracle.com/technetwork/java). The Splunk SDK for Java has been tested with OpenJDK v7 and v8, and Oracle JDK v7 and v8.
54+
You'll need Java version 8 or higher, from [OpenJDK](https://openjdk.java.net) or [Oracle](https://www.oracle.com/technetwork/java). The Splunk SDK for Java has been tested with OpenJDK v8 and v11.
5555

5656
You'll also need Ant, which you can install from the
5757
[Apache website](http://ant.apache.org/bindownload.cgi).
@@ -100,7 +100,7 @@ To add the Splunk SDK for Java `.JAR` file as a dependency:
100100
<dependency>
101101
<groupId>com.splunk</groupId>
102102
<artifactId>splunk</artifactId>
103-
<version>1.6.3.0</version>
103+
<version>1.6.4.0</version>
104104
</dependency>
105105
</dependencies>
106106
```

tests/com/splunk/IndexTest.java

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,24 @@ public boolean predicate() {
5353
public void tearDown() throws Exception {
5454
if (service.versionIsAtLeast("5.0.0")) {
5555
if (service.getIndexes().containsKey(indexName) && System.getenv("TRAVIS") == null) {
56-
index.remove();
56+
try {
57+
index.remove();
58+
} catch(HttpException he) {
59+
if (he.getStatus() == 400) {
60+
uncheckedSplunkRestart();
61+
index.remove();
62+
} else {
63+
throw he;
64+
}
65+
}
5766
}
5867
} else {
5968
// Can't delete indexes via the REST API. Just let them build up.
6069
}
6170

71+
// At least in CI the test exists with a required restart
72+
uncheckedSplunkRestart();
73+
6274
super.tearDown();
6375
}
6476

@@ -132,7 +144,16 @@ public void testDeletion() {
132144

133145
Assert.assertTrue(service.getIndexes().containsKey(indexName));
134146

135-
index.remove();
147+
try {
148+
index.remove();
149+
} catch(HttpException he) {
150+
if (he.getStatus() == 400) {
151+
uncheckedSplunkRestart();
152+
index.remove();
153+
} else {
154+
throw he;
155+
}
156+
}
136157
assertEventuallyTrue(new EventuallyTrueBehavior() {
137158
@Override
138159
public boolean predicate() {
@@ -149,7 +170,17 @@ public void testDeletionFromCollection() {
149170
}
150171

151172
Assert.assertTrue(service.getIndexes().containsKey(indexName));
152-
service.getIndexes().remove(indexName);
173+
174+
try {
175+
service.getIndexes().remove(indexName);
176+
} catch(HttpException he) {
177+
if (he.getStatus() == 400) {
178+
uncheckedSplunkRestart();
179+
service.getIndexes().remove(indexName);
180+
} else {
181+
throw he;
182+
}
183+
}
153184

154185
assertEventuallyTrue(new EventuallyTrueBehavior() {
155186
@Override

tests/com/splunk/SDKTestCase.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,16 @@ public void connect() {
7979
}
8080

8181
public static Integer getJavaVersion() {
82-
String ver = System.getProperty("java.version");
83-
return Integer.parseInt(ver.substring(2, 3));
82+
String version = System.getProperty("java.version");
83+
if (version.startsWith("1.")) {
84+
version = version.substring(2, 3);
85+
} else {
86+
int dot = version.indexOf(".");
87+
if (dot != -1) {
88+
version = version.substring(0, dot);
89+
}
90+
}
91+
return Integer.parseInt(version);
8492
}
8593

8694
@Before

tests/com/splunk/UploadTest.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,12 @@
2525

2626
public class UploadTest extends SDKTestCase {
2727
@Test
28-
public void testOneshot() throws IOException {
28+
public void testOneshot() {
2929
String filename = locateSystemLog();
30-
if (System.getenv("TRAVIS_CI") != null) {
31-
File tempfile = File.createTempFile((new Date()).toString(), "");
32-
tempfile.deleteOnExit();
33-
34-
FileWriter f = new FileWriter(tempfile, true);
35-
f.append("some data here");
36-
37-
filename = tempfile.getAbsolutePath();
38-
}
39-
else if (System.getenv("SPLUNK_HOME") != null) {
40-
filename = System.getenv("SPLUNK_HOME") + "/var/log/splunk/splunkd.log";
30+
if (System.getenv("SPLUNK_HOME") != null) {
31+
filename = System.getenv("SPLUNK_HOME") + "/copyright.txt";
4132
}
33+
4234
service.getUploads().create(filename);
4335

4436
for (Upload oneshot : service.getUploads().values()) {

0 commit comments

Comments
 (0)