Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

notifications:
email: false

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

jdk:
- oraclejdk8
- openjdk7
- openjdk8
- openjdk11

before_script:
- ant
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Here's what you need to get going with the Splunk SDK for Java.
If you haven't already installed Splunk, download it
[here](http://www.splunk.com/download). For more about installing and running
Splunk and system requirements, see
[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.
[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.

#### Splunk SDK for Java

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

#### Java and Ant

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.
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.

You'll also need Ant, which you can install from the
[Apache website](http://ant.apache.org/bindownload.cgi).
Expand Down Expand Up @@ -100,7 +100,7 @@ To add the Splunk SDK for Java `.JAR` file as a dependency:
<dependency>
<groupId>com.splunk</groupId>
<artifactId>splunk</artifactId>
<version>1.6.3.0</version>
<version>1.6.4.0</version>
</dependency>
</dependencies>
```
Expand Down
37 changes: 34 additions & 3 deletions tests/com/splunk/IndexTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,24 @@ public boolean predicate() {
public void tearDown() throws Exception {
if (service.versionIsAtLeast("5.0.0")) {
if (service.getIndexes().containsKey(indexName) && System.getenv("TRAVIS") == null) {
index.remove();
try {
index.remove();
} catch(HttpException he) {
if (he.getStatus() == 400) {
uncheckedSplunkRestart();
index.remove();
} else {
throw he;
}
}
}
} else {
// Can't delete indexes via the REST API. Just let them build up.
}

// At least in CI the test exists with a required restart
uncheckedSplunkRestart();

super.tearDown();
}

Expand Down Expand Up @@ -132,7 +144,16 @@ public void testDeletion() {

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

index.remove();
try {
index.remove();
} catch(HttpException he) {
if (he.getStatus() == 400) {
uncheckedSplunkRestart();
index.remove();
} else {
throw he;
}
}
assertEventuallyTrue(new EventuallyTrueBehavior() {
@Override
public boolean predicate() {
Expand All @@ -149,7 +170,17 @@ public void testDeletionFromCollection() {
}

Assert.assertTrue(service.getIndexes().containsKey(indexName));
service.getIndexes().remove(indexName);

try {
service.getIndexes().remove(indexName);
} catch(HttpException he) {
if (he.getStatus() == 400) {
uncheckedSplunkRestart();
service.getIndexes().remove(indexName);
} else {
throw he;
}
}

assertEventuallyTrue(new EventuallyTrueBehavior() {
@Override
Expand Down
12 changes: 10 additions & 2 deletions tests/com/splunk/SDKTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,16 @@ public void connect() {
}

public static Integer getJavaVersion() {
String ver = System.getProperty("java.version");
return Integer.parseInt(ver.substring(2, 3));
String version = System.getProperty("java.version");
if (version.startsWith("1.")) {
version = version.substring(2, 3);
} else {
int dot = version.indexOf(".");
if (dot != -1) {
version = version.substring(0, dot);
}
}
return Integer.parseInt(version);
}

@Before
Expand Down
16 changes: 4 additions & 12 deletions tests/com/splunk/UploadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,12 @@

public class UploadTest extends SDKTestCase {
@Test
public void testOneshot() throws IOException {
public void testOneshot() {
String filename = locateSystemLog();
if (System.getenv("TRAVIS_CI") != null) {
File tempfile = File.createTempFile((new Date()).toString(), "");
tempfile.deleteOnExit();

FileWriter f = new FileWriter(tempfile, true);
f.append("some data here");

filename = tempfile.getAbsolutePath();
}
else if (System.getenv("SPLUNK_HOME") != null) {
filename = System.getenv("SPLUNK_HOME") + "/var/log/splunk/splunkd.log";
if (System.getenv("SPLUNK_HOME") != null) {
filename = System.getenv("SPLUNK_HOME") + "/copyright.txt";
}

service.getUploads().create(filename);

for (Upload oneshot : service.getUploads().values()) {
Expand Down