File: fork_safety_test.rb

package info (click to toggle)
ruby-redis 5.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,168 kB
  • sloc: ruby: 11,501; makefile: 117; sh: 24
file content (25 lines) | stat: -rw-r--r-- 505 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

require "helper"

class TestForkSafety < Minitest::Test
  include Helper::Client

  def setup
    skip("Fork unavailable") unless Process.respond_to?(:fork)
  end

  def test_fork_safety
    redis = Redis.new(OPTIONS)
    pid = fork do
      1000.times do
        assert_equal "OK", redis.set("key", "foo")
      end
    end
    1000.times do
      assert_equal "PONG", redis.ping
    end
    _, status = Process.wait2(pid)
    assert_predicate(status, :success?)
  end
end