Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip genie client integration tests if the docker container is not successfully set up #1208

Merged
merged 2 commits into from
Apr 8, 2024
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
3 changes: 3 additions & 0 deletions .github/workflows/genie-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ jobs:
github.event_name == 'pull_request' ||
((!startsWith(github.ref, 'refs/tags/v')) && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/dev-snapshot')
run: |
./gradlew --stacktrace build codeCoverageReport coveralls
INTEGRATION_TEST_DB=mysql ./gradlew --stacktrace genie-web:integrationTest
INTEGRATION_TEST_DB=postgresql ./gradlew --stacktrace genie-web:integrationTest
./gradlew --stacktrace javadoc asciidoc dockerBuildAllImages
- name: Publish snapshot
if: |
Expand Down
10 changes: 10 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
coverage:
range: 80..100

status:
project:
default:
threshold: 2%
patch:
default:
threshold: 2%
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
import com.netflix.genie.common.dto.Command;
import com.netflix.genie.common.dto.CommandStatus;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import retrofit2.Retrofit;

Expand All @@ -39,6 +41,7 @@
import java.util.Set;
import java.util.UUID;


/**
* Base class for all Genie client integration tests.
*
Expand All @@ -63,16 +66,34 @@ abstract class GenieClientIntegrationTestBase {
// TODO: Improve genie-app image packaging to leverage unpacked (application plugin) based agent so that startup
// is faster as in agent mode the tests are much slower than embedded. Also once we move to boot 2.3 we can
// leverage their layered jars to produce less changing images.
@Container
private static final GenericContainer GENIE = new GenericContainer("netflixoss/genie-app:latest.release")
.waitingFor(Wait.forHttp("/admin/health").forStatusCode(200).withStartupTimeout(Duration.ofMinutes(1L)))
.withExposedPorts(8080);
private static GenericContainer genericContainer;

protected ApplicationClient applicationClient;
protected CommandClient commandClient;
protected ClusterClient clusterClient;
protected JobClient jobClient;

@BeforeAll
static void setupBeforeAll() {
try {
genericContainer = new GenericContainer("netflixoss/genie-app:latest.release")
.waitingFor(Wait.forHttp("/admin/health").forStatusCode(200).withStartupTimeout(Duration.ofMinutes(1L)))
.withExposedPorts(8080);
genericContainer.start();
} catch (Exception e) {
// skip genie client integration tests for unblocking
Assumptions.assumeTrue(() -> false, "Docker is not available. Skipping tests.");
}
}

@AfterAll
static void teardownAfterAll() {
// Stop the container
if (genericContainer != null) {
genericContainer.stop();
}
}

@BeforeEach
void setup() throws Exception {
// Just run these once but don't make it a static BeforeAll in case it would be executed before container starts
Expand All @@ -82,7 +103,9 @@ void setup() throws Exception {
|| this.clusterClient == null
|| this.jobClient == null
) {
final String baseUrl = "http://" + GENIE.getContainerIpAddress() + ":" + GENIE.getFirstMappedPort();
final String baseUrl = "http://" + genericContainer.getContainerIpAddress()
+ ":" + genericContainer.getFirstMappedPort();

final Retrofit retrofit = GenieClientUtils.createRetrofitInstance(baseUrl, null, null);
if (this.applicationClient == null) {
this.applicationClient = new ApplicationClient(retrofit);
Expand Down
Loading