Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
levb committed Oct 21, 2024
1 parent 3c1c949 commit fe7aebf
Show file tree
Hide file tree
Showing 10 changed files with 400 additions and 382 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ jobs:
export PATH=../deps/nats-server:../deps/nats-streaming-server:$PATH
export NATS_TEST_SERVER_VERSION="$(nats-server -v)"
flags=""
ctest -L 'test' --timeout 60 --output-on-failure --repeat-until-fail ${{ inputs.repeat }}
ctest -R '^Micro' --timeout 60 --output-on-failure --repeat-until-fail 20 # ${{ inputs.repeat }}
# ctest -L 'test' --timeout 60 --output-on-failure --repeat-until-fail ${{ inputs.repeat }}
- name: Upload coverage reports to Codecov
# PRs from external contributors fail: https://github.com/codecov/feedback/issues/301
Expand Down
240 changes: 120 additions & 120 deletions .github/workflows/on-pr-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ permissions:
contents: write # so it can comment

jobs:
Ubuntu:
name: "Ubuntu"
strategy:
fail-fast: false
matrix:
compiler: [gcc, clang]
uses: ./.github/workflows/build-test.yml
with:
compiler: ${{ matrix.compiler }}
server_version: main
type: Debug
# Ubuntu:
# name: "Ubuntu"
# strategy:
# fail-fast: false
# matrix:
# compiler: [gcc, clang]
# uses: ./.github/workflows/build-test.yml
# with:
# compiler: ${{ matrix.compiler }}
# server_version: main
# type: Debug

dev-mode:
name: "DEV_MODE"
uses: ./.github/workflows/build-test.yml
with:
dev_mode: ON
server_version: main
type: Debug
verbose_test_output: ON
verbose_make_output: ON
# dev-mode:
# name: "DEV_MODE"
# uses: ./.github/workflows/build-test.yml
# with:
# dev_mode: ON
# server_version: main
# type: Debug
# verbose_test_output: ON
# verbose_make_output: ON

sanitize:
name: "Sanitize"
Expand All @@ -44,110 +44,110 @@ jobs:
sanitize: ${{ matrix.sanitize }}
pool_dispatch: ${{ matrix.pooled_dispatch }}

coverage-TLS:
name: "Coverage: TLS"
strategy:
fail-fast: false
matrix:
pooled_dispatch: [pool, NO-pool]
write_deadline: [write_deadline, NO-write_deadline]
uses: ./.github/workflows/build-test.yml
with:
coverage: ON
type: RelWithDebInfo
server_version: main
compiler: gcc
tls: TLS
verify_host: verify_host
pool_dispatch: ${{ matrix.pooled_dispatch }}
write_deadline: ${{ matrix.write_deadline }}
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# coverage-TLS:
# name: "Coverage: TLS"
# strategy:
# fail-fast: false
# matrix:
# pooled_dispatch: [pool, NO-pool]
# write_deadline: [write_deadline, NO-write_deadline]
# uses: ./.github/workflows/build-test.yml
# with:
# coverage: ON
# type: RelWithDebInfo
# server_version: main
# compiler: gcc
# tls: TLS
# verify_host: verify_host
# pool_dispatch: ${{ matrix.pooled_dispatch }}
# write_deadline: ${{ matrix.write_deadline }}
# secrets:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

coverage-NO-verify_host:
name: "Coverage: NO-verify_host"
uses: ./.github/workflows/build-test.yml
with:
coverage: ON
type: RelWithDebInfo
server_version: main
compiler: gcc
tls: TLS
verify_host: NO-verify_host
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# coverage-NO-verify_host:
# name: "Coverage: NO-verify_host"
# uses: ./.github/workflows/build-test.yml
# with:
# coverage: ON
# type: RelWithDebInfo
# server_version: main
# compiler: gcc
# tls: TLS
# verify_host: NO-verify_host
# secrets:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

coverage-NO-TLS:
name: "Coverage NO-TLS"
uses: ./.github/workflows/build-test.yml
with:
coverage: ON
type: RelWithDebInfo
server_version: main
compiler: gcc
tls: NO-TLS
verify_host: NO-verify_host
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# coverage-NO-TLS:
# name: "Coverage NO-TLS"
# uses: ./.github/workflows/build-test.yml
# with:
# coverage: ON
# type: RelWithDebInfo
# server_version: main
# compiler: gcc
# tls: NO-TLS
# verify_host: NO-verify_host
# secrets:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

bench:
name: "Benchmark"
uses: ./.github/workflows/build-test.yml
with:
server_version: main
benchmark: ON
type: Release
# bench:
# name: "Benchmark"
# uses: ./.github/workflows/build-test.yml
# with:
# server_version: main
# benchmark: ON
# type: Release

Windows:
name: "Windows"
runs-on: windows-latest
steps:
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
# Windows:
# name: "Windows"
# runs-on: windows-latest
# steps:
# - name: Export GitHub Actions cache environment variables
# uses: actions/github-script@v7
# with:
# script: |
# core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
# core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

- name: Checkout nats.c
uses: actions/checkout@v4
# - name: Checkout nats.c
# uses: actions/checkout@v4

- name: Build
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
run: |
cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug -DNATS_BUILD_STREAMING=OFF
cmake --build build
# - name: Build
# env:
# VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
# run: |
# cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug -DNATS_BUILD_STREAMING=OFF
# cmake --build build

