t2-server 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,128 +1,66 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ # Copyright (c) 2010-2014 The University of Manchester, UK.
2
+ #
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright notice,
9
+ # this list of conditions and the following disclaimer.
10
+ #
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # * Neither the names of The University of Manchester nor the names of its
16
+ # contributors may be used to endorse or promote products derived from this
17
+ # software without specific prior written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
+ # POSSIBILITY OF SUCH DAMAGE.
30
+ #
31
+ # Author: Robert Haines
5
32
 
6
- Gem::Specification.new do |s|
7
- s.name = "t2-server"
8
- s.version = "1.0.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Robert Haines", "Finn Bacall"]
12
- s.date = "2013-11-05"
13
- s.description = "This gem provides access to the Taverna 2 Server REST interface from Ruby."
14
- s.email = ["support@mygrid.org.uk"]
15
- s.executables = ["t2-delete-runs", "t2-run-workflow", "t2-server-info", "t2-get-output", "t2-server-admin"]
16
- s.extra_rdoc_files = [
17
- "CHANGES.rdoc",
18
- "LICENCE.rdoc",
19
- "README.rdoc"
20
- ]
21
- s.files = [
22
- "CHANGES.rdoc",
23
- "LICENCE.rdoc",
24
- "README.rdoc",
25
- "Rakefile",
26
- "bin/t2-delete-runs",
27
- "bin/t2-get-output",
28
- "bin/t2-run-workflow",
29
- "bin/t2-server-admin",
30
- "bin/t2-server-info",
31
- "extras/t2-server-stress",
32
- "lib/t2-server-cli.rb",
33
- "lib/t2-server.rb",
34
- "lib/t2-server/admin.rb",
35
- "lib/t2-server/exceptions.rb",
36
- "lib/t2-server/interaction.rb",
37
- "lib/t2-server/net/connection.rb",
38
- "lib/t2-server/net/credentials.rb",
39
- "lib/t2-server/net/parameters.rb",
40
- "lib/t2-server/port.rb",
41
- "lib/t2-server/run-cache.rb",
42
- "lib/t2-server/run.rb",
43
- "lib/t2-server/server.rb",
44
- "lib/t2-server/util.rb",
45
- "lib/t2-server/xml/libxml.rb",
46
- "lib/t2-server/xml/nokogiri.rb",
47
- "lib/t2-server/xml/rexml.rb",
48
- "lib/t2-server/xml/xml.rb",
49
- "lib/t2-server/xml/xpath_cache.rb",
50
- "t2-server.gemspec",
51
- "test/tc_admin.rb",
52
- "test/tc_misc.rb",
53
- "test/tc_params.rb",
54
- "test/tc_perms.rb",
55
- "test/tc_run.rb",
56
- "test/tc_secure.rb",
57
- "test/tc_server.rb",
58
- "test/tc_util.rb",
59
- "test/ts_t2server.rb",
60
- "test/workflows/always_fail.t2flow",
61
- "test/workflows/empty_list.t2flow",
62
- "test/workflows/empty_list_input.baclava",
63
- "test/workflows/in.txt",
64
- "test/workflows/list_and_value.t2flow",
65
- "test/workflows/list_with_errors.t2flow",
66
- "test/workflows/missing_outputs.t2flow",
67
- "test/workflows/no-ports.t2flow",
68
- "test/workflows/pass_through.t2flow",
69
- "test/workflows/secure/basic-http.t2flow",
70
- "test/workflows/secure/basic-https.t2flow",
71
- "test/workflows/secure/client-https.t2flow",
72
- "test/workflows/secure/digest-http.t2flow",
73
- "test/workflows/secure/digest-https.t2flow",
74
- "test/workflows/secure/heater-pk.pem",
75
- "test/workflows/secure/user-cert.p12",
76
- "test/workflows/secure/ws-http.t2flow",
77
- "test/workflows/secure/ws-https.t2flow",
78
- "test/workflows/strings.txt",
79
- "test/workflows/xml_xpath.t2flow",
80
- "version.yml"
81
- ]
82
- s.homepage = "http://www.taverna.org.uk/"
83
- s.rdoc_options = ["-N", "--tab-width=2", "--main=README.rdoc"]
84
- s.require_paths = ["lib"]
85
- s.rubygems_version = "1.8.21"
86
- s.summary = "Support for interacting with Taverna 2 Server."
87
- s.test_files = ["test/ts_t2server.rb"]
88
-
89
- if s.respond_to? :specification_version then
90
- s.specification_version = 3
33
+ lib = File.expand_path('../lib', __FILE__)
34
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
35
+ require "t2-server/version"
91
36
 
