diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa72fb06b6..510f182138 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,4 +61,12 @@ jobs: with: go-version: ${{ matrix.go-version }} - name: Run Tests + id: run-tests run: make test GO_VERSION=${{ matrix.go-version }} + - name: Upload logs on failure + if: failure() && steps.run-tests.outcome == 'failure' + uses: actions/upload-artifact@v4 + with: + name: test-logs-${{ matrix.go-version }} + path: logs/ + retention-days: 7 diff --git a/Makefile b/Makefile index 4ff147c8aa..3ade7200d8 100644 --- a/Makefile +++ b/Makefile @@ -61,23 +61,23 @@ container: test: container test_standalone test_clustered test_extensible_load_manager test_standalone: container - docker run -v /var/run/docker.sock:/var/run/docker.sock ${DOCKER_TEST_ARGS} bash -c "cd /pulsar/pulsar-client-go && ./scripts/run-ci.sh" + docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(shell pwd)/logs:/pulsar/logs ${DOCKER_TEST_ARGS} bash -c "cd /pulsar/pulsar-client-go && ./scripts/run-ci.sh" test_clustered: container PULSAR_VERSION=${PULSAR_VERSION} docker compose -f integration-tests/clustered/docker-compose.yml up -d until curl http://localhost:8080/metrics > /dev/null 2>&1; do sleep 1; done - docker run --network=clustered_pulsar ${DOCKER_TEST_ARGS} bash -c "cd /pulsar/pulsar-client-go && ./scripts/run-ci-clustered.sh" + docker run --network=clustered_pulsar -v $(shell pwd)/logs:/pulsar/logs ${DOCKER_TEST_ARGS} bash -c "cd /pulsar/pulsar-client-go && ./scripts/run-ci-clustered.sh" PULSAR_VERSION=${PULSAR_VERSION} docker compose -f integration-tests/clustered/docker-compose.yml down test_extensible_load_manager: container PULSAR_VERSION=${PULSAR_VERSION} docker compose -f integration-tests/extensible-load-manager/docker-compose.yml up -d until curl http://localhost:8080/metrics > /dev/null 2>&1; do sleep 1; done - docker run --network=extensible-load-manager_pulsar ${DOCKER_TEST_ARGS} bash -c "cd /pulsar/pulsar-client-go && ./scripts/run-ci-extensible-load-manager.sh" + docker run --network=extensible-load-manager_pulsar -v $(shell pwd)/logs:/pulsar/logs ${DOCKER_TEST_ARGS} bash -c "cd /pulsar/pulsar-client-go && ./scripts/run-ci-extensible-load-manager.sh" PULSAR_VERSION=${PULSAR_VERSION} docker compose -f integration-tests/blue-green/docker-compose.yml up -d until curl http://localhost:8081/metrics > /dev/null 2>&1 ; do sleep 1; done - docker run --network=extensible-load-manager_pulsar ${DOCKER_TEST_ARGS} bash -c "cd /pulsar/pulsar-client-go && ./scripts/run-ci-blue-green-cluster.sh" + docker run --network=extensible-load-manager_pulsar -v $(shell pwd)/logs:/pulsar/logs ${DOCKER_TEST_ARGS} bash -c "cd /pulsar/pulsar-client-go && ./scripts/run-ci-blue-green-cluster.sh" PULSAR_VERSION=${PULSAR_VERSION} docker compose -f integration-tests/blue-green/docker-compose.yml down PULSAR_VERSION=${PULSAR_VERSION} docker compose -f integration-tests/extensible-load-manager/docker-compose.yml down diff --git a/pulsar/reader_test.go b/pulsar/reader_test.go index 2fbe89e458..40ed20efd3 100644 --- a/pulsar/reader_test.go +++ b/pulsar/reader_test.go @@ -1029,8 +1029,8 @@ func TestReaderHasNextRetryFailed(t *testing.T) { close(req.doneCh) } }() - minTimer := time.NewTimer(1 * time.Second) // Timer to check if r.HasNext() blocked for at least 1s - maxTimer := time.NewTimer(3 * time.Second) // Timer to ensure r.HasNext() doesn't block for more than 3s + maxTimer := time.NewTimer(8 * time.Second) // Timer to ensure r.HasNext() doesn't block for more than 3s + startTime := time.Now().UnixMilli() done := make(chan bool) go func() { assert.False(t, r.HasNext()) @@ -1041,8 +1041,10 @@ func TestReaderHasNextRetryFailed(t *testing.T) { case <-maxTimer.C: t.Fatal("r.HasNext() blocked for more than 3s") case <-done: - assert.False(t, minTimer.Stop(), "r.HasNext() did not block for at least 1s") - assert.True(t, maxTimer.Stop()) + now := time.Now().UnixMilli() + if now-startTime < 1000 { + t.Fatal("r.HasNext() blocked for less than 1s") + } } } diff --git a/scripts/run-ci-blue-green-cluster.sh b/scripts/run-ci-blue-green-cluster.sh index 8c886db3d3..21f0e97bc6 100755 --- a/scripts/run-ci-blue-green-cluster.sh +++ b/scripts/run-ci-blue-green-cluster.sh @@ -17,6 +17,7 @@ # under the License. set -x +set -o pipefail TEST_LOG=/tmp/test-log-$(date +%s).log diff --git a/scripts/run-ci-clustered.sh b/scripts/run-ci-clustered.sh index a1a0764d93..d20ed41614 100755 --- a/scripts/run-ci-clustered.sh +++ b/scripts/run-ci-clustered.sh @@ -17,6 +17,7 @@ # under the License. set -x +set -o pipefail TEST_LOG=/tmp/test-log-$(date +%s).log diff --git a/scripts/run-ci-extensible-load-manager.sh b/scripts/run-ci-extensible-load-manager.sh index 714bb4db1b..3f18d94a45 100755 --- a/scripts/run-ci-extensible-load-manager.sh +++ b/scripts/run-ci-extensible-load-manager.sh @@ -17,6 +17,7 @@ # under the License. set -x +set -o pipefail TEST_LOG=/tmp/test-log-$(date +%s).log diff --git a/scripts/run-ci.sh b/scripts/run-ci.sh index d7ef2effdd..2058aa1bb0 100755 --- a/scripts/run-ci.sh +++ b/scripts/run-ci.sh @@ -18,6 +18,7 @@ set -x +set -o pipefail scripts/pulsar-test-service-start.sh