Skip to content

Commit

Permalink
sigint ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubwro committed Jan 27, 2024
1 parent 5068420 commit ba630e6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/sigint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 20 additions & 10 deletions test/sigint.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NATS
using Random

@show getpid()
Base.exit_on_sigint(false)

function sigint_current_process()
Expand All @@ -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
Expand All @@ -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."
Expand Down
7 changes: 7 additions & 0 deletions test/sigint_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


JULIA_DEBUG=NATS julia --project test/sigint.jl &
JL_PROCESS_PID=$!
sleep 10
kill -2 $JL_PROCESS_PID
sleep 5

0 comments on commit ba630e6

Please sign in to comment.