92
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
93
- s.add_development_dependency(%q<rake>, ["~> 0.9.2"])
94
- s.add_development_dependency(%q<libxml-ruby>, [">= 1.1.4"])
95
- s.add_development_dependency(%q<nokogiri>, [">= 1.5.0"])
96
- s.add_development_dependency(%q<rdoc>, [">= 3.9.4"])
97
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
98
- s.add_development_dependency(%q<launchy>, ["~> 2.2.0"])
99
- s.add_runtime_dependency(%q<net-http-persistent>, ["~> 2.6"])
100
- s.add_runtime_dependency(%q<taverna-baclava>, ["~> 1.0.0"])
101
- s.add_runtime_dependency(%q<ratom>, ["~> 0.8.2"])
102
- s.add_runtime_dependency(%q<hirb>, [">= 0.4.0"])
103
- else
104
- s.add_dependency(%q<rake>, ["~> 0.9.2"])
105
- s.add_dependency(%q<libxml-ruby>, [">= 1.1.4"])
106
- s.add_dependency(%q<nokogiri>, [">= 1.5.0"])
107
- s.add_dependency(%q<rdoc>, [">= 3.9.4"])
108
- s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
109
- s.add_dependency(%q<launchy>, ["~> 2.2.0"])
110
- s.add_dependency(%q<net-http-persistent>, ["~> 2.6"])
111
- s.add_dependency(%q<taverna-baclava>, ["~> 1.0.0"])
112
- s.add_dependency(%q<ratom>, ["~> 0.8.2"])
113
- s.add_dependency(%q<hirb>, [">= 0.4.0"])
114
- end
115
- else
116
- s.add_dependency(%q<rake>, ["~> 0.9.2"])
117
- s.add_dependency(%q<libxml-ruby>, [">= 1.1.4"])
118
- s.add_dependency(%q<nokogiri>, [">= 1.5.0"])
119
- s.add_dependency(%q<rdoc>, [">= 3.9.4"])
120
- s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
121
- s.add_dependency(%q<launchy>, ["~> 2.2.0"])
122
- s.add_dependency(%q<net-http-persistent>, ["~> 2.6"])
123
- s.add_dependency(%q<taverna-baclava>, ["~> 1.0.0"])
124
- s.add_dependency(%q<ratom>, ["~> 0.8.2"])
125
- s.add_dependency(%q<hirb>, [">= 0.4.0"])
126
- end
37
+ Gem::Specification.new do |s|
38
+ s.name = "t2-server"
39
+ s.version = T2Server::Version::STRING
40
+ s.authors = ["Robert Haines", "Finn Bacall"]
41
+ s.email = ["support@mygrid.org.uk"]
42
+ s.homepage = "http://www.taverna.org.uk/"
43
+ s.platform = Gem::Platform::RUBY
44
+ s.summary = "Support for interacting with Taverna 2 Server."
45
+ s.description = "This gem provides access to the Taverna 2 Server " +
46
+ "REST interface from Ruby."
47
+ s.license = "BSD"
48
+ s.require_path = "lib"
49
+ s.bindir = "bin"
50
+ s.files = `git ls-files`.split($/)
51
+ s.executables = ["t2-delete-runs", "t2-run-workflow", "t2-server-info",
52
+ "t2-get-output", "t2-server-admin"]
53
+ s.test_file = "test/ts_t2server.rb"
54
+ s.has_rdoc = true
55
+ s.extra_rdoc_files = ["README.rdoc", "LICENCE.rdoc", "CHANGES.rdoc"]
56
+ s.rdoc_options = ["-N", "--tab-width=2", "--main=README.rdoc"]
57
+ s.add_development_dependency('rake', '~> 10.0')
58
+ s.add_development_dependency('bundler', '~> 1.5')
59
+ s.add_development_dependency('rdoc', '~> 4.1')
60
+ s.add_development_dependency('launchy', '~> 2.2')
61
+ s.add_development_dependency('hirb', '~> 0.7')
62
+ s.add_runtime_dependency('net-http-persistent', '~> 2.6')
63
+ s.add_runtime_dependency('taverna-baclava', '~> 1.0')
64
+ s.add_runtime_dependency('ratom', '~> 0.8.2')
65
+ s.add_runtime_dependency('libxml-ruby', '~> 2.6')
127
66
  end
