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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
require_relative "toxbank-setup.rb"
begin
puts "Service URI is: #{$investigation[:uri]}"
rescue
puts "Configuration Error: $investigation[:uri] is not defined in: " + File.join(ENV["HOME"],".opentox","config","test.rb")
exit
end
class StressTest < MiniTest::Test
def self.test_order
:sorted
end
# Do multiple POST and check if completed
def test_01_multiple_upload
file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "BII-I-1b-tb2.zip"
response = []; task_uri = []; task =[]
(0..2).each do |i|
response[i] = OpenTox::RestClientWrapper.post $investigation[:uri], {:file => File.open(file)}, { :subjectid => $pi[:subjectid] }
task_uri[i] = response[i].chomp
task[i] = OpenTox::Task.new task_uri[i]
end
(0..2).each do |i|
task[i].wait
assert_equal true, task[i].completed?
assert_equal "Completed", task[i].hasStatus
result = OpenTox::RestClientWrapper.delete task[i].resultURI.to_s, {}, {:subjectid => $pi[:subjectid]}
assert_equal 200, result.code
end
end
# Creates investigation for later Update
def test_02a_pre_multiple_updates
@@uri = ""
file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "BII-I-1b-tb2.zip"
response = OpenTox::RestClientWrapper.post $investigation[:uri], {:file => File.open(file)}, { :subjectid => $pi[:subjectid] }
task_uri = response.chomp
task = OpenTox::Task.new task_uri
task.wait
uri = task.resultURI
@@uri = URI(uri)
end
# Do multipe update on existing investigation
def test_02b_multiple_updates
file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "BII-I-1-tb2.zip"
response = []; task_uri = []; task =[]
response[0] = OpenTox::RestClientWrapper.put "#{@@uri}", {:file => File.open(file)}, { :subjectid => $pi[:subjectid] }
assert_equal 202, response[0].code
task_uri[0] = response[0].chomp
(1..2).each do |i|
response[i] = OpenTox::RestClientWrapper.put "#{@@uri}", {:file => File.open(file)}, { :subjectid => $pi[:subjectid] }
task_uri[i] = response[i].chomp
end
(1..2).each do |i|
#assert_raise OpenTox::LockedError do
task[i] = OpenTox::Task.new task_uri[i]
task[i].wait
#end
assert_equal false, task[i].completed?
assert_equal "Error", task[i].hasStatus
end
task[0] = OpenTox::Task.new task_uri[0]
task[0].wait
assert_equal true, task[0].completed?
assert_equal "Completed", task[0].hasStatus
end
# Delete Test-investigation
def test_98_delete_investigation
result = OpenTox::RestClientWrapper.delete @@uri.to_s, {}, {:subjectid => $pi[:subjectid]}
assert_equal 200, result.code
end
end
|