From ba630e66b5063e1675816d54121aa94eaa19032a Mon Sep 17 00:00:00 2001 From: Jakub Wronowski Date: Sat, 27 Jan 2024 18:04:44 +0100 Subject: [PATCH] sigint ci --- .github/workflows/sigint.yml | 7 ++++--- test/sigint.jl | 30 ++++++++++++++++++++---------- test/sigint_test.sh | 7 +++++++ 3 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 test/sigint_test.sh diff --git a/.github/workflows/sigint.yml b/.github/workflows/sigint.yml index f4753291..3b187e57 100644 --- a/.github/workflows/sigint.yml +++ b/.github/workflows/sigint.yml @@ -35,9 +35,10 @@ jobs: arch: ${{ matrix.julia-arch }} - run: | julia --project -e 'using Pkg; Pkg.instantiate()' - JULIA_DEBUG=NATS JULIA_NUM_THREADS=${{ matrix.julia-num-threads }} julia --color=yes --code-coverage=user --project test/sigint.jl - JULIA_DEBUG=NATS JULIA_NUM_THREADS=${{ matrix.julia-num-threads }} julia --color=yes --code-coverage=user --project test/sigint_handler_on_wrong_thread.jl - JULIA_DEBUG=NATS JULIA_NUM_THREADS=${{ matrix.julia-num-threads }} julia -i --color=yes --code-coverage=user --project < test/sigint_handler_repl.jl + bash ./test/sigint_test.sh + # JULIA_DEBUG=NATS JULIA_NUM_THREADS=${{ matrix.julia-num-threads }} julia --color=yes --code-coverage=user --project test/sigint.jl + # JULIA_DEBUG=NATS JULIA_NUM_THREADS=${{ matrix.julia-num-threads }} julia --color=yes --code-coverage=user --project test/sigint_handler_on_wrong_thread.jl + # JULIA_DEBUG=NATS JULIA_NUM_THREADS=${{ matrix.julia-num-threads }} julia -i --color=yes --code-coverage=user --project < test/sigint_handler_repl.jl - uses: julia-actions/julia-processcoverage@v1 # annotate: true - name: Upload coverage reports to Codecov diff --git a/test/sigint.jl b/test/sigint.jl index 2fa3897b..6dc8866e 100644 --- a/test/sigint.jl +++ b/test/sigint.jl @@ -1,6 +1,7 @@ using NATS using Random +@show getpid() Base.exit_on_sigint(false) function sigint_current_process() @@ -19,9 +20,10 @@ function run_test() end sleep(0.5) - pub_task = Threads.@spawn begin - for i in 1:10000 - timer = Timer(0.001) + pub_task = Threads.@spawn disable_sigint() do + Base.sigatomic_begin() + for i in 1:1000 + timer = Timer(0.01) for _ in 1:10 publish(connection, subject, "Hi!") end @@ -30,21 +32,29 @@ function run_test() end @info "Publisher finished." end + # errormonitor(pub_task) sleep(2) @info "Published: $(published_count.value), received: $(received_count.value)." - @info "Sending SIGINT" - sigint_current_process() - try wait(pub_task) catch end - @info "Published: $(published_count.value), received: $(received_count.value)." sleep(2) end -t = Threads.@spawn :default run_test() +t = Threads.@spawn :default disable_sigint() do + Base.sigatomic_begin() + run_test() +end +errormonitor(t) + +try + while true + sleep(0.2) + end +catch err + @error err +end +drain(NATS.connection(1)) -wait(t) -sleep(5) NATS.status() if NATS.status(NATS.connection(1)) == NATS.DRAINED @info "Test passed correctly." diff --git a/test/sigint_test.sh b/test/sigint_test.sh new file mode 100644 index 00000000..c7caa75d --- /dev/null +++ b/test/sigint_test.sh @@ -0,0 +1,7 @@ + + +JULIA_DEBUG=NATS julia --project test/sigint.jl & +JL_PROCESS_PID=$! +sleep 10 +kill -2 $JL_PROCESS_PID +sleep 5 \ No newline at end of file