128
-
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2010-2012 The University of Manchester, UK.
1
+ # Copyright (c) 2010-2014 The University of Manchester, UK.
2
2
  #
3
3
  # All rights reserved.
4
4
  #
@@ -124,10 +124,8 @@ class TestRun < Test::Unit::TestCase
124
124
  # Test run naming. This is different for different versions of server.
125
125
  def test_run_naming
126
126
  T2Server::Server.new($uri, $conn_params) do |server|
127
- vc = server.version_components
128
- v250plus = vc[0] > 2 || (vc[0] == 2 && vc[1] >= 5)
129
127
  server.create_run($wkf_no_io, $creds) do |run|
130
- if v250plus
128
+ if server.version >= "2.5.0"
131
129
  # Read initial name.
132
130
  assert(run.name.length > 0)
133
131
  assert_equal("Workflow1", run.name[0...9])
@@ -202,7 +200,7 @@ class TestRun < Test::Unit::TestCase
202
200
  end
203
201
  end
204
202
 
205
- # Test run with a list and file input
203
+ # Test run with a list and file input, and check that provenance is not on
206
204
  def test_run_list_and_file
207
205
  T2Server::Run.create($uri, $wkf_l_v, $creds, $conn_params) do |run|
208
206
  list = ["one", 2, :three]
@@ -228,6 +226,10 @@ class TestRun < Test::Unit::TestCase
228
226
  assert_not_equal(log_cache.size, 0)
229
227
  end
230
228
 
229
+ assert_raise(T2Server::AccessForbiddenError) do
230
+ run.provenance
231
+ end
232
+
231
233
  assert(run.delete)
232
234
  end
233
235
  end
@@ -245,7 +247,8 @@ class TestRun < Test::Unit::TestCase
245
247
  end
246
248
  end
247
249
 
248
- # Test run with file input. Also pass workflow as File object.
250
+ # Test run with file input. Also pass workflow as File object. Also test
251
+ # toggling provenance on and then off again.
249
252
  def test_run_file_input
250
253
  workflow = File.open($wkf_pass, "r")
251
254
 
@@ -253,12 +256,20 @@ class TestRun < Test::Unit::TestCase
253
256
 
254
257
  assert_nothing_raised(T2Server::AttributeNotFoundError) do
255
258
  run.input_port("IN").file = $file_input
259
+ run.generate_provenance
260
+ run.generate_provenance(false)
256
261
  end
262
+ refute run.generate_provenance?
257
263
 
258
264
  run.start
259
265
  assert(run.running?)
260
266
  assert_nothing_raised(T2Server::RunStateError) { run.wait }
261
267
  assert_equal(run.output_port("OUT").value, "Hello, World!")
268
+
269
+ assert_raise(T2Server::AccessForbiddenError) do
270
+ run.provenance
271
+ end
272
+
262
273
  assert(run.delete)
263
274
  end
264
275
 
@@ -266,10 +277,18 @@ class TestRun < Test::Unit::TestCase
266
277
  end
267
278
 
268
279
  # Test run that returns list of lists, some empty, using baclava for input
280
+ # Also test provenance output works with baclava input
269
281
  def test_baclava_input
270
282
  T2Server::Run.create($uri, $wkf_lists, $creds, $conn_params) do |run|
271
283
  assert_nothing_raised(T2Server::AttributeNotFoundError) do
