Skip to content

Commit fb09338

Browse files
committed
chore: disable range and db sync tests in ci environment
1 parent 00a3ca6 commit fb09338

File tree

9 files changed

+80
-21
lines changed

9 files changed

+80
-21
lines changed

src/test/java/org/cardanofoundation/rewards/calculation/DepositCalculationTest.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import org.cardanofoundation.rewards.data.provider.JsonDataProvider;
66
import org.cardanofoundation.rewards.data.provider.KoiosDataProvider;
77
import org.cardanofoundation.rewards.entity.AdaPots;
8-
import org.cardanofoundation.rewards.entity.PoolDeregistration;
9-
import org.cardanofoundation.rewards.entity.PoolUpdate;
108
import org.cardanofoundation.rewards.enums.DataProviderType;
119
import org.junit.jupiter.api.Assertions;
1210
import org.junit.jupiter.api.Test;
@@ -15,17 +13,13 @@
1513
import org.springframework.beans.factory.annotation.Autowired;
1614
import org.springframework.boot.test.context.SpringBootTest;
1715
import org.springframework.context.annotation.ComponentScan;
18-
import org.springframework.test.context.ActiveProfiles;
19-
20-
import java.util.List;
16+
import org.springframework.test.context.junit.jupiter.EnabledIf;
2117
import java.util.stream.IntStream;
2218
import java.util.stream.Stream;
2319

