neptune 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/README +4 -0
  2. data/doc/BabelHelper.html +393 -376
  3. data/doc/BadConfigurationException.html +121 -127
  4. data/doc/CommonFunctions.html +237 -265
  5. data/doc/ExodusHelper.html +820 -0
  6. data/doc/ExodusTaskInfo.html +263 -0
  7. data/doc/FileNotFoundException.html +121 -127
  8. data/doc/NeptuneHelper.html +527 -592
  9. data/doc/NeptuneManagerClient.html +696 -0
  10. data/doc/NeptuneManagerException.html +139 -0
  11. data/doc/Object.html +334 -236
  12. data/doc/TaskInfo.html +428 -0
  13. data/doc/created.rid +8 -5
  14. data/doc/images/add.png +0 -0
  15. data/doc/images/delete.png +0 -0
  16. data/doc/images/tag_blue.png +0 -0
  17. data/doc/images/transparent.png +0 -0
  18. data/doc/index.html +74 -142
  19. data/doc/js/darkfish.js +99 -62
  20. data/doc/js/jquery.js +15 -29
  21. data/doc/js/navigation.js +142 -0
  22. data/doc/js/search.js +94 -0
  23. data/doc/js/search_index.js +1 -0
  24. data/doc/js/searcher.js +228 -0
  25. data/doc/table_of_contents.html +226 -0
  26. data/lib/babel.rb +116 -50
  27. data/lib/custom_exceptions.rb +2 -2
  28. data/lib/exodus.rb +311 -0
  29. data/lib/exodus_task_info.rb +36 -0
  30. data/lib/neptune.rb +52 -18
  31. data/lib/{app_controller_client.rb → neptune_manager_client.rb} +54 -38
  32. data/lib/task_info.rb +155 -0
  33. data/test/{unit/test_babel.rb → test_babel.rb} +161 -26
  34. data/test/{unit/test_common_functions.rb → test_common_functions.rb} +1 -1
  35. data/test/test_exodus.rb +687 -0
  36. data/test/{unit/test_neptune.rb → test_neptune.rb} +28 -17
  37. data/test/{unit/test_app_controller_client.rb → test_neptune_manager_client.rb} +15 -16
  38. data/test/test_task_info.rb +32 -0
  39. data/test/{unit/ts_all.rb → ts_all.rb} +3 -1
  40. metadata +30 -34
  41. data/doc/AppControllerClient.html +0 -702
  42. data/doc/AppControllerException.html +0 -145
  43. data/doc/bin/neptune.html +0 -56
  44. data/doc/js/quicksearch.js +0 -114
  45. data/doc/js/thickbox-compressed.js +0 -10
  46. data/doc/lib/app_controller_client_rb.html +0 -60
  47. data/doc/lib/babel_rb.html +0 -68
  48. data/doc/lib/common_functions_rb.html +0 -70
  49. data/doc/lib/custom_exceptions_rb.html +0 -54
  50. data/doc/lib/neptune_rb.html +0 -60
  51. data/test/integration/tc_c.rb +0 -57
  52. data/test/integration/tc_dfsp.rb +0 -37
  53. data/test/integration/tc_dwssa.rb +0 -38
  54. data/test/integration/tc_erlang.rb +0 -183
  55. data/test/integration/tc_mapreduce.rb +0 -282
  56. data/test/integration/tc_mpi.rb +0 -160
  57. data/test/integration/tc_storage.rb +0 -209
  58. data/test/integration/tc_upc.rb +0 -75
  59. data/test/integration/tc_x10.rb +0 -94
  60. data/test/integration/test_helper.rb +0 -135
  61. data/test/integration/ts_neptune.rb +0 -40