272
284
  run.baclava_input = $list_input
285
+ run.generate_provenance
286
+ end
287
+
288
+ if run.server.version >= "2.5.3"
289
+ assert(run.generate_provenance?)
290
+ else
291
+ refute(run.generate_provenance?)
273
292
  end
274
293
 
275
294
  assert_equal(run.input_ports.keys.sort, ["MANY_IN", "SINGLE_IN"])
@@ -291,6 +310,20 @@ class TestRun < Test::Unit::TestCase
291
310
  assert(run.output_port("MANY")[1][0][0].empty?)
292
311
  assert_equal(run.output_port("MANY")[1][0][1].value(1..3), "ell")
293
312
  assert_raise(NoMethodError) { run.output_port("SINGLE")[0].value }
313
+
314
+ # Grab provenance
315
+ if run.server.version >= "2.5.3"
316
+ assert_nothing_raised(T2Server::AccessForbiddenError) do
317
+ prov = run.provenance
318
+ assert_not_equal(prov, "")
319
+ end
320
+ else
321
+ assert_raise(T2Server::AccessForbiddenError) do
322
+ prov = run.provenance
323
+ assert_equal(prov, "")
324
+ end
325
+ end
326
+
294
327
  assert(run.delete)
295
328
  end
296
329
  end
@@ -300,9 +333,9 @@ class TestRun < Test::Unit::TestCase
300
333
  T2Server::Run.create($uri, $wkf_pass, $creds, $conn_params) do |run|
301
334
  run.input_port("IN").value = "Some input..."
302
335
  assert_nothing_raised(T2Server::AttributeNotFoundError) do
303
- run.request_baclava_output
336
+ run.generate_baclava_output
304
337
  end
305
- assert(run.baclava_output?)
338
+ assert(run.generate_baclava_output?)
306
339
 
307
340
  run.start
308
341
  assert(run.running?)
@@ -323,12 +356,19 @@ class TestRun < Test::Unit::TestCase
323
356
  end
324
357
  end
325
358
 
326
- # Test partial result download
359
+ # Test partial result download and provenance streaming
327
360
  def test_result_download
328
361
  T2Server::Run.create($uri, $wkf_pass, $creds, $conn_params) do |run|
329
362
  assert_nothing_raised(T2Server::AttributeNotFoundError) do
330
363
  file = run.upload_file($file_strs)
331
364
  run.input_port("IN").remote_file = file
365
+ run.generate_provenance(true)
366
+ end
367
+
368
+ if run.server.version >= "2.5.3"
369
+ assert(run.generate_provenance?)
370
+ else
371
+ refute(run.generate_provenance?)
332
372
  end
333
373
 
334
374
  run.start
@@ -371,6 +411,23 @@ class TestRun < Test::Unit::TestCase
371
411
  out = run.output_port("OUT").value
372
412
  assert_equal(out.length, 100)
373
413
 
414
+ # test streaming provenance data
415
+ if run.server.version >= "2.5.3"
416
+ assert_nothing_raised(T2Server::AccessForbiddenError) do
417
+ prov_cache = TestCache.new
418
+ prov_size = run.provenance(prov_cache)
419
+ assert_not_equal(prov_size, 0)
420
+ assert_not_equal(prov_cache.data, "")
421
+ end
422
+ else
423
+ assert_raise(T2Server::AccessForbiddenError) do
424
+ prov_cache = TestCache.new
425
+ prov_size = run.provenance(prov_cache)
426
+ assert_equal(prov_size, 0)
427
+ assert_equal(prov_cache.data, "")
428
+ end
429
+ end
430
+
374
431
  assert(run.delete)
375
432
  end
376
433
  end