24-
import static org.cardanofoundation.rewards.constants.RewardConstants.DEPOSIT_POOL_REGISTRATION_IN_LOVELACE;
25-
2620
@SpringBootTest
2721
@ComponentScan
28-
@ActiveProfiles("db-sync")
22+
@EnabledIf(expression = "#{environment.acceptsProfiles('db-sync')}", loadContext = true, reason = "DB Sync data provider must be available for this test")
2923
public class DepositCalculationTest {
3024

3125
@Autowired

src/test/java/org/cardanofoundation/rewards/calculation/EpochCalculationTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
package org.cardanofoundation.rewards.calculation;
22

3-
import org.cardanofoundation.rewards.data.provider.DataProvider;
43
import org.cardanofoundation.rewards.data.provider.DbSyncDataProvider;
54
import org.cardanofoundation.rewards.entity.PoolRewardCalculationResult;
65
import org.cardanofoundation.rewards.entity.TreasuryCalculationResult;
7-
import org.cardanofoundation.rewards.enums.DataProviderType;
86
import org.junit.jupiter.api.Test;
97
import org.springframework.beans.factory.annotation.Autowired;
108
import org.springframework.boot.test.context.SpringBootTest;
119
import org.springframework.context.annotation.ComponentScan;
12-
import org.springframework.test.context.ActiveProfiles;
10+
import org.springframework.test.context.junit.jupiter.EnabledIf;
1311

1412
import java.util.List;
1513

@@ -18,7 +16,7 @@
1816
*/
1917
@SpringBootTest
2018
@ComponentScan
21-
@ActiveProfiles("db-sync")
19+
@EnabledIf(expression = "#{environment.acceptsProfiles('db-sync')}", loadContext = true, reason = "DB Sync data provider must be available for this test")
2220
public class EpochCalculationTest {
2321

2422
// Only the DbSyncDataProvider is used for this test

src/test/java/org/cardanofoundation/rewards/calculation/FeesCalculationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
import org.springframework.beans.factory.annotation.Autowired;
1414
import org.springframework.boot.test.context.SpringBootTest;
1515
import org.springframework.context.annotation.ComponentScan;
16-
import org.springframework.test.context.ActiveProfiles;
16+
import org.springframework.test.context.junit.jupiter.EnabledIf;
1717

1818
import java.util.stream.IntStream;
1919
import java.util.stream.Stream;
2020

2121
@SpringBootTest
2222
@ComponentScan
23-
@ActiveProfiles("db-sync")
23+
@EnabledIf(expression = "#{environment.acceptsProfiles('db-sync')}", loadContext = true, reason = "DB Sync data provider must be available for this test")
2424
public class FeesCalculationTest {
2525
@Autowired
2626
KoiosDataProvider koiosDataProvider;

src/test/java/org/cardanofoundation/rewards/calculation/PoolRewardCalculationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.springframework.beans.factory.annotation.Autowired;
1212
import org.springframework.boot.test.context.SpringBootTest;
1313
import org.springframework.context.annotation.ComponentScan;
14-
14+
import org.springframework.test.context.junit.jupiter.DisabledIf;
1515
import java.util.stream.IntStream;
1616
import java.util.stream.Stream;
1717

@@ -28,7 +28,6 @@ public class PoolRewardCalculationTest {
2828
@Autowired
2929
JsonDataProvider jsonDataProvider;
3030

31-
3231
private void Test_calculatePoolReward(final String poolId,
3332
final int epoch,
3433
final DataProviderType dataProviderType) {
@@ -82,6 +81,7 @@ static Stream<Integer> testPoolJsonProviderRewardRange() {
8281

8382
@ParameterizedTest
8483
@MethodSource("testPoolJsonProviderRewardRange")
84+
@DisabledIf(expression = "#{environment.acceptsProfiles('ci')}", loadContext = true, reason = "Range test is too long for CI")
8585
void calculateNorthPoolRewardFromEpoch211To432(int epoch) {
8686
String poolId = "pool12t3zmafwjqms7cuun86uwc8se4na07r3e5xswe86u37djr5f0lx";
8787
Test_calculatePoolReward(poolId, epoch, DataProviderType.JSON);

src/test/java/org/cardanofoundation/rewards/calculation/TreasuryCalculationTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
import org.junit.jupiter.params.provider.Arguments;
1313
import org.junit.jupiter.params.provider.MethodSource;
1414
import org.springframework.beans.factory.annotation.Autowired;
15+
import org.springframework.beans.factory.annotation.Value;
1516
import org.springframework.boot.test.context.SpringBootTest;
1617
import org.junit.jupiter.api.Assertions;
1718
import org.springframework.context.annotation.ComponentScan;
19+
import org.springframework.test.context.junit.jupiter.DisabledIf;
1820

1921
import static org.cardanofoundation.rewards.constants.RewardConstants.*;
2022
import static org.cardanofoundation.rewards.util.CurrencyConverter.lovelaceToAda;
@@ -29,6 +31,9 @@ public class TreasuryCalculationTest {
2931
@Autowired
3032
JsonDataProvider jsonDataProvider;
3133

34+
@Value("${spring.profiles.active}")
35+
private String activeProfiles;
36+
3237
void Test_calculateTreasury(final int epoch, DataProviderType dataProviderType) {
3338

3439
DataProvider dataProvider = null;
@@ -52,13 +57,15 @@ static Stream<Integer> dataProviderRangeUntilEpoch213() {
5257
}
5358

5459
@ParameterizedTest
60+
@DisabledIf(expression = "#{environment.acceptsProfiles('ci')}", loadContext = true, reason = "Range test is too long for CI")
5561
@MethodSource("dataProviderRangeUntilEpoch213")
5662
void Test_calculateTreasuryWithKoiosDataProvider(int epoch) {
63+
System.out.println(activeProfiles);
5764
Test_calculateTreasury(epoch, DataProviderType.KOIOS);
5865
}
5966

6067
static Stream<Integer> jsonDataProviderRange() {
61-
return IntStream.range(210, 217).boxed();
68+
return IntStream.range(210, 215).boxed();
6269
}
6370

6471
@ParameterizedTest

src/test/java/org/cardanofoundation/rewards/calculation/UtxoCalculationTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@
1111
import org.junit.jupiter.params.ParameterizedTest;
1212
import org.junit.jupiter.params.provider.MethodSource;
1313
import org.springframework.beans.factory.annotation.Autowired;
14+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
1415
import org.springframework.boot.test.context.SpringBootTest;
1516
import org.springframework.context.annotation.ComponentScan;
16-
import org.springframework.test.context.ActiveProfiles;
17+
import org.springframework.test.context.junit.jupiter.EnabledIf;
1718

1819
import java.util.stream.IntStream;
1920
import java.util.stream.Stream;
2021

2122
@SpringBootTest
2223
@ComponentScan
23-
@ActiveProfiles("db-sync")
24+
@EnabledIf(expression = "#{environment.acceptsProfiles('db-sync')}", loadContext = true, reason = "DB Sync data provider must be available for this test")
2425
public class UtxoCalculationTest {
2526

2627
@Autowired

src/test/java/org/cardanofoundation/rewards/data/provider/DbSyncDataProviderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.springframework.beans.factory.annotation.Autowired;
1212
import org.springframework.boot.test.context.SpringBootTest;
1313
import org.springframework.context.annotation.ComponentScan;
14-
import org.springframework.test.context.ActiveProfiles;
14+
import org.springframework.test.context.junit.jupiter.EnabledIf;
1515

1616
import java.util.List;
1717
import java.util.stream.IntStream;
@@ -22,7 +22,7 @@
2222

2323
@SpringBootTest
2424
@ComponentScan
25-
@ActiveProfiles("db-sync")
25+
@EnabledIf(expression = "#{environment.acceptsProfiles('db-sync')}", loadContext = true, reason = "DB Sync data provider must be available for this test")
2626
public class DbSyncDataProviderTest {
2727

2828
@Autowired

src/test/resources/.env.example

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copy this example file to .env and fill in the values
2+
# Do not commit .env to git
3+
4+
# Possible values are: ci, json, db-sync, koios
5+
SPRING_PROFILES_ACTIVE=ci json
6+
7+
# The following values are required for the dbsync profile
8+
POSTGRES_USER=<YOUR_USER>
9+
POSTGRES_PASSWORD=<YOUR_PASSWORD>
10+
POSTGRES_DB=cexplorer
11+
12+
# Settings for the json data provider
13+
JSON_DATA_SOURCE_FOLDER=<PATH_TO_JSON_DATA_FOLDER>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
server:
2+
port: ${SERVER_PORT:8888}
3+
4+
spring:
5+
profiles:
6+
active: ${SPRING_PROFILES_ACTIVE:ci, json}
7+
8+
json:
9+
data-provider:
10+
source: ${JSON_DATA_SOURCE_FOLDER}
11+
12+
---
13+
spring:
14+
config:
15+
activate:
16+
on-profile: db-sync
17+
18+
flyway:
19+
enabled: false
20+
21+
datasource:
22+
type: com.zaxxer.hikari.HikariDataSource
23+
hikari:
24+
read-only: true
25+
url: jdbc:postgresql://${POSTGRES_HOST:localhost}:${POSTGRES_PORT:54321}/${POSTGRES_DB}
26+
username: ${POSTGRES_USER}
27+
password: ${POSTGRES_PASSWORD}
28+
driver-class-name: org.postgresql.Driver
29+
30+
jpa:
31+
open-in-view: false
32+
database-platform: org.hibernate.dialect.PostgreSQLDialect
33+
show-sql: true
34+
properties:
35+
javax:
36+
persistence:
37+
readOnly: true
38+
hibernate:
39+
dialect: org.hibernate.dialect.PostgreSQLDialect
40+
ddl-auto: none
41+
show_sql: false
42+
format_sql: true
43+
jdbc:
44+
batch_size: 100
45+
temp:
46+
use_jdbc_metadata_defaults: false

0 commit comments

Comments
 (0)