Skip to content

Commit

Permalink
DRAFT - fighting CI
Browse files Browse the repository at this point in the history
  • Loading branch information
wprzytula committed Aug 8, 2022
1 parent 46d6f90 commit 4cbfa72
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 71 deletions.
112 changes: 56 additions & 56 deletions .github/workflows/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -31,60 +31,60 @@ jobs:
- name: Compile source and tests
run: mvn -B compile test-compile -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true

verify:
name: Full verify
runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
matrix:
java-version: [8, 11]
fail-fast: false

steps:
- name: Checkout source
uses: actions/checkout@v2

- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java-version }}
distribution: 'adopt'

- name: Full verify
run: mvn -B verify -DskipTests

unit-tests:
name: Unit tests
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout source
uses: actions/checkout@v2

- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'

- name: Run unit tests
run: mvn -B test -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true

- name: Copy test results
if: success() || failure()
run: |
shopt -s globstar
mkdir unit
cp --parents ./**/target/*-reports/*.xml unit/
- name: Upload test results
uses: actions/upload-artifact@v2
if: success() || failure()
with:
name: test-results
path: "*/**/target/*-reports/*.xml"
# verify:
# name: Full verify
# runs-on: ubuntu-latest
# timeout-minutes: 10

# strategy:
# matrix:
# java-version: [8, 11]
# fail-fast: false

# steps:
# - name: Checkout source
# uses: actions/checkout@v2

# - name: Set up JDK ${{ matrix.java-version }}
# uses: actions/setup-java@v2
# with:
# java-version: ${{ matrix.java-version }}
# distribution: 'adopt'

# - name: Full verify
# run: mvn -B verify -DskipTests

# unit-tests:
# name: Unit tests
# runs-on: ubuntu-latest
# timeout-minutes: 10

# steps:
# - name: Checkout source
# uses: actions/checkout@v2

# - name: Set up JDK 8
# uses: actions/setup-java@v2
# with:
# java-version: '8'
# distribution: 'adopt'

# - name: Run unit tests
# run: mvn -B test -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true

# - name: Copy test results
# if: success() || failure()
# run: |
# shopt -s globstar
# mkdir unit
# cp --parents ./**/target/*-reports/*.xml unit/

# - name: Upload test results
# uses: actions/upload-artifact@v2
# if: success() || failure()
# with:
# name: test-results
# path: "*/**/target/*-reports/*.xml"

setup-integration-tests:
name: Setup ITs
Expand Down Expand Up @@ -145,7 +145,7 @@ jobs:
pip3 install https://github.com/scylladb/scylla-ccm/archive/master.zip
- name: Run integration tests on Cassandra (${{ matrix.cassandra-version }})
run: mvn -B verify -Pshort -Dcassandra.version=${{ matrix.cassandra-version }} -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true
run: mvn -B verify -Pshort -Dcassandra.version=${{ matrix.cassandra-version }} -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true -Dtest=OpenTelemetryTest -Dsurefire.failIfNoSpecifiedTests=false

- name: Copy test results
if: success() || failure()
Expand Down Expand Up @@ -203,7 +203,7 @@ jobs:
sudo sh -c "echo 2097152 >> /proc/sys/fs/aio-max-nr"
- name: Run integration tests on Scylla (${{ matrix.scylla-version }})
run: mvn -B verify -Pshort -Dscylla.version=${{ matrix.scylla-version }} -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true
run: mvn -B verify -Pshort -Dscylla.version=${{ matrix.scylla-version }} -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true -Dtest=OpenTelemetryTest -Dsurefire.failIfNoSpecifiedTests=false

- name: Copy test results
if: success() || failure()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ private void setFinalResult(
&& logger.isWarnEnabled()) {
logServerWarnings(response.warnings);
}
callback.onSet(connection, response, info, statement, System.nanoTime() - startTime);

if (response.type == Message.Response.Type.RESULT) {
Responses.Result rm = (Responses.Result) response;
Expand All @@ -359,6 +358,8 @@ private void setFinalResult(
tracingInfo.setHasMorePages(r.metadata.pagingState != null);
}
}
callback.onSet(connection, response, info, statement, System.nanoTime() - startTime);

tracingInfo.setStatus(
response.type == Message.Response.Type.ERROR
? TracingInfo.StatusCode.ERROR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
Expand All @@ -60,21 +61,26 @@
/** Tests for OpenTelemetry integration. */
public class OpenTelemetryTest extends CCMTestsSupport {
/** Collects and saves spans. */
private static final class BookkeepingSpanProcessor implements SpanProcessor {
final AtomicInteger spansStarted = new AtomicInteger(0);

final AtomicInteger spansEnded = new AtomicInteger(0);

private final class BookkeepingSpanProcessor implements SpanProcessor {
final Lock lock = new ReentrantLock();
final Condition allEnded = lock.newCondition();

final Collection<ReadableSpan> startedSpans = new ArrayList<>();
final Collection<ReadableSpan> spans = new ArrayList<>();

int activeSpans = 0;
volatile int activeSpans = 0;

@Override
public void onStart(Context parentContext, ReadWriteSpan span) {
lock.lock();

startedSpans.add(span);
++activeSpans;
spansStarted.incrementAndGet();

lock.unlock();
}
Expand All @@ -90,6 +96,7 @@ public void onEnd(ReadableSpan span) {

spans.add(span);
--activeSpans;
spansEnded.incrementAndGet();

if (activeSpans == 0) allEnded.signal();

Expand Down Expand Up @@ -148,7 +155,6 @@ private Collection<ReadableSpan> collectSpans(
final Tracer tracer = openTelemetry.getTracerProvider().get("this");
final OpenTelemetryTracingInfoFactory tracingInfoFactory =
new OpenTelemetryTracingInfoFactory(tracer, precisionLevel);
cluster().setTracingInfoFactory(tracingInfoFactory);
session = cluster().connect();

session.execute("USE " + keyspace);
Expand All @@ -163,8 +169,18 @@ private Collection<ReadableSpan> collectSpans(
session.execute("INSERT INTO t(k, v) VALUES (9, 7)");
session.execute("INSERT INTO t(k, v) VALUES (10, 7)");
collector.getSpans().clear();
session.close();

session = cluster().connect();
cluster().setTracingInfoFactory(tracingInfoFactory);

/* try {
Thread.sleep(500);
} catch (InterruptedException e) {
assert false;
} */
test.accept(tracer, tracingInfoFactory);
session.close();

tracerProvider.close();
cluster().setTracingInfoFactory(new NoopTracingInfoFactory());
Expand All @@ -187,7 +203,7 @@ private Collection<ReadableSpan> getChildrenOfSpans(
}

/** Basic test for creating spans with INSERT statement. */
@Test(groups = "short")
// @Test(groups = "short")
public void simpleTracingInsertTest() {
final Collection<ReadableSpan> spans =
collectSpans(
Expand Down Expand Up @@ -303,7 +319,7 @@ public void simpleTracingInsertTest() {
}

/** Basic test for creating spans with UPDATE statement. */
@Test(groups = "short")
// @Test(groups = "short")
public void simpleTracingUpdateTest() {
final Collection<ReadableSpan> spans =
collectSpans(
Expand Down Expand Up @@ -431,7 +447,7 @@ public void simpleTracingUpdateTest() {
}

/** Basic test for creating spans with DELETE statement. */
@Test(groups = "short")
// @Test(groups = "short")
public void simpleTracingDeleteTest() {
final Collection<ReadableSpan> spans =
collectSpans(
Expand Down Expand Up @@ -561,7 +577,7 @@ public void simpleTracingDeleteTest() {
}

/** Basic test for creating spans with TRUNCATE statement. */
@Test(groups = "short")
// @Test(groups = "short")
public void simpleTracingTruncateTest() {
final Collection<ReadableSpan> spans =
collectSpans(
Expand Down Expand Up @@ -686,13 +702,14 @@ public void simpleTracingSelectTest() {
Scope scope = userSpan.makeCurrent();

SimpleStatement s =
new SimpleStatement("SELECT k FROM t WHERE v = 7 ALLOW FILTERING");
new SimpleStatement(
"SELECT k FROM " + keyspace + ".t WHERE v = 7 ALLOW FILTERING");
s.setFetchSize(2);
s.setIdempotent(true);
s.setRetryPolicy(FallthroughRetryPolicy.INSTANCE);
s.setConsistencyLevel(ConsistencyLevel.QUORUM);
s.setConsistencyLevel(ConsistencyLevel.ALL);

session.execute(s).all();
assertEquals(session.execute(s).all().size(), 7);

scope.close();
userSpan.end();
Expand Down Expand Up @@ -730,6 +747,7 @@ public void simpleTracingSelectTest() {

boolean wasNoMorePages = false;
int totalRows = 0;
List<Integer> rowsCounts = new ArrayList<>();

for (ReadableSpan requestSpan : requestSpans) {
SpanData spanData = requestSpan.toSpanData();
Expand All @@ -738,7 +756,7 @@ public void simpleTracingSelectTest() {
Attributes tags = spanData.getAttributes();

// tags generic for any (reasonable) statement
assertEquals(tags.get(AttributeKey.stringKey("db.scylla.consistency_level")), "QUORUM");
assertEquals(tags.get(AttributeKey.stringKey("db.scylla.consistency_level")), "ALL");
assertEquals(tags.get(AttributeKey.stringKey("db.scylla.fetch_size")), "2");
assertEquals(tags.get(AttributeKey.stringKey("db.scylla.statement_type")), "regular");
assertEquals(
Expand All @@ -758,6 +776,7 @@ public void simpleTracingSelectTest() {
final String rowsCount = tags.get(AttributeKey.stringKey("db.scylla.rows_count"));
assertNotNull(rowsCount);
totalRows += Integer.parseInt(rowsCount);
rowsCounts.add(Integer.parseInt(rowsCount));

// no such information in RegularStatement:
assertNull(tags.get(AttributeKey.stringKey("db.scylla.batch_size")));
Expand All @@ -773,10 +792,16 @@ public void simpleTracingSelectTest() {
assertNull(tags.get(AttributeKey.stringKey("net.peer.port")));
assertNull(tags.get(AttributeKey.stringKey("db.scylla.shard_id")));
}
;

assertTrue(wasNoMorePages);
assertEquals(totalRows, 7);
// assertEquals(totalRows, 7);
assert totalRows == 7
: "counts: "
+ rowsCounts.toString()
+ ", spansStarted="
+ spansStarted.toString()
+ "spansEnded"
+ spansEnded.toString();

speculativeExecutionsSpans.stream()
.map(ReadableSpan::toSpanData)
Expand Down Expand Up @@ -809,7 +834,7 @@ public void simpleTracingSelectTest() {
}

/** Basic test for creating spans with an erroneous statement. */
@Test(groups = "short")
// @Test(groups = "short")
public void simpleRequestErrorTracingTest() {
final Collection<ReadableSpan> spans =
collectSpans(
Expand Down

0 comments on commit 4cbfa72

Please sign in to comment.