@@ -0,0 +1,82 @@
1
+ # Copyright (c) 2014 The University of Manchester, UK.
2
+ #
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright notice,
9
+ # this list of conditions and the following disclaimer.
10
+ #
11
+ # * Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # * Neither the names of The University of Manchester nor the names of its
16
+ # contributors may be used to endorse or promote products derived from this
17
+ # software without specific prior written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
+ # POSSIBILITY OF SUCH DAMAGE.
30
+ #
31
+ # Author: Robert Haines
32
+
33
+ require 't2-server'
34
+
35
+ class TestServerVersion < Test::Unit::TestCase
36
+
37
+ TWO_FOUR = "2.4"
38
+ TWO_FOUR_ZERO = "2.4.0"
39
+ TWO_FOUR_ONE = "2.4.1"
40
+ TWO_FIVE_ZERO = "2.5.0"
41
+ TWO_FIVE_ONE = "2.5.1"
42
+
43
+ TWO_FOUR_ZERO_SNAP = "2.4.0-SNAPSHOT"
44
+ TWO_FOUR_ZERO_ALPHA = "2.4.0alpha99"
45
+
46
+ def setup
47
+ @v24 = T2Server::Server::Version.new(TWO_FOUR)
48
+ @v240 = T2Server::Server::Version.new(TWO_FOUR_ZERO)
49
+ @v241 = T2Server::Server::Version.new(TWO_FOUR_ONE)
50
+ @v250 = T2Server::Server::Version.new(TWO_FIVE_ZERO)
51
+ @v251 = T2Server::Server::Version.new(TWO_FIVE_ONE)
52
+
53
+ @v240s = T2Server::Server::Version.new(TWO_FOUR_ZERO_SNAP)
54
+ @v240a = T2Server::Server::Version.new(TWO_FOUR_ZERO_ALPHA)
55
+ end
56
+
57
+ def test_version_parsing
58
+ assert_equal TWO_FOUR_ZERO, @v24.to_s
59
+ assert_equal TWO_FOUR_ZERO, @v240.to_s
60
+ assert_equal TWO_FOUR_ZERO, @v240s.to_s
61
+ assert_equal TWO_FOUR_ZERO, @v240a.to_s
62
+ assert_equal @v24.to_s, @v240.to_s
63
+ end
64
+
65
+ def test_version_comparison
66
+ assert @v24 == @v240
67
+ assert @v240 < @v250
68
+ assert @v240 < @v241
69
+ assert @v251 > @v241
70
+ assert @v251 > @v250
71
+ end
72
+
73
+ def test_version_components
74
+ assert_equal [2, 4, 0], @v24.to_a
75
+ assert_equal [2, 4, 0], @v240.to_a
76
+ assert_equal [2, 5, 0], @v250.to_a
77
+
78
+ assert_equal [2, 4, 0], @v240s.to_a
79
+ assert_equal [2, 4, 0], @v240a.to_a
80
+ end
81
+
82
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2010-2013 The University of Manchester, UK.
1
+ # Copyright (c) 2010-2014 The University of Manchester, UK.
2
2
  #
3
3
  # All rights reserved.
4
4
  #
@@ -53,8 +53,8 @@ if ARGV.size != 0
53
53
 
54
54
  # Clear the commandline arguments so that we don't confuse runit.
55
55
  ARGV.clear
56
- else
57
- # get a server address to test - 30 second timeout
56
+ elsif !ENV["TRAVIS"]
57
+ # get a server address to test if not in travis - 30 second timeout
58
58
  print "\nPlease supply a valid Taverna 2 Server address.\n\nNOTE that " +
59
59
  "these tests will fully load the server and then delete all the runs " +
60
60
  "that it has permission to do so - if you are not using security ALL " +
@@ -62,16 +62,17 @@ else
62
62
  $stdout.flush
63
63
  if select([$stdin], [], [], 30)
64
64
  address = $stdin.gets.chomp
65
- else
66
- puts "\nSkipping tests that require a Taverna 2 Server instance..."
67
- address = ""
68
65
  end
69
66
  end
70
67
 
68
+ # If address is still unset then set it to something.
69
+ address ||= ""
70
+
71
71
  # the testcases to run
72
72
  require 'tc_util'
73
73
  require 'tc_params'
74
- if address != ""
74
+ require 'tc_server_version'
75
+ unless address == ""
75
76
  $uri, $creds = T2Server::Util.strip_uri_credentials(address)
76
77
 
77
78
  # override creds if passed in on the command line