Skip to content

Commit

Permalink
Merge a4bfb51 into ddb4607
Browse files Browse the repository at this point in the history
  • Loading branch information
julienbourdeau committed Aug 1, 2018
2 parents ddb4607 + a4bfb51 commit 126ebe7
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 14 deletions.
23 changes: 23 additions & 0 deletions .run-travis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -e

if [[ "${JAVA_VERSION}" = "8" ]]; then
if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [[ ! "$TRAVIS_PULL_REQUEST_SLUG" =~ ^algolia\/ ]]; then
eval $(./algolia-keys export) && mvn clean test jacoco:report jacoco:report-aggregate -B && mvn -pl algoliasearch-tests coveralls:report -B;
exit $?
else
mvn clean test jacoco:report jacoco:report-aggregate -B && mvn -pl algoliasearch-tests coveralls:report -B;
exit $?
fi
fi

if [[ "${JAVA_VERSION}" = "9" ]]; then
if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [[ ! "$TRAVIS_PULL_REQUEST_SLUG" =~ ^algolia\/ ]]; then
eval $(./algolia-keys export) && mvn clean test;
exit $?
else
mvn clean test;
exit $?
fi
fi
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ cache:

#check coverage
before_script:
- "mvn com.coveo:fmt-maven-plugin:check"
- "mvn com.coveo:fmt-maven-plugin:check"
- wget https://alg.li/algolia-keys && chmod +x algolia-keys

script:
- if [[ "${JAVA_VERSION}" = "8" ]]; then mvn clean test jacoco:report jacoco:report-aggregate -B && mvn -pl algoliasearch-tests coveralls:report -B; fi
#Disable coverage for java9
- if [[ "${JAVA_VERSION}" = "9" ]]; then mvn clean test; fi
- ./.run-travis.sh

#deploy snapshots
after_success:
- "mvn clean deploy -DskipTests --settings settings-for-travis.xml"
- "mvn clean deploy -DskipTests --settings settings-for-travis.xml"
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

public class ApacheHttpClientTest {

private static String APPLICATION_ID = System.getenv("APPLICATION_ID");
private static String API_KEY = System.getenv("API_KEY");
private static String APPLICATION_ID = System.getenv("ALGOLIA_APPLICATION_ID");
private static String API_KEY = System.getenv("ALGOLIA_API_KEY");
private APIClientConfiguration defaultConfig;

@Before
public void checkEnvVariables() throws Exception {
if (APPLICATION_ID == null || APPLICATION_ID.isEmpty()) {
throw new Exception("APPLICATION_ID is not defined or empty");
throw new Exception("ALGOLIA_APPLICATION_ID is not defined or empty");
}
if (API_KEY == null || API_KEY.isEmpty()) {
throw new Exception("API_KEY is not defined or empty");
throw new Exception("ALGOLIA_API_KEY is not defined or empty");
}
}

Expand Down Expand Up @@ -129,6 +129,6 @@ public void shouldHandleConnectionResetException() throws Exception {
@Test
public void shouldHandleSNI() throws Exception {
APIClient client = build(APPLICATION_ID + "-1.algolianet.com");
assertThat(client.listApiKeys()).isNotEmpty();
assertThat(client.listIndexes()).isNotEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public abstract class AsyncAlgoliaIntegrationTest {

protected static final long WAIT_TIME_IN_SECONDS = 60 * 5; // 5 minutes
protected static AsyncAPIClient client;
private String APPLICATION_ID = System.getenv("APPLICATION_ID");
private String API_KEY = System.getenv("API_KEY");
private String APPLICATION_ID = System.getenv("ALGOLIA_APPLICATION_ID");
private String API_KEY = System.getenv("ALGOLIA_API_KEY");

private static List<String> indexNameToDeleteAfterTheTests = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public abstract class SyncAlgoliaIntegrationTest {

protected static APIClient client;
private static List<String> indexNameToDeleteAfterTheTests = new ArrayList<>();
protected String APPLICATION_ID = System.getenv("APPLICATION_ID");
protected String API_KEY = System.getenv("API_KEY");
protected String APPLICATION_ID = System.getenv("ALGOLIA_APPLICATION_ID");
protected String API_KEY = System.getenv("ALGOLIA_API_KEY");
protected static final long WAIT_TIME_IN_SECONDS = 60 * 5; // 5 minutes

@AfterClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assume.assumeTrue;

import com.algolia.search.AlgoliaObject;
import com.algolia.search.AsyncAlgoliaIntegrationTest;
Expand All @@ -11,10 +12,23 @@
import java.util.List;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
import org.junit.Before;
import org.junit.Test;

public abstract class AsyncApiKeysTest extends AsyncAlgoliaIntegrationTest {

/**
* If the tests are run on Travis from a pull request of a contributor we need to bypass key
* management tests since they require the Admin API key
*/
@Before
public void skipIfIsCommunity() {
String isCommunity = System.getenv("IS_COMMUNITY");
if (isCommunity != null && !isCommunity.isEmpty()) {
assumeTrue(false);
}
}

private void waitForKeyPresent(AsyncIndex<AlgoliaObject> index, @Nonnull String description)
throws Exception {
for (int i = 0; i < 100; i++) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.algolia.search.integration.common.sync;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assume.assumeTrue;

import com.algolia.search.AlgoliaObject;
import com.algolia.search.Index;
Expand All @@ -9,11 +10,24 @@
import com.algolia.search.objects.ApiKey;
import java.util.Collections;
import java.util.List;
import org.junit.Before;
import org.junit.Test;

@SuppressWarnings("ConstantConditions")
public abstract class SyncApiKeysTest extends SyncAlgoliaIntegrationTest {

/**
* If the tests are run on Travis from a pull request of a contributor we need to bypass key
* management tests since they require the Admin API key
*/
@Before
public void skipIfIsCommunity() {
String isCommunity = System.getenv("IS_COMMUNITY");
if (isCommunity != null && !isCommunity.isEmpty()) {
assumeTrue(false);
}
}

private void waitForKeyPresent(Index<AlgoliaObject> index, String description)
throws AlgoliaException, InterruptedException {
for (int i = 0; i < 100; i++) {
Expand Down

0 comments on commit 126ebe7

Please sign in to comment.