- name: Test
shell: bash
run: |
cd build
# Download latest nats-server
rel="latest" # TODO: parameterize
if [ "$rel" = "latest" ]; then
rel=$(curl -s https://api.github.com/repos/nats-io/nats-server/releases/latest | jq -r '.tag_name')
fi
if [ "$rel" != "${rel#v}" ] && wget https://github.com/nats-io/nats-server/releases/download/$rel/nats-server-$rel-windows-amd64.tar.gz; then
tar -xzf nats-server-$rel-linux-amd64.tar.gz
cp nats-server-$rel-windows-amd64/nats-server.exe ../deps/nats-server/nats-server.exe
else
for c in 1 2 3 4 5
do
echo "Attempt $c to download binary for main"
rm -f ./nats-server
curl -sf "https://binaries.nats.dev/nats-io/nats-server/v2@$rel" | PREFIX=. sh
# We are sometimes getting nats-server of size 0. Make sure we have a
# working nats-server by making sure we get a version number.
mv ./nats-server ./nats-server.exe
v="$(./nats-server.exe -v)"
if [ "$v" != "" ]; then
break
fi
done
mkdir -p ../deps/nats-server
mv ./nats-server.exe ../deps/nats-server/nats-server.exe
fi
export PATH=../deps/nats-server:$PATH
export NATS_TEST_SERVER_VERSION="$(nats-server -v)"
ctest -L test -C Debug --timeout 60 --output-on-failure --repeat until-pass:3
# - name: Test
# shell: bash
# run: |
# cd build
# # Download latest nats-server
# rel="latest" # TODO: parameterize
# if [ "$rel" = "latest" ]; then
# rel=$(curl -s https://api.github.com/repos/nats-io/nats-server/releases/latest | jq -r '.tag_name')
# fi
# if [ "$rel" != "${rel#v}" ] && wget https://github.com/nats-io/nats-server/releases/download/$rel/nats-server-$rel-windows-amd64.tar.gz; then
# tar -xzf nats-server-$rel-linux-amd64.tar.gz
# cp nats-server-$rel-windows-amd64/nats-server.exe ../deps/nats-server/nats-server.exe
# else
# for c in 1 2 3 4 5
# do
# echo "Attempt $c to download binary for main"
# rm -f ./nats-server
# curl -sf "https://binaries.nats.dev/nats-io/nats-server/v2@$rel" | PREFIX=. sh
# # We are sometimes getting nats-server of size 0. Make sure we have a
# # working nats-server by making sure we get a version number.
# mv ./nats-server ./nats-server.exe
# v="$(./nats-server.exe -v)"
# if [ "$v" != "" ]; then
# break
# fi
# done
# mkdir -p ../deps/nats-server
# mv ./nats-server.exe ../deps/nats-server/nats-server.exe
# fi
# export PATH=../deps/nats-server:$PATH
# export NATS_TEST_SERVER_VERSION="$(nats-server -v)"
# ctest -L test -C Debug --timeout 60 --output-on-failure --repeat until-pass:3
42 changes: 21 additions & 21 deletions .github/workflows/on-push-release.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
name: "Release"
on:
push:
# name: "Release"
# on:
# push:

permissions:
contents: write # required by build-test to comment on coverage but not used here.
# permissions:
# contents: write # required by build-test to comment on coverage but not used here.

defaults:
run:
shell: bash --noprofile --norc -x -eo pipefail {0}
# defaults:
# run:
# shell: bash --noprofile --norc -x -eo pipefail {0}

jobs:
quick:
name: "Ubuntu"
strategy:
fail-fast: false
matrix:
compiler: [gcc, clang]
ubuntu_version: [latest, 20.04]
uses: ./.github/workflows/build-test.yml
with:
server_version: main
ubuntu_version: ${{ matrix.ubuntu_version }}
compiler: ${{ matrix.compiler }}
# jobs:
# quick:
# name: "Ubuntu"
# strategy:
# fail-fast: false
# matrix:
# compiler: [gcc, clang]
# ubuntu_version: [latest, 20.04]
# uses: ./.github/workflows/build-test.yml
# with:
# server_version: main
# ubuntu_version: ${{ matrix.ubuntu_version }}
# compiler: ${{ matrix.compiler }}
3 changes: 3 additions & 0 deletions src/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -2506,6 +2506,8 @@ _removeAllSubscriptions(natsConnection *nc)
}
natsHashIter_Done(&iter);
natsMutex_Unlock(nc->subsMu);

printf("<>/<> removeAllSubscriptions\n");
}

// Low level close call that will do correct cleanup and set
Expand Down Expand Up @@ -2986,6 +2988,7 @@ natsConn_removeSubscription(natsConnection *nc, natsSubscription *removedSub)
natsSub_close(sub, false);

natsMutex_Unlock(nc->subsMu);
nats_Sleep(1); // <>/<>

// If we really removed the subscription, then release it.
if (sub != NULL)
Expand Down
8 changes: 8 additions & 0 deletions src/dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,11 @@ nats_dispatchThreadPool(void *arg)
}

if (completeCB != NULL)
{
nats_Sleep(100);
printf("<>/<> completeCB (pool) on %s\n", sub->subject); fflush(stdout);
(*completeCB)(completeCBClosure);
}

// Subscription closed, just release
natsSub_release(sub);
Expand Down Expand Up @@ -586,7 +590,11 @@ nats_dispatchThreadOwn(void *arg)
}

if (completeCB != NULL)
{
nats_Sleep(100);
printf("<>/<> completeCB on %s\n", sub->subject); fflush(stdout);
(*completeCB)(completeCBClosure);
}

natsSub_release(sub);
}
Loading

0 comments on commit fe7aebf

Please sign in to comment.