This loads up 1000 test strands into the test database. The prog executed performs CPU work, IO work, semaphore setting, napping, and hopping. The test then runs respirate in the test environment, and waits until all strands have been processed. To pass, the test needs to finish within 30 seconds. Actual finish is in around 14-16 seconds on my machine (varies due to randomness).
18 lines
522 B
Ruby
18 lines
522 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "../spec_helper"
|
|
|
|
RSpec.describe Prog::Test do
|
|
let(:strand) { Strand.create(prog: "Test", label: "smoke_test_1") }
|
|
|
|
let(:prog) { described_class.new(strand) }
|
|
|
|
it "smoke_test_1 naps, then hops to smoke_test_0" do
|
|
expect(prog).to receive(:rand).and_return(2).thrice
|
|
expect(prog).to receive(:print).with(1)
|
|
expect { prog.smoke_test_1 }.to nap(2)
|
|
expect { prog.smoke_test_1 }.to hop("smoke_test_0")
|
|
expect { prog.smoke_test_0 }.to nap(1000)
|
|
end
|
|
end
|