@@ -1,282 +0,0 @@
1
-
2
- class TestMapReduce < Test::Unit::TestCase
3
- def test_java_mr_code
4
- STORAGE_TYPES.each { |storage|
5
- # TODO: once files api is good in appscale, test this use case
6
- next if storage == "appdb"
7
- run_java_mr_code(storage)
8
- }
9
- end
10
-
11
- def test_mr_streaming_code
12
- STORAGE_TYPES.each { |storage|
13
- run_streaming_code(storage)
14
- }
15
- end
16
-
17
- def run_java_mr_code(storage)
18
- local_input = File.expand_path("~/neptune/samples/mapreduce/the-end-of-time.txt")
19
- unless File.exists?(local_input)
20
- abort("missing input corpus - please download it and try again.")
21
- end
22
- input = TestHelper.read_file(local_input)
23
-
24
- local_code = File.expand_path("~/neptune/samples/mapreduce/hadoop-0.20.0-examples.jar")
25
- unless File.exists?(local_code)
26
- abort("missing hadoop examples jar - please download it and try again.")
27
- end
28
- main = "wordcount"
29
-
30
- local_output = File.expand_path("~/neptune/samples/mapreduce/expected-output.txt")
31
- unless File.exists?(local_output)
32
- abort("missing expected output - please download it and try again.")
33
- end
34
- expected_output = TestHelper.read_file(local_output)
35
-
36
- folder = "wordcount-#{TestHelper.get_random_alphanumeric}"
37
- tmp_folder = "/tmp/#{folder}"
38
- FileUtils.mkdir_p(tmp_folder)
39
-
40
- input_name = "input"
41
- local_input = "#{tmp_folder}/#{input_name}"
42
- TestHelper.write_file(local_input, input)
43
-
44
- remote_input = TestHelper.get_output_location("#{folder}-input", storage)
45
- remote_code = TestHelper.get_output_location("#{folder}-code.jar", storage, notxt=true)
46
- remote_output = TestHelper.get_output_location("#{folder}-output", storage)
47
-
48
- put_file_in_storage(local_input, remote_input, storage)
49
- put_file_in_storage(local_code, remote_code, storage)
50
-
51
- start_mr_code(remote_input, remote_output, remote_code, main, storage)
52
- get_mr_output(remote_output, expected_output, storage)
53
- end
54
-
55
-
56
- def start_mr_code(input, output, code, main, storage)
57
- params = {
58
- :type => "mapreduce",
59
- :input => input,
60
- :output => output,
61
- :mapreducejar => code,
62
- :main => main,
63
- :nodes_to_use => 1
64
- }.merge(TestHelper.get_storage_params(storage))
65
-
66
- status = nil
67
-
68
- loop {
69
- status = neptune(params)
70
- if status[:msg] =~ /not enough free nodes/
71
- puts status[:msg]
72
- else
73
- break
74
- end
75
- sleep(5)
76
- }
77
-
78
- msg = "Your job was not started successfully. The failure message " +
79
- "reported was #{status[:msg]}"
80
- assert_equal(status[:result], :success, msg)
81
- end
82
-
83
- def run_streaming_code(storage)
84
- expected_output = "sum x ="
85
- input = <<BAZ
86
- 1 32
87
- 33 64
88
- 65 96
89
- 97 128
90
- BAZ
91
-
92
- map_code = <<BAZ
93
- #!/usr/bin/ruby -w
94
- # Programmer: Chris Bunch
95
- # mapper-ruby.rb: Solves part of the EP parallel benchmark via the
96
- # MapReduce framework as follows:
97
- # Input: Takes in ranges of k values to compute over STDIN.
98
- # Output: list [l, X_k, Y_k]
99
-
100
- A = 5 ** 13
101
- S = 271828183
102
- MIN_VAL = 2 ** -46
103
- MAX_VAL = 2 ** 46
104
-
105
- def generate_random(k)
106
- xk = (A ** k) * S % MAX_VAL
107
- MIN_VAL * xk
108
- end
109
-
110
- def ep(k)
111
- k = Integer(k)
112
-
113
- xj = generate_random(k)
114
- yj = generate_random(k+1)
115
-
116
- t = xj * xj + yj * yj
117
-
118
- if t <= 1
119
- xk = xj * Math.sqrt(-2 * Math.log(t) / t)
120
- yk = yj * Math.sqrt(-2 * Math.log(t) / t)
121
-
122
- max = [xk.abs, yk.abs].max
123
- l = max.floor
124
- puts l.to_s + " " + xk.to_s + " " + yk.to_s
125
- end
126
- end
127
-
128
- loop {
129
- input = STDIN.gets
130
- break if input.nil?
131
- start, fin = input.chomp.split
132
- start = Integer(start)
133
- fin = Integer(fin)
134
- current = start
135
- loop {
136
- ep(current)
137
- current = current + 2
138
- break if current > fin
139
- }
140
- }
141
-
142
- BAZ
143
-
144
- red_code = <<BAZ
145
- #!/usr/bin/ruby -w
146
- # Programmer: Chris Bunch
147
- # reducer-ruby.rb: Solves part of the EP parallel benchmark via the
148
- # MapReduce framework as follows:
149
- # Input: list [l, X_k, Y_k]
150
- # Output: [l, sum(X_k), sum(Y_k)]
151
-
152
- current_l = nil
153
-
154
- x_count = 0
155
- y_count = 0
156
-
157
- sum_x = 0.0
158
- sum_y = 0.0
159
-
160
- loop {
161
- input = STDIN.gets
162
- break if input.nil?
163
- l, x, y = input.chomp.split
164
- l = Integer(l)
165
- x = Float(x)
166
- y = Float(y)
167
-
168
- current_l = l if current_l.nil?
169
-
170
- if l != current_l
171
- puts "bucket = " + current_l.to_s + ", |x| = " + x_count.to_s + ", |y| = " + y_count.to_s
172
- current_l = l
173
- x_count = 0
174
- y_count = 0
175
- end
176
-
177
- sum_x = sum_x + x
178
- sum_y = sum_y + y
179
-
180
- abs_x = x.abs
181
- abs_y = y.abs
182
-
183
- if abs_x > abs_y
184
- x_count = x_count + 1
185
- else
186
- y_count = y_count + 1
187
- end
188
- }
189
-
190
- puts "bucket = " + current_l.to_s + ", |x| = " + x_count.to_s + ", |y| = " + y_count.to_s
191
- puts "sum x = " + sum_x.to_s + ", sum y = " + sum_y.to_s
192
-
193
- BAZ
194
-
195
- contents = TestHelper.get_random_alphanumeric(1024)
196
- folder = "ep-#{TestHelper.get_random_alphanumeric}"
197
-
198
- input_name = "input"
199
- map_source = "map.rb"
200
- red_source = "reduce.rb"
201
-
202
- tmp_folder = "/tmp/#{folder}"
203
- FileUtils.mkdir_p(tmp_folder)
204
-
205
- local_input = "#{tmp_folder}/#{input_name}"
206
- local_map = "#{tmp_folder}/#{map_source}"
207
- local_red = "#{tmp_folder}/#{red_source}"
208
-
209
- TestHelper.write_file(local_input, input)
210
- TestHelper.write_file(local_map, map_code)
211
- TestHelper.write_file(local_red, red_code)
212
-
213
- remote_input = TestHelper.get_output_location("#{folder}-input", storage)
214
- remote_map = TestHelper.get_output_location("#{folder}-map.rb", storage, notxt=true)
215
- remote_red = TestHelper.get_output_location("#{folder}-reduce.rb", storage, notxt=true)
216
- remote_output = TestHelper.get_output_location("#{folder}-output", storage)
217
-
218
- put_file_in_storage(local_input, remote_input, storage)
219
- put_file_in_storage(local_map, remote_map, storage)
220
- put_file_in_storage(local_red, remote_red, storage)
221
-
222
- start_mr_streaming_code(remote_input, remote_output, remote_map, remote_red, storage)
223
- get_mr_output(remote_output, expected_output, storage)
224
-
225
- FileUtils.rm_rf(local_input)
226
- FileUtils.rm_rf(local_map)
227
- FileUtils.rm_rf(local_red)
228
- end
229
-
230
- def put_file_in_storage(local, remote, storage)
231
- params = {
232
- :type => "input",
233
- :local => local,
234
- :remote => remote
235
- }.merge(TestHelper.get_storage_params(storage))
236
-
237
- input_result = neptune(params)
238
-
239
- msg = "We were unable to store a file in the database. We " +
240
- " got back this: #{msg}"
241
- assert(input_result, msg)
242
- end
243
-
244
- def start_mr_streaming_code(input, output, map, reduce, storage)
245
- params = {
246
- :type => "mapreduce",
247
- :input => input,
248
- :output => output,
249
- :map => map,
250
- :reduce => reduce,
251
- :nodes_to_use => 1
252
- }.merge(TestHelper.get_storage_params(storage))
253
-
254
- status = nil
255
-
256
- loop {
257
- status = neptune(params)
258
- if status[:msg] =~ /not enough free nodes/
259
- puts status[:msg]
260
- else
261
- break
262
- end
263
- sleep(5)
264
- }
265
-
266
- msg = "Your job was not started successfully. The failure message " +
267
- "reported was #{status[:msg]}"
268
- assert_equal(status[:result], :success, msg)
269
- end
270
-
271
- def get_mr_output(output, expected, storage)
272
- result = TestHelper.get_job_output(output, storage)
273
-
274
- TestHelper.write_file("/tmp/result", result)
275
-
276
- msg = "The MapReduce job you ran did not return the expected result. " +
277
- "We expected to see [#{expected}] but instead saw [#{result}]"
278
- success = result.include?(expected)
279
- assert(success, msg)
280
- end
281
- end
282
-
@@ -1,160 +0,0 @@
1
-
2
- class TestMPI < Test::Unit::TestCase
3
- def test_hello_world_code
4
- num_procs = 1
5
-
6
- STORAGE_TYPES.each { |storage|
7
- run_hello_world_code(storage, num_procs)
8
- }
9
- end
10
-
11
- def test_not_enough_procs
12
- num_procs = 0
13
-
14
- STORAGE_TYPES.each { |storage|
15
- msg = "Running an MPI compute job with p < n should have thrown " +
16
- "an exception, when in fact it did not. Here we used #{storage} " +
17
- "as the storage backend."
18
-
19
- assert_raise(SystemExit, msg) {
20
- run_hello_world_code(storage, num_procs)
21
- }
22
- }
23
- end
24
-
25
- def test_bad_source_code
26
- location = "/tmp/baz" + TestHelper.get_random_alphanumeric
27
- output = "/bazboo2"
28
- storage = "appdb"
29
-
30
- msg = "Running an MPI compute job with a non-existent code location" +
31
- " should have thrown an exception, when in fact it did not."
32
-
33
- assert_raise(SystemExit, msg) {
34
- TestHelper.start_job("mpi", location, output, storage)
35
- }
36
-
37
- FileUtils.mkdir_p(location)
38
-
39
- bad_file_msg = "Running an MPI compute job with a code location that" +
40
- " is not a file should have thrown an exception, when in fact it did not."
41
-
42
- assert_raise(SystemExit, bad_file_msg) {
43
- TestHelper.start_job("mpi", location, output, storage)
44
- }
45
-
46
- FileUtils.rmdir(location)
47
- end
48
-
49
- def run_hello_world_code(storage, num_procs)
50
- expected_output = "0: We have 1 processors"
51
- ring_code = <<BAZ
52
- /*
53
- "Hello World" MPI Test Program
54
- */
55
- #include <mpi.h>
56
- #include <stdio.h>
57
- #include <string.h>
58
-
59
- #define BUFSIZE 128
60
- #define TAG 0
61
-
62
- int main(int argc, char *argv[])
63
- {
64
- char idstr[32];
65
- char buff[BUFSIZE];
66
- int numprocs;
67
- int myid;
68
- int i;
69
- MPI_Status stat;
70
-
71
- MPI_Init(&argc,&argv); /* all MPI programs start with MPI_Init; all 'N' processes exist thereafter */
72
- MPI_Comm_size(MPI_COMM_WORLD,&numprocs); /* find out how big the SPMD world is */
73
- MPI_Comm_rank(MPI_COMM_WORLD,&myid); /* and this processes' rank is */
74
-
75
- /* At this point, all programs are running equivalently, the rank distinguishes
76
- the roles of the programs in the SPMD model, with rank 0 often used specially... */
77
- if(myid == 0)
78
- {
79
- printf("%d: We have %d processors", myid, numprocs);
80
- for(i=1;i<numprocs;i++)
81
- {
82
- sprintf(buff, "Hello %d! ", i);
83
- MPI_Send(buff, BUFSIZE, MPI_CHAR, i, TAG, MPI_COMM_WORLD);
84
- }
85
- for(i=1;i<numprocs;i++)
86
- {
87
- MPI_Recv(buff, BUFSIZE, MPI_CHAR, i, TAG, MPI_COMM_WORLD, &stat);
88
- printf("%d: %s", myid, buff);
89
- }
90
- }
91
- else
92
- {
93
- /* receive from rank 0: */
94
- MPI_Recv(buff, BUFSIZE, MPI_CHAR, 0, TAG, MPI_COMM_WORLD, &stat);
95
- sprintf(idstr, "Processor %d ", myid);
96
- strncat(buff, idstr, BUFSIZE-1);
97
- strncat(buff, "reporting for duty", BUFSIZE-1);
98
- /* send to rank 0: */
99
- MPI_Send(buff, BUFSIZE, MPI_CHAR, 0, TAG, MPI_COMM_WORLD);
100
- }
101
-
102
- MPI_Finalize(); /* MPI Programs end with MPI Finalize; this is a weak synchronization point */
103
- return 0;
104
- }
105
-
106
- BAZ
107
-
108
- contents = TestHelper.get_random_alphanumeric(1024)
109
- folder = "hello-world-#{TestHelper.get_random_alphanumeric}"
110
- source = "HelloWorld.c"
111
-
112
- tmp_folder = "/tmp/#{folder}"
113
- FileUtils.mkdir_p(tmp_folder)
114
- compiled = "#{tmp_folder}-compiled"
115
- compiled_code = "#{compiled}/HelloWorld"
116
-
117
- local = "#{tmp_folder}/#{source}"
118
- TestHelper.write_file(local, ring_code)
119
-
120
- output = TestHelper.get_output_location(folder, storage)
121
-
122
- compile_mpi_code(tmp_folder, source, compiled)
123
- start_mpi_code(compiled_code, num_procs, output, storage)
124
- get_mpi_output(output, expected_output, storage)
125
-
126
- FileUtils.rm_rf(tmp_folder)
127
- FileUtils.rm_rf(compiled)
128
- end
129
-
130
- def compile_mpi_code(location, main_file, compiled)
131
- std_out, std_err = TestHelper.compile_code(location, main_file, compiled)
132
-
133
- make = "mpicc HelloWorld.c -o HelloWorld -Wall"
134
- msg = "The MPI code did not compile as expected. It should have " +
135
- "compiled with the command [#{make}] instead of [#{std_out}]."
136
- assert_equal(std_out, make, msg)
137
-
138
- msg = "The MPI code did not compile successfully. It reported " +
139
- "the following error: #{std_err}"
140
- assert_nil(std_err, msg)
141
- end
142
-
143
- def start_mpi_code(code_location, num_procs, output, storage)
144
- params = { :procs_to_use => num_procs }
145
- status = TestHelper.start_job("mpi", code_location, output, storage, params)
146
-
147
- msg = "Your job was not started successfully. The failure message " +
148
- "reported was #{status[:msg]}"
149
- assert_equal(status[:result], :success, msg)
150
- end
151
-
152
- def get_mpi_output(output, expected, storage)
153
- result = TestHelper.get_job_output(output, storage)
154
-
155
- msg = "The MPI job you ran did not return the expected result. " +
156
- "We expected to see [#{expected}] but instead saw [#{result}]"
157
- assert_equal(result, expected, msg)
158
- end
159
- end
160
-
@@ -1,209 +0,0 @@
1
-
2
- class TestStorage < Test::Unit::TestCase
3
- def test_acl
4
- STORAGE_TYPES.each { |storage|
5
- run_in_acl(storage)
6
- }
7
- end
8
-
9
- def test_in_out
10
- STORAGE_TYPES.each { |storage|
11
- run_in_out(storage)
12
- }
13
- end
14
-
15
- def test_run_in_out_w_env
16
- STORAGE_TYPES.each { |storage|
17
- run_in_out_w_env(storage)
18
- }
19
- end
20
-
21
- def test_no_creds
22
- creds = %w{
23
- GSTORAGE_ACCESS_KEY GSTORAGE_SECRET_KEY GSTORAGE_URL
24
- S3_ACCESS_KEY S3_SECRET_KEY S3_URL
25
- WALRUS_ACCESS_KEY WALRUS_SECRET_KEY WALRUS_URL
26
- }
27
-
28
- old_creds = {}
29
- creds.each { |c|
30
- old_creds[c] = ENV[c]
31
- ENV[c] = nil
32
- }
33
-
34
- # try an input job with creds in env but not in job
35
- # should succeed
36
-
37
- STORAGE_TYPES.each { |storage|
38
- params = { :storage => storage }
39
- testhelper = flexmock(TestHelper)
40
- testhelper.should_receive(:get_storage_params).with(storage).and_return(params)
41
-
42
- no_msg = "Trying to start a storage job and failing to specify " +
43
- "necessary credentials should not have failed, but it did." +
44
- " The storage type used was #{storage}."
45
-
46
- msg = "Trying to start a storage job and failing to specify " +
47
- "necessary credentials should have failed, but it didn't." +
48
- " The storage type used was #{storage}."
49
-
50
- if storage == "appdb"
51
- assert_nothing_raised(SystemExit, no_msg) {
52
- run_in_out(storage)
53
- }
54
- else
55
- assert_raise(SystemExit, msg) {
56
- run_in_out(storage)
57
- }
58
- end
59
- }
60
-
61
- creds.each { |c|
62
- ENV[c] = old_creds[c]
63
- }
64
- end
65
-
66
- def test_bad_storage
67
- msg = "Specifying an incorrect storage backend should have thrown an " +
68
- "exception, when in fact it did not."
69
- assert_raise(SystemExit, msg) { run_in_out("blarg_storage") }
70
- end
71
-
72
- def test_bad_output_location
73
- output = "baz-boo-for-me-too"
74
-
75
- STORAGE_TYPES.each { |storage|
76
- end_of_msg = " should have thrown an exception, when in fact it did not." +
77
- "Here we tested with #{storage} as the storage backend."
78
-
79
- no_slash_msg = "Specifying an output location without a leading slash"
80
-
81
- assert_raise(SystemExit, no_slash_msg + end_of_msg) {
82
- TestHelper.get_job_output(output, storage)
83
- }
84
-
85
- no_output_msg = "Specifying an output job with a blank output parameter"
86
- assert_raise(SystemExit, no_output_msg + end_of_msg) {
87
- TestHelper.get_job_output("", storage)
88
- }
89
-
90
- nil_output_msg = "Specifying an output job with a nil output"
91
- assert_raise(SystemExit, nil_output_msg + end_of_msg) {
92
- TestHelper.get_job_output(nil, storage)
93
- }
94
- }
95
- end
96
-
97
- def run_in_acl(storage)
98
- contents = TestHelper.get_random_alphanumeric(1024) + "+&baz"
99
- suffix = "neptune-testfile-#{TestHelper.get_random_alphanumeric}"
100
- local = "/tmp/#{suffix}"
101
- TestHelper.write_file(local, contents)
102
- remote = TestHelper.get_output_location(suffix, storage)
103
-
104
- in_params = {
105
- :type => "input",
106
- :local => local,
107
- :remote => remote
108
- }.merge(TestHelper.get_storage_params(storage))
109
-
110
- input_result = neptune(in_params)
111
-
112
- msg = "We were unable to store a file in the datastore. We " +
113
- " got back this: #{msg}"
114
- assert(input_result, msg)
115
-
116
- get_params = {
117
- :type => "get-acl",
118
- :output => remote
119
- }.merge(TestHelper.get_storage_params(storage))
120
-
121
- acl = neptune(get_params)
122
-
123
- get_acl_msg1 = "The default ACL should be private, but was [#{acl}] instead."
124
- assert_equal("private", acl, get_acl_msg1)
125
-
126
- # TODO: set acl is currently broken - once we fix it, we should
127
- # do the following:
128
-
129
- # set acl to something else
130
- # verify that it was set correctly
131
-
132
- FileUtils.rm_rf(local)
133
- end
134
-
135
- def run_in_out_w_env(storage)
136
- creds = %w{
137
- GSTORAGE_ACCESS_KEY GSTORAGE_SECRET_KEY GSTORAGE_URL
138
- S3_ACCESS_KEY S3_SECRET_KEY S3_URL
139
- WALRUS_ACCESS_KEY WALRUS_SECRET_KEY WALRUS_URL
140
- }
141
-
142
- old_creds = {}
143
- creds.each { |c|
144
- old_creds[c] = ENV[c]
145
- }
146
-
147
- s3_creds = %w{ EC2_ACCESS_KEY EC2_SECRET_KEY S3_URL }
148
-
149
- needed_creds = TestHelper.get_storage_params(storage)
150
- puts needed_creds.inspect
151
-
152
- params = { :storage => storage }
153
- testhelper = flexmock(TestHelper)
154
- testhelper.should_receive(:get_storage_params).with(storage).and_return(params)
155
-
156
- s3_creds.each { |c|
157
- ENV[c] = needed_creds[c.to_sym]
158
- }
159
-
160
- run_in_out(storage)
161
-
162
- s3_creds.each { |c|
163
- ENV[c] = nil
164
- }
165
-
166
- creds.each { |c|
167
- ENV[c] = old_creds[c]
168
- }
169
-
170
- testhelper.flexmock_teardown
171
- end
172
-
173
- def run_in_out(storage)
174
- contents = TestHelper.get_random_alphanumeric(1024) + "+&baz"
175
- suffix = "neptune-testfile-#{TestHelper.get_random_alphanumeric}"
176
- local = "/tmp/#{suffix}"
177
- TestHelper.write_file(local, contents)
178
-
179
- run_input(local, suffix, storage)
180
- run_output(contents, suffix, storage)
181
-
182
- FileUtils.rm_rf(local)
183
- end
184
-
185
- def run_input(local, suffix, storage)
186
- params = {
187
- :type => "input",
188
- :local => local,
189
- :remote => TestHelper.get_output_location(suffix, storage)
190
- }.merge(TestHelper.get_storage_params(storage))
191
-
192
- input_result = neptune(params)
193
-
194
- msg = "We were unable to store a file in the database. We " +
195
- " got back this: #{msg}"
196
- assert(input_result, msg)
197
- end
198
-
199
- def run_output(local, suffix, storage)
200
- output = TestHelper.get_output_location(suffix, storage)
201
- remote = TestHelper.get_job_output(output, storage)
202
-
203
- msg = "We were unable to verify that the remote file matches the " +
204
- "local version. The local copy's contents are: " +
205
- "[#{local}], while the remote copy's contents are [#{remote}]."
206
- assert_equal(local, remote, msg)
207
- end
208
- end
209
-