solution: setup CI

This commit is contained in:
Igor Artamonov
2020-03-15 16:48:31 -04:00
committed by GitHub
parent 35cb35fe0a
commit 6392b6bebd
12 changed files with 382 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
package io.emeraldpay.dshackle.cache
import io.emeraldpay.dshackle.test.IntegrationTestingCommons
import io.emeraldpay.dshackle.test.TestingCommons
import io.emeraldpay.grpc.Chain
import io.infinitape.etherjar.domain.BlockHash
@@ -13,9 +14,7 @@ import spock.lang.Specification
import java.time.Instant
import java.time.temporal.ChronoUnit
@IgnoreIf({
env["DSHACKLE_TEST_ENABLED"] == null || !env["DSHACKLE_TEST_ENABLED"].contains("redis")
})
@IgnoreIf({ IntegrationTestingCommons.isDisabled("redis") })
class BlocksRedisCacheSpec extends Specification {
StatefulRedisConnection<String, String> redis
@@ -27,7 +26,7 @@ class BlocksRedisCacheSpec extends Specification {
def setup() {
RedisClient client = RedisClient.create("redis://localhost:6379");
RedisClient client = IntegrationTestingCommons.redis()
StatefulRedisConnection<String, String> connection = client.connect();
connection.sync().flushdb()
redis = connection

View File

@@ -1,5 +1,6 @@
package io.emeraldpay.dshackle.cache
import io.emeraldpay.dshackle.test.IntegrationTestingCommons
import io.emeraldpay.dshackle.test.TestingCommons
import io.emeraldpay.grpc.Chain
import io.infinitape.etherjar.domain.BlockHash
@@ -10,11 +11,13 @@ import io.infinitape.etherjar.rpc.json.TransactionJson
import io.infinitape.etherjar.rpc.json.TransactionRefJson
import io.lettuce.core.RedisClient
import io.lettuce.core.api.StatefulRedisConnection
import spock.lang.IgnoreIf
import spock.lang.Specification
import java.time.Instant
import java.time.temporal.ChronoUnit
@IgnoreIf({ IntegrationTestingCommons.isDisabled("redis") })
class TxRedisCacheSpec extends Specification {
String hash1 = "0xd3f34def3c56ba4e701540d15edaff9acd2a1c968a7ff83b3300ab5dfd5f6aab"
@@ -24,7 +27,7 @@ class TxRedisCacheSpec extends Specification {
TxRedisCache cache
def setup() {
RedisClient client = RedisClient.create("redis://localhost:6379");
RedisClient client = IntegrationTestingCommons.redis()
StatefulRedisConnection<String, String> connection = client.connect();
connection.sync().flushdb()
StatefulRedisConnection<String, String> redis = connection

View File

@@ -0,0 +1,25 @@
package io.emeraldpay.dshackle.test
import io.lettuce.core.RedisClient
class IntegrationTestingCommons {
static boolean isEnabled(String name) {
return System.getenv("DSHACKLE_TEST_ENABLED") != null && System.getenv("DSHACKLE_TEST_ENABLED").contains(name)
}
static boolean isDisabled(String name) {
return !isEnabled(name)
}
static String env(String name, String defaultValue) {
return System.getenv(name) ?: defaultValue
}
static RedisClient redis() {
String host = env("REDIS_HOST", "localhost")
String port = env("REDIS_PORT", "6379")
return RedisClient.create("redis://${host}:${port}")
}
}