From 4cbfa728f02fd8001bb914632a208582b94759dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Przytu=C5=82a?= Date: Mon, 8 Aug 2022 10:21:32 +0200 Subject: [PATCH] DRAFT - fighting CI --- .github/workflows/tests@v1.yml | 112 +++++++++--------- .../datastax/driver/core/RequestHandler.java | 3 +- .../opentelemetry/OpenTelemetryTest.java | 53 ++++++--- 3 files changed, 97 insertions(+), 71 deletions(-) diff --git a/.github/workflows/tests@v1.yml b/.github/workflows/tests@v1.yml index 80702698380..e237a959697 100644 --- a/.github/workflows/tests@v1.yml +++ b/.github/workflows/tests@v1.yml @@ -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 @@ -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() @@ -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() diff --git a/driver-core/src/main/java/com/datastax/driver/core/RequestHandler.java b/driver-core/src/main/java/com/datastax/driver/core/RequestHandler.java index c91eb72bedc..22c8490ffef 100644 --- a/driver-core/src/main/java/com/datastax/driver/core/RequestHandler.java +++ b/driver-core/src/main/java/com/datastax/driver/core/RequestHandler.java @@ -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; @@ -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 diff --git a/driver-opentelemetry/src/test/java/com/datastax/driver/opentelemetry/OpenTelemetryTest.java b/driver-opentelemetry/src/test/java/com/datastax/driver/opentelemetry/OpenTelemetryTest.java index f27fbf93f24..7afaa76f17d 100644 --- a/driver-opentelemetry/src/test/java/com/datastax/driver/opentelemetry/OpenTelemetryTest.java +++ b/driver-opentelemetry/src/test/java/com/datastax/driver/opentelemetry/OpenTelemetryTest.java @@ -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; @@ -60,14 +61,18 @@ /** 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 startedSpans = new ArrayList<>(); final Collection spans = new ArrayList<>(); - int activeSpans = 0; + volatile int activeSpans = 0; @Override public void onStart(Context parentContext, ReadWriteSpan span) { @@ -75,6 +80,7 @@ public void onStart(Context parentContext, ReadWriteSpan span) { startedSpans.add(span); ++activeSpans; + spansStarted.incrementAndGet(); lock.unlock(); } @@ -90,6 +96,7 @@ public void onEnd(ReadableSpan span) { spans.add(span); --activeSpans; + spansEnded.incrementAndGet(); if (activeSpans == 0) allEnded.signal(); @@ -148,7 +155,6 @@ private Collection 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); @@ -163,8 +169,18 @@ private Collection 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()); @@ -187,7 +203,7 @@ private Collection getChildrenOfSpans( } /** Basic test for creating spans with INSERT statement. */ - @Test(groups = "short") + // @Test(groups = "short") public void simpleTracingInsertTest() { final Collection spans = collectSpans( @@ -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 spans = collectSpans( @@ -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 spans = collectSpans( @@ -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 spans = collectSpans( @@ -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(); @@ -730,6 +747,7 @@ public void simpleTracingSelectTest() { boolean wasNoMorePages = false; int totalRows = 0; + List rowsCounts = new ArrayList<>(); for (ReadableSpan requestSpan : requestSpans) { SpanData spanData = requestSpan.toSpanData(); @@ -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( @@ -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"))); @@ -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) @@ -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 spans = collectSpans(