Skip to content

Commit 6556ce3

Browse files
committed
test reports
1 parent f202921 commit 6556ce3

File tree

3 files changed

+80
-64
lines changed

3 files changed

+80
-64
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@
1818
*.pyd filter=lfs diff=lfs merge=lfs -text
1919
*.png filter=lfs diff=lfs merge=lfs -text
2020
*.jpg filter=lfs diff=lfs merge=lfs -text
21+
22+
bin/runner.sh text eol=lf

.github/workflows/build.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build CI
33
on:
44
workflow_dispatch:
55
push:
6-
branches: [main]
6+
branches: [main-actualize]
77
pull_request:
88
types: [opened, synchronize]
99
branches: [main]
@@ -92,3 +92,9 @@ jobs:
9292
path: |
9393
./java/runner/build/reports/tests/intTest
9494
./java/runner/build/intTest
95+
- name: Report Tests
96+
uses: dorny/test-reporter@v1
97+
if: success() || failure()
98+
with:
99+
name: Integration Tests
100+
path: ./java/runner/build/test-results/intTest/*.xml

java/runner/src/intTest/java/com/epam/deltix/data/connectors/ApplicationIntTest.java

+71-63
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,22 @@ public class ApplicationIntTest extends TbIntTestPreparation {
6464
withFileSystemBind("build/intTest/config", "/runner/config", BindMode.READ_WRITE).
6565
withStartupTimeout(Duration.ofMinutes(5));
6666

67-
private static final int SMOKE_READ_TIMEOUT_S = 30;
68-
private static final int SMOKE_READ_MESSAGES = 10;
67+
private static final int READ_TIMEOUT_S = 10;
6968

70-
private static final int VALIDATION_READ_TIMEOUT_S = 300;
69+
private static final int SMOKE_READ_MESSAGES = 100;
7170
private static final int VALIDATION_READ_MESSAGES = 1000;
7271

72+
private static Map<String, TestConnectorReports> reports = new LinkedHashMap<>();
73+
7374
@BeforeAll
7475
static void beforeAll() throws Exception {
7576
TIMEBASE_CONTAINER.start();
7677
APP_CONTAINER.start();
7778

7879
Thread.sleep(10_000);
80+
81+
Arrays.stream(listConnectors()).sorted(Comparator.comparing(c -> c.connector))
82+
.forEach(c -> reports.put(c.connector, c));
7983
}
8084

8185
@AfterAll
@@ -99,38 +103,39 @@ void closeTb() {
99103

100104
@TestFactory
101105
Stream<DynamicTest> testDataFeedInTbSmoke() throws Exception {
102-
return Arrays.stream(listStreams()).
103-
map(c -> DynamicTest.dynamicTest(
104-
c.connector,
106+
return reports.values().stream()
107+
.map(c -> DynamicTest.dynamicTest(
108+
"Connection To " + c.connector,
105109
() -> tryReadSomeData(c)
106110
));
107111
}
108112

109113
@TestFactory
110114
Stream<DynamicTest> testDataFeedInTbValidateOrderBook() throws Exception {
111-
return Arrays.stream(listStreams()).filter(c -> !SKIP_CONNECTORS_DATA_VALIDATION.contains(c.stream)).
112-
map(c -> DynamicTest.dynamicTest(
113-
c.connector,
115+
return reports.values().stream()
116+
.filter(c -> !SKIP_CONNECTORS_DATA_VALIDATION.contains(c.stream))
117+
.map(c -> DynamicTest.dynamicTest(
118+
"Validate L2 for " + c.connector,
114119
() -> tryBuildOrderBook(c)
115120
));
116121
}
117122

118-
private static ConnectorStream[] listStreams() throws Exception {
123+
private static TestConnectorReports[] listConnectors() throws Exception {
119124
final JsonArray connectors =
120125
rest("http://localhost:" + APP_CONTAINER.getFirstMappedPort() + "/api/v0/connectors").
121126
asArrayRequired();
122127

123128
return connectors.items().
124129
map(JsonValue::asObjectRequired).
125-
map(ConnectorStream::new).
130+
map(TestConnectorReports::new).
126131
filter(connector -> !SKIP_CONNECTORS.contains(connector.stream)).
127-
toArray(ConnectorStream[]::new);
132+
toArray(TestConnectorReports[]::new);
128133
}
129134

130-
void tryReadSomeData(final ConnectorStream connector) {
135+
void tryReadSomeData(final TestConnectorReports connector) {
131136
// we are trying to read N messages
132137
final int expectedNumOfMessages = SMOKE_READ_MESSAGES;
133-
final int timeoutSeconds = SMOKE_READ_TIMEOUT_S;
138+
final int timeoutSeconds = READ_TIMEOUT_S;
134139

135140
final DXTickStream stream = db.getStream(connector.stream);
136141

@@ -139,20 +144,18 @@ void tryReadSomeData(final ConnectorStream connector) {
139144

140145
try (TickCursor cursor = stream.select(TimeConstants.TIMESTAMP_UNKNOWN,
141146
new SelectionOptions(true, true))) {
142-
Assertions.assertTimeoutPreemptively(Duration.ofSeconds(timeoutSeconds), () -> {
143-
int messages = 0;
144-
while (cursor.next()) {
145-
if (++messages == expectedNumOfMessages) {
146-
break;
147-
}
147+
int messages = 0;
148+
while (readWithTimeout(timeoutSeconds, cursor, connector)) {
149+
if (++messages == expectedNumOfMessages) {
150+
break;
148151
}
149-
}, "Cannot read data for the " + connector);
152+
}
150153
}
151154
}
152155

153-
void tryBuildOrderBook(final ConnectorStream connector) {
156+
void tryBuildOrderBook(final TestConnectorReports connector) {
154157
final int expectedNumOfMessages = VALIDATION_READ_MESSAGES;
155-
final int timeoutSeconds = VALIDATION_READ_TIMEOUT_S;
158+
final int timeoutSeconds = READ_TIMEOUT_S;
156159

157160
final DXTickStream stream = db.getStream(connector.stream);
158161

@@ -163,54 +166,59 @@ void tryBuildOrderBook(final ConnectorStream connector) {
163166
AtomicLong errors = new AtomicLong();
164167

165168
try (TickCursor cursor = stream.select(TimeConstants.TIMESTAMP_UNKNOWN, new SelectionOptions(false, true))) {
166-
Assertions.assertTimeoutPreemptively(Duration.ofSeconds(timeoutSeconds), () -> {
167-
int messages = 0;
168-
while (cursor.next()) {
169-
InstrumentMessage message = cursor.getMessage();
170-
if (message.getSymbol() == null) {
171-
continue;
169+
int messages = 0;
170+
while (readWithTimeout(timeoutSeconds, cursor, connector)) {
171+
InstrumentMessage message = cursor.getMessage();
172+
if (message.getSymbol() == null) {
173+
continue;
174+
}
175+
176+
// validate
177+
if (message instanceof PackageHeaderInfo) {
178+
PackageHeaderInfo packageHeader = (PackageHeaderInfo) message;
179+
DataValidator validator = validators.computeIfAbsent(
180+
message.getSymbol().toString(),
181+
k -> createValidator(k, (sender, severity, exception, stringMessage) -> {
182+
if (severity == Severity.ERROR) {
183+
errors.addAndGet(1);
184+
LOG.severe(severity + " | " + stringMessage);
185+
} else {
186+
LOG.warning(severity + " | " + stringMessage);
187+
}
188+
189+
if (exception != null) {
190+
LOG.log(Level.SEVERE, "Exception", exception);
191+
}
192+
}, stream
193+
)
194+
);
195+
196+
validator.sendPackage(packageHeader);
197+
198+
if (++messages % 100 == 0) {
199+
LOG.info("Processed " + messages + " package headers");
172200
}
173201

174-
// validate
175-
if (message instanceof PackageHeaderInfo) {
176-
PackageHeaderInfo packageHeader = (PackageHeaderInfo) message;
177-
DataValidator validator = validators.computeIfAbsent(
178-
message.getSymbol().toString(),
179-
k -> createValidator(k, (sender, severity, exception, stringMessage) -> {
180-
if (severity == Severity.ERROR) {
181-
errors.addAndGet(1);
182-
LOG.severe(severity + " | " + stringMessage);
183-
} else {
184-
LOG.warning(severity + " | " + stringMessage);
185-
}
186-
187-
if (exception != null) {
188-
LOG.log(Level.SEVERE, "Exception", exception);
189-
}
190-
}, stream
191-
)
192-
);
193-
194-
validator.sendPackage(packageHeader);
195-
196-
if (++messages % 100 == 0) {
197-
LOG.info("Processed " + messages + " package headers");
198-
}
199-
200-
if (messages == expectedNumOfMessages) {
201-
LOG.info("Processed " + messages + " package headers");
202-
break;
203-
}
202+
if (messages == expectedNumOfMessages) {
203+
LOG.info("Processed " + messages + " package headers");
204+
break;
204205
}
205206
}
206-
}, "Cannot read data for the " + connector);
207+
}
207208
} finally {
208209
exportStream(stream);
209210
}
210211

211212
Assertions.assertEquals(0L, errors.get());
212213
}
213214

215+
private static Boolean readWithTimeout(long timeoutSeconds, TickCursor cursor, TestConnectorReports connector) {
216+
return Assertions.assertTimeoutPreemptively(
217+
Duration.ofSeconds(timeoutSeconds), cursor::next,
218+
"Cannot read data for the " + connector
219+
);
220+
}
221+
214222
private static DataValidator createValidator(String symbol, LogProcessor log, DXTickStream stream) {
215223
DataValidatorImpl validator = new DataValidatorImpl(symbol, log,
216224
Decimal64Utils.parse("0.0000000000000000001"), Decimal64Utils.parse("0.0000000000000000001"),
@@ -260,16 +268,16 @@ private static JsonValue rest(final String url) throws Exception {
260268
return new JsonValueParser().parseAndEoj(response.body());
261269
}
262270

263-
private static class ConnectorStream {
271+
private static class TestConnectorReports {
264272
private final String connector;
265273
private final String stream;
266274

267-
private ConnectorStream(final JsonObject fromJsom) {
275+
private TestConnectorReports(final JsonObject fromJsom) {
268276
this(fromJsom.getStringRequired("name"),
269277
fromJsom.getStringRequired("stream"));
270278
}
271279

272-
private ConnectorStream(final String connector, final String stream) {
280+
private TestConnectorReports(final String connector, final String stream) {
273281
this.connector = connector;
274282
this.stream = stream;
275283
}

0 commit comments

Comments
 (0)