Skip to content

Commit

Permalink
Stop skipping IT by assumeThat (treasure-data#1601)
Browse files Browse the repository at this point in the history
* Add assertThat as replacement of assumeThat.
* run_test.sh in Github Workflow skip IT explicitly.
  • Loading branch information
yoyama committed Jun 9, 2021
1 parent e34c369 commit cf73572
Show file tree
Hide file tree
Showing 24 changed files with 39 additions and 67 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
- name: Run tests in Docker
run: ci/run_test.sh
env:
# Explicilty skip IT
CI_ACCEPTANCE_TEST: false
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
CI_NODE_TOTAL: 10
BUILD_IMAGE: digdag/digdag-build:20210121T160201-c21ea363746ab5ef7f7503a1a6212a37b79a9943
Expand Down
2 changes: 1 addition & 1 deletion ci/run_test_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ docker run \
-e REDSHIFT_IT_CONFIG="${REDSHIFT_IT_CONFIG}" \
-e CI_NODE_TOTAL="${CI_NODE_TOTAL}" \
-e CI_NODE_INDEX="${CI_NODE_INDEX}" \
-e CI_ACCEPTANCE_TEST=true \
-e CI_ACCEPTANCE_TEST="${CI_ACCEPTANCE_TEST:-true}" \
-e TEST_S3_ENDPOINT=$TEST_S3_ENDPOINT \
-e TEST_S3_ACCESS_KEY_ID=$TEST_S3_ACCESS_KEY_ID \
-e TEST_S3_SECRET_ACCESS_KEY=$TEST_S3_SECRET_ACCESS_KEY \
Expand Down
7 changes: 3 additions & 4 deletions digdag-tests/src/test/java/acceptance/AgentOverAcquireIT.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package acceptance;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeThat;
import static utils.TestUtils.copyResource;
import static utils.TestUtils.main;
import utils.CommandStatus;

// Disabled to avoid too long execution time. We should remove this whole test in the future.
@Ignore
public class AgentOverAcquireIT
{
@Rule
Expand All @@ -39,8 +40,6 @@ public void setUp()
public void testOverAcquire()
throws Exception
{
assumeThat(true, is(false)); // disabled by default to avoid too long execution time.

copyResource("acceptance/over_acquire/over_acquire.dig", projectDir.resolve("over_acquire.dig"));

CommandStatus runStatus = main("run",
Expand Down
1 change: 0 additions & 1 deletion digdag-tests/src/test/java/acceptance/AttemptLimitIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeThat;
import static java.time.temporal.ChronoUnit.HOURS;

public class AttemptLimitIT
Expand Down
4 changes: 1 addition & 3 deletions digdag-tests/src/test/java/acceptance/S3StorageIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import io.digdag.client.api.RestLogFileHandle;
import io.digdag.client.api.RestProject;
import io.digdag.client.api.RestSessionAttempt;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -31,7 +30,6 @@
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeThat;

public class S3StorageIT
{
Expand Down Expand Up @@ -73,7 +71,7 @@ public class S3StorageIT
public void setUp()
throws Exception
{
assumeThat(TEST_S3_ENDPOINT, not(isEmptyOrNullString()));
assertThat(TEST_S3_ENDPOINT, not(isEmptyOrNullString()));

projectDir = folder.getRoot().toPath().resolve("foobar");
config = folder.newFile().toPath();
Expand Down
3 changes: 1 addition & 2 deletions digdag-tests/src/test/java/acceptance/S3WaitIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeThat;
import static utils.TestUtils.addWorkflow;
import static utils.TestUtils.attemptSuccess;
import static utils.TestUtils.createProject;
Expand Down Expand Up @@ -70,7 +69,7 @@ public class S3WaitIT
public void setUp()
throws Exception
{
assumeThat(TEST_S3_ENDPOINT, not(isEmptyOrNullString()));
assertThat(TEST_S3_ENDPOINT, not(isEmptyOrNullString()));

proxyServer = TestUtils.startRequestFailingProxy(10);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private Path root()
public void setUp()
throws Exception
{
//This checks Windows environment and then skip
assumeThat(server.hasUnixProcess(), is(true));

projectDir = root().resolve("foobar");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
import java.net.Socket;
import java.net.InetSocketAddress;

import java.sql.Connection;

import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeThat;

import static java.nio.charset.StandardCharsets.UTF_8;

import static utils.TestUtils.expect;
Expand Down
3 changes: 2 additions & 1 deletion digdag-tests/src/test/java/acceptance/ServerJmxIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import java.sql.Connection;
import java.sql.Statement;

import javax.management.remote.JMXServiceURL;
Expand Down Expand Up @@ -81,6 +80,7 @@ public void verifyJmx()
public void verifyHikariCP()
throws Exception
{
//This test requires remote database
assumeThat(server.isRemoteDatabase(), is(true));
try (JMXConnector con = connectJmx(server)) {
MBeanServerConnection beans = con.getMBeanServerConnection();
Expand Down Expand Up @@ -126,6 +126,7 @@ public void verifyDigdagMetrics()
public void verifyUncaughtErrorCount()
throws Exception
{
//This test requires remote database
assumeThat(server.isRemoteDatabase(), is(true));

try (JMXConnector con = connectJmx(server)) {
Expand Down
2 changes: 1 addition & 1 deletion digdag-tests/src/test/java/acceptance/ShIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -34,6 +33,7 @@ public class ShIT
public void setUp()
throws Exception
{
//This checks Windows environment and then skip
assumeThat(runEcho(), is(true));

projectDir = folder.getRoot().toPath().toAbsolutePath().normalize();
Expand Down
7 changes: 3 additions & 4 deletions digdag-tests/src/test/java/acceptance/td/BigQueryIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeThat;
import static utils.TestUtils.addWorkflow;
import static utils.TestUtils.attemptSuccess;
import static utils.TestUtils.createProject;
Expand Down Expand Up @@ -106,7 +105,7 @@ public class BigQueryIT
public void setUp()
throws Exception
{
assumeThat(GCP_CREDENTIAL, not(isEmptyOrNullString()));
assertThat(GCP_CREDENTIAL, not(isEmptyOrNullString()));

proxyServer = TestUtils.startRequestFailingProxy(2, new ConcurrentHashMap<>(), HttpResponseStatus.INTERNAL_SERVER_ERROR,
(req, reqCount) -> {
Expand Down Expand Up @@ -237,7 +236,7 @@ public static class LoadIT
public void testLoad()
throws Exception
{
assumeThat(GCS_TEST_BUCKET, not(isEmptyOrNullString()));
assertThat(GCS_TEST_BUCKET, not(isEmptyOrNullString()));

// Create source data object
String objectName = GCS_PREFIX + "test.csv";
Expand Down Expand Up @@ -282,7 +281,7 @@ public static class ExtractIT
public void testExtract()
throws Exception
{
assumeThat(GCS_TEST_BUCKET, not(isEmptyOrNullString()));
assertThat(GCS_TEST_BUCKET, not(isEmptyOrNullString()));

// Create source table
String tableId = "data";
Expand Down
17 changes: 7 additions & 10 deletions digdag-tests/src/test/java/acceptance/td/EmrIT.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package acceptance.td;

import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.elasticmapreduce.AmazonElasticMapReduceClient;
Expand All @@ -12,12 +11,10 @@
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.AmazonS3URI;
import com.amazonaws.services.s3.model.DeleteObjectsRequest;
import com.amazonaws.services.s3.model.ListObjectsRequest;
import com.amazonaws.services.s3.model.ObjectListing;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.S3Object;
import com.amazonaws.services.s3.model.S3ObjectSummary;
import com.google.common.base.Throwables;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
Expand All @@ -29,7 +26,6 @@
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
Expand Down Expand Up @@ -112,12 +108,12 @@ public class EmrIT
public void setUp()
throws Exception
{
assumeThat(S3_TEMP_BUCKET, not(isEmptyOrNullString()));
assumeThat(AWS_ACCESS_KEY_ID, not(isEmptyOrNullString()));
assumeThat(AWS_SECRET_ACCESS_KEY, not(isEmptyOrNullString()));
assumeThat(AWS_ROLE, not(isEmptyOrNullString()));
assumeThat(TD_API_KEY, not(isEmptyOrNullString()));
assumeThat(AWS_KMS_KEY_ID, not(isEmptyOrNullString()));
assertThat(S3_TEMP_BUCKET, not(isEmptyOrNullString()));
assertThat(AWS_ACCESS_KEY_ID, not(isEmptyOrNullString()));
assertThat(AWS_SECRET_ACCESS_KEY, not(isEmptyOrNullString()));
assertThat(AWS_ROLE, not(isEmptyOrNullString()));
assertThat(TD_API_KEY, not(isEmptyOrNullString()));
assertThat(AWS_KMS_KEY_ID, not(isEmptyOrNullString()));

AWSCredentials credentials = new BasicAWSCredentials(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY);

Expand Down Expand Up @@ -301,6 +297,7 @@ public void manualTest()
throws Exception
{
String clusterId = System.getenv("EMR_TEST_CLUSTER_ID");
// This test is expected to run by hand. So keep assumeThat.
assumeThat(clusterId, not(Matchers.isEmptyOrNullString()));

Id attemptId = pushAndStart(server.endpoint(), projectDir, "emr", ImmutableMap.of(
Expand Down
5 changes: 2 additions & 3 deletions digdag-tests/src/test/java/acceptance/td/GcsWaitIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeThat;
import static utils.TestUtils.addWorkflow;
import static utils.TestUtils.attemptSuccess;
import static utils.TestUtils.createProject;
Expand Down Expand Up @@ -75,8 +74,8 @@ public class GcsWaitIT
public void setUp()
throws Exception
{
assumeThat(GCP_CREDENTIAL, not(isEmptyOrNullString()));
assumeThat(GCS_TEST_BUCKET, not(isEmptyOrNullString()));
assertThat(GCP_CREDENTIAL, not(isEmptyOrNullString()));
assertThat(GCS_TEST_BUCKET, not(isEmptyOrNullString()));

proxyServer = TestUtils.startRequestFailingProxy(1);

Expand Down
3 changes: 1 addition & 2 deletions digdag-tests/src/test/java/acceptance/td/PyIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeThat;
import static utils.TestUtils.copyResource;
import static utils.TestUtils.getAttemptId;
import static utils.TestUtils.getAttemptLogs;
Expand Down Expand Up @@ -58,7 +57,7 @@ public class PyIT
public void setUp()
throws Exception
{
assumeThat(ECS_CONFIG, not(isEmptyOrNullString()));
assertThat(ECS_CONFIG, not(isEmptyOrNullString()));

ObjectMapper objectMapper = DigdagClient.objectMapper();
config = Config.deserializeFromJackson(objectMapper, objectMapper.readTree(ECS_CONFIG));
Expand Down
3 changes: 1 addition & 2 deletions digdag-tests/src/test/java/acceptance/td/RedshiftIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assume.assumeThat;
import static utils.TestUtils.*;

public class RedshiftIT
Expand Down Expand Up @@ -109,7 +108,7 @@ interface ContentBuilder<T>

@Before
public void setUp() throws Exception {
assumeThat(REDSHIFT_CONFIG, not(isEmptyOrNullString()));
assertThat(REDSHIFT_CONFIG, not(isEmptyOrNullString()));

ObjectMapper objectMapper = DigdagClient.objectMapper();
config = Config.deserializeFromJackson(objectMapper, objectMapper.readTree(REDSHIFT_CONFIG));
Expand Down
3 changes: 1 addition & 2 deletions digdag-tests/src/test/java/acceptance/td/TdConfIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeThat;
import static utils.TestUtils.main;

public class TdConfIT
Expand All @@ -57,7 +56,7 @@ public class TdConfIT
public void setUp()
throws Exception
{
assumeThat(TD_API_KEY, not(isEmptyOrNullString()));
assertThat(TD_API_KEY, not(isEmptyOrNullString()));
tdConf = folder.newFolder().toPath().resolve("td.conf");
digdagConf = folder.newFolder().toPath().resolve("digdag");
Files.write(digdagConf, emptyList());
Expand Down
5 changes: 1 addition & 4 deletions digdag-tests/src/test/java/acceptance/td/TdDdlIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,8 @@
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeThat;
import static utils.TestUtils.addWorkflow;
import static utils.TestUtils.main;

Expand Down Expand Up @@ -102,7 +99,7 @@ public class TdDdlIT
public void setUp()
throws Exception
{
assumeThat(TD_API_KEY, not(isEmptyOrNullString()));
assertThat(TD_API_KEY, not(isEmptyOrNullString()));
noTdConf = folder.newFolder().toPath().resolve("non-existing-td.conf").toString();
projectDir = folder.newFolder().toPath();
config = folder.newFile().toPath();
Expand Down
7 changes: 1 addition & 6 deletions digdag-tests/src/test/java/acceptance/td/TdForEachIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import io.digdag.client.DigdagClient;
import io.digdag.client.api.Id;
import org.littleshoot.proxy.HttpProxyServer;
import utils.CommandStatus;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -20,16 +19,12 @@
import static acceptance.td.Secrets.secretsServerConfiguration;
import static utils.TestUtils.addWorkflow;
import static utils.TestUtils.attemptSuccess;
import static utils.TestUtils.copyResource;
import static utils.TestUtils.createProject;
import static utils.TestUtils.expect;
import static utils.TestUtils.main;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeThat;
import static utils.TestUtils.pushAndStart;
import static utils.TestUtils.pushProject;

Expand All @@ -54,7 +49,7 @@ public class TdForEachIT
public void setUp()
throws Exception
{
assumeThat(TD_API_KEY, not(isEmptyOrNullString()));
assertThat(TD_API_KEY, not(isEmptyOrNullString()));

proxyServer = TestUtils.startRequestFailingProxy(5);

Expand Down
3 changes: 1 addition & 2 deletions digdag-tests/src/test/java/acceptance/td/TdIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assume.assumeThat;
import static utils.TestUtils.attemptSuccess;
import static utils.TestUtils.copyResource;
import static utils.TestUtils.expect;
Expand Down Expand Up @@ -99,7 +98,7 @@ public class TdIT
public void setUp()
throws Exception
{
assumeThat(TD_API_KEY, not(isEmptyOrNullString()));
assertThat(TD_API_KEY, not(isEmptyOrNullString()));
noTdConf = folder.newFolder().toPath().resolve("non-existing-td.conf").toString();
projectDir = folder.getRoot().toPath().toAbsolutePath().normalize();
config = folder.newFile().toPath();
Expand Down
Loading

0 comments on commit cf73572

Please sign in to comment.