uricp 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +16 -0
- data/README.md +31 -0
- data/README.rdoc +23 -0
- data/Rakefile +66 -0
- data/bin/segment_upload +66 -0
- data/bin/uricp +103 -0
- data/features/auth_download.feature +106 -0
- data/features/cacheable_from_uri.feature +71 -0
- data/features/documented_options.feature +73 -0
- data/features/remote_upload.feature +49 -0
- data/features/segmented_upload.feature +27 -0
- data/features/segmented_upload_options.feature +65 -0
- data/features/step_definitions/orbit_steps.rb +194 -0
- data/features/step_definitions/uricp_steps.rb +34 -0
- data/features/support/env.rb +20 -0
- data/features/userid_download.feature +21 -0
- data/lib/segment_upload.rb +38 -0
- data/lib/uricp/curl_primitives.rb +45 -0
- data/lib/uricp/orbit_auth.rb +59 -0
- data/lib/uricp/segmenter.rb +88 -0
- data/lib/uricp/strategy/cache_common.rb +48 -0
- data/lib/uricp/strategy/cached_get.rb +48 -0
- data/lib/uricp/strategy/cleaner.rb +28 -0
- data/lib/uricp/strategy/common.rb +108 -0
- data/lib/uricp/strategy/local_convert.rb +36 -0
- data/lib/uricp/strategy/local_convert_common.rb +29 -0
- data/lib/uricp/strategy/local_link.rb +31 -0
- data/lib/uricp/strategy/piped_cache.rb +40 -0
- data/lib/uricp/strategy/piped_cache_convert.rb +45 -0
- data/lib/uricp/strategy/piped_compress.rb +30 -0
- data/lib/uricp/strategy/piped_decompress.rb +35 -0
- data/lib/uricp/strategy/piped_local_compress.rb +30 -0
- data/lib/uricp/strategy/piped_local_get.rb +29 -0
- data/lib/uricp/strategy/piped_local_put.rb +29 -0
- data/lib/uricp/strategy/piped_remote_get.rb +38 -0
- data/lib/uricp/strategy/pruner.rb +22 -0
- data/lib/uricp/strategy/remote_put.rb +47 -0
- data/lib/uricp/strategy/segmented_remote_put.rb +52 -0
- data/lib/uricp/strategy/sweeper.rb +28 -0
- data/lib/uricp/uri_strategy.rb +47 -0
- data/lib/uricp/version.rb +4 -0
- data/lib/uricp.rb +56 -0
- data/spec/something_spec.rb +5 -0
- data/uricp.gemspec +32 -0
- metadata +281 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Name: uricp
|
2
|
+
Copyright (c) 2014
|
3
|
+
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
5
|
+
it under the terms of the GNU General Public License as published by
|
6
|
+
the Free Software Foundation, either version 3 of the License, or
|
7
|
+
(at your option) any later version.
|
8
|
+
|
9
|
+
This program is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
GNU General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU General Public License
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Uricp
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'uricp'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install uricp
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/uricp/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/README.rdoc
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
= uricp - DESCRIBE YOUR GEM
|
2
|
+
|
3
|
+
Author:: YOUR NAME (YOUR EMAIL)
|
4
|
+
Copyright:: Copyright (c) 2014 YOUR NAME
|
5
|
+
|
6
|
+
|
7
|
+
License:: gplv3, see LICENSE.txt
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
DESCRIBE YOUR GEM HERE
|
12
|
+
|
13
|
+
== Links
|
14
|
+
|
15
|
+
* {Source on Github}[LINK TO GITHUB]
|
16
|
+
* RDoc[LINK TO RDOC.INFO]
|
17
|
+
|
18
|
+
== Install
|
19
|
+
|
20
|
+
== Examples
|
21
|
+
|
22
|
+
== Contributing
|
23
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
def dump_load_path
|
2
|
+
puts $LOAD_PATH.join("\n")
|
3
|
+
found = nil
|
4
|
+
$LOAD_PATH.each do |path|
|
5
|
+
if File.exists?(File.join(path,"rspec"))
|
6
|
+
puts "Found rspec in #{path}"
|
7
|
+
if File.exists?(File.join(path,"rspec","core"))
|
8
|
+
puts "Found core"
|
9
|
+
if File.exists?(File.join(path,"rspec","core","rake_task"))
|
10
|
+
puts "Found rake_task"
|
11
|
+
found = path
|
12
|
+
else
|
13
|
+
puts "!! no rake_task"
|
14
|
+
end
|
15
|
+
else
|
16
|
+
puts "!!! no core"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
if found.nil?
|
21
|
+
puts "Didn't find rspec/core/rake_task anywhere"
|
22
|
+
else
|
23
|
+
puts "Found in #{path}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
require 'bundler'
|
27
|
+
require 'rake/clean'
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
rescue LoadError
|
32
|
+
dump_load_path
|
33
|
+
raise
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'cucumber'
|
37
|
+
require 'cucumber/rake/task'
|
38
|
+
gem 'rdoc' # we need the installed RDoc gem, not the system one
|
39
|
+
require 'rdoc/task'
|
40
|
+
|
41
|
+
include Rake::DSL
|
42
|
+
|
43
|
+
Bundler::GemHelper.install_tasks
|
44
|
+
|
45
|
+
|
46
|
+
RSpec::Core::RakeTask.new do |t|
|
47
|
+
# Put spec opts in a file named .rspec in root
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
CUKE_RESULTS = 'results.html'
|
52
|
+
CLEAN << CUKE_RESULTS
|
53
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
54
|
+
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
|
55
|
+
t.fork = false
|
56
|
+
end
|
57
|
+
|
58
|
+
Rake::RDocTask.new do |rd|
|
59
|
+
|
60
|
+
rd.main = "README.rdoc"
|
61
|
+
|
62
|
+
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
|
63
|
+
end
|
64
|
+
|
65
|
+
task :default => [:spec,:features]
|
66
|
+
|
data/bin/segment_upload
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'uri'
|
5
|
+
require 'methadone'
|
6
|
+
require 'filesize'
|
7
|
+
require 'segment_upload.rb'
|
8
|
+
|
9
|
+
class App
|
10
|
+
include Methadone::Main
|
11
|
+
include Methadone::SH
|
12
|
+
include Methadone::CLILogging
|
13
|
+
|
14
|
+
main do |to_uri|
|
15
|
+
options['auth_uri'] = options['to_uri'] = URI(to_uri)
|
16
|
+
options['segment-size'] = Filesize.from(options['segment-size'])
|
17
|
+
Uricp::OrbitAuth.validate_options(options)
|
18
|
+
Uricp::OrbitAuth.add_auth_token(options)
|
19
|
+
validate_options
|
20
|
+
run_command
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.run_command
|
24
|
+
Uricp::Segmenter.new(options).upload
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.validate_options
|
28
|
+
unless %w{http https}.include? options['to_uri'].scheme
|
29
|
+
raise Uricp::UnsupportedURLtype,
|
30
|
+
"unsupported url: Can only perform a segmented upload to an HTTP(S) URL"
|
31
|
+
end
|
32
|
+
unless options['auth-token']
|
33
|
+
raise OptionParser::MissingArgument,
|
34
|
+
"Need authentication to proceed - supply 'auth-user' or 'auth-token'"
|
35
|
+
end
|
36
|
+
if options['from'].to_s =~ /^\s*\|/
|
37
|
+
raise OptionParser::InvalidArgument,
|
38
|
+
"Source filenames starting with '|' not supported"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Declare command-line interface here
|
43
|
+
|
44
|
+
description "Split input into chunks and upload as Dynamic Large Object"
|
45
|
+
|
46
|
+
options['segment-size'] = Uricp::DEFAULT_SEGMENT_SIZE
|
47
|
+
Uricp::OrbitAuth.add_auth_to_optionparser(self)
|
48
|
+
on("--from FILE",
|
49
|
+
"Upload from FILE rather than stdin")
|
50
|
+
on("--segment-size SEGMENT_SIZE",
|
51
|
+
"Size of required segment in [GMk][i]B.")
|
52
|
+
on("--[no-]dry-run",
|
53
|
+
"Show what would be run,","but don't run the command")
|
54
|
+
|
55
|
+
|
56
|
+
#Arguments
|
57
|
+
arg :to_uri, "URI to upload to"
|
58
|
+
|
59
|
+
defaults_from_env_var 'URICP'
|
60
|
+
|
61
|
+
version Uricp::VERSION
|
62
|
+
|
63
|
+
use_log_level_option :toggle_debug_on_signal => 'USR1'
|
64
|
+
|
65
|
+
go!
|
66
|
+
end
|
data/bin/uricp
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'uri'
|
5
|
+
require 'methadone'
|
6
|
+
require 'filesize'
|
7
|
+
require 'uricp.rb'
|
8
|
+
|
9
|
+
class App
|
10
|
+
include Methadone::Main
|
11
|
+
include Methadone::SH
|
12
|
+
include Methadone::CLILogging
|
13
|
+
|
14
|
+
main do |from_uri, to_uri|
|
15
|
+
options['from_uri'] = URI(from_uri)
|
16
|
+
options['to_uri'] = URI(to_uri)
|
17
|
+
options['auth_uri'] = select_auth_url
|
18
|
+
if options['segment-size']
|
19
|
+
options['segment-size'] = Filesize.from(options['segment-size'])
|
20
|
+
end
|
21
|
+
validate_options
|
22
|
+
Uricp::OrbitAuth.validate_options(options)
|
23
|
+
Uricp::OrbitAuth.add_auth_token(options)
|
24
|
+
ENV['URICP'] = "--auth-token='#{options['auth-token']}'"
|
25
|
+
add_cache_name
|
26
|
+
add_temp_area
|
27
|
+
run_command
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.run_command
|
31
|
+
command_list = build_command
|
32
|
+
if options['dry-run']
|
33
|
+
info "Would execute:\n###\n#{command_list}\n###"
|
34
|
+
else
|
35
|
+
sh! pipefail_wrapper(command_list),
|
36
|
+
:on_fail => "Copy from #{options['from_uri']} to #{options['to_uri']} failed"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.build_command
|
41
|
+
command_sequence = Uricp::UriStrategy.choose_strategy(options)
|
42
|
+
debug "#{self.name} Command sequence is #{command_sequence.inspect}"
|
43
|
+
command_sequence.map{|c| c.command}.join('')
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.validate_options
|
47
|
+
if options['target-format'] && !options['cache']
|
48
|
+
raise ::OptionParser::MissingArgument,
|
49
|
+
"'target-format' requires 'cache' option"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.add_cache_name
|
54
|
+
if options['cache']
|
55
|
+
options['cache_name'] = File.basename(options['from_uri'].path)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.add_temp_area
|
60
|
+
if options['cache']
|
61
|
+
options['temp'] = File.join(options['cache'], 'temp/')
|
62
|
+
else
|
63
|
+
options['temp'] = '/tmp'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.select_auth_url
|
68
|
+
[options['from_uri'], options['to_uri']].detect do |x|
|
69
|
+
x && x.scheme =~ /https?/
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.pipefail_wrapper(command)
|
74
|
+
['bash', '-c', 'set -e -o pipefail;'+command]
|
75
|
+
end
|
76
|
+
|
77
|
+
# Declare command-line interface here
|
78
|
+
|
79
|
+
description "Copy one URI to another"
|
80
|
+
|
81
|
+
Uricp::OrbitAuth.add_auth_to_optionparser(self)
|
82
|
+
on("--cache CACHE_ROOT",
|
83
|
+
"Root directory of cache area")
|
84
|
+
on("--target-format FORMAT", [:qcow2, :raw, :qcow3, :qcow2v3],
|
85
|
+
"Image format of target", "[qcow2, raw, qcow3, qcow2v3]")
|
86
|
+
on("--segment-size SEGMENT_SIZE",
|
87
|
+
"Size of required segment in [GMk][i]B.")
|
88
|
+
on("--[no-]compress",
|
89
|
+
"Compress output")
|
90
|
+
on("--[no-]dry-run",
|
91
|
+
"Show what would be run,", "but don't run the command")
|
92
|
+
#Arguments
|
93
|
+
arg :from_uri, "URI to copy from"
|
94
|
+
arg :to_uri, "URI to copy to"
|
95
|
+
|
96
|
+
defaults_from_env_var 'URICP'
|
97
|
+
|
98
|
+
version Uricp::VERSION
|
99
|
+
|
100
|
+
use_log_level_option :toggle_debug_on_signal => 'USR1'
|
101
|
+
|
102
|
+
go!
|
103
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
@orbit
|
2
|
+
@orbitdownloads
|
3
|
+
Feature: Authenticated download of images from orbit
|
4
|
+
In order to download images from orbit
|
5
|
+
As a command line user
|
6
|
+
I want to retrieve the URI via an optional cache and copy correctly to target in the right format
|
7
|
+
|
8
|
+
Background:
|
9
|
+
Given an empty directory named "/tmp/uricp"
|
10
|
+
And the default aruba timeout is 15 seconds
|
11
|
+
And a container called "test"
|
12
|
+
|
13
|
+
Scenario: qcow download no conversion, no cache
|
14
|
+
When I retrieve "img-qcow2" from container "test" into "file:///tmp/uricp/srv-test1"
|
15
|
+
Then a file named "/tmp/uricp/srv-test1" should exist
|
16
|
+
And the file named "/tmp/uricp/srv-test1" should have a file format of "qcow2v3"
|
17
|
+
|
18
|
+
Scenario: lz4 download no conversion, no cache
|
19
|
+
When I retrieve "img-lz4cy" from container "test" into "file:///tmp/uricp/srv-test2"
|
20
|
+
Then a file named "/tmp/uricp/srv-test2" should exist
|
21
|
+
And the file named "/tmp/uricp/srv-test2" should have a file format of "lz4"
|
22
|
+
|
23
|
+
Scenario: qcow download no conversion, cache
|
24
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
25
|
+
When I retrieve "img-qcow2" with options "--cache=/tmp/uricp" from container "test" into "file:///tmp/uricp/srv-test3"
|
26
|
+
Then a file named "/tmp/uricp/srv-test3" should exist
|
27
|
+
And the file named "/tmp/uricp/srv-test3" should have a file format of "qcow2v3"
|
28
|
+
And a file named "/tmp/uricp/cache/img-qcow2" should exist
|
29
|
+
And the file named "/tmp/uricp/cache/img-qcow2" should have a file format of "qcow2v3"
|
30
|
+
|
31
|
+
Scenario: qcow download convert to raw, cache
|
32
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
33
|
+
When I retrieve "img-qcow2" with options "--target-format=raw --cache=/tmp/uricp" from container "test" into "file:///tmp/uricp/srv-test4"
|
34
|
+
Then a file named "/tmp/uricp/srv-test4" should exist
|
35
|
+
And the file named "/tmp/uricp/srv-test4" should have a file format of "raw"
|
36
|
+
And a file named "/tmp/uricp/cache/img-qcow2" should exist
|
37
|
+
And the file named "/tmp/uricp/cache/img-qcow2" should have a file format of "qcow2v3"
|
38
|
+
|
39
|
+
Scenario: qcow download convert to qcow2, cache
|
40
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
41
|
+
When I retrieve "img-qcow2" with options "--target-format=qcow2 --cache=/tmp/uricp" from container "test" into "file:///tmp/uricp/srv-test5"
|
42
|
+
Then a file named "/tmp/uricp/srv-test5" should exist
|
43
|
+
And the file named "/tmp/uricp/srv-test5" should have a file format of "qcow2"
|
44
|
+
And a file named "/tmp/uricp/cache/img-qcow2" should exist
|
45
|
+
And the file named "/tmp/uricp/cache/img-qcow2" should have a file format of "qcow2v3"
|
46
|
+
|
47
|
+
Scenario: qcow download no conversion, from cache
|
48
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
49
|
+
And a cache of "img-qcow2" from container "test" at "/tmp/uricp"
|
50
|
+
When I retrieve "img-qcow2" with options "--cache=/tmp/uricp" from container "test" into "file:///tmp/uricp/srv-test6"
|
51
|
+
Then a file named "/tmp/uricp/srv-test6" should exist
|
52
|
+
And the file named "/tmp/uricp/srv-test6" should have a file format of "qcow2v3"
|
53
|
+
And a file named "/tmp/uricp/cache/img-qcow2" should exist
|
54
|
+
And the file named "/tmp/uricp/cache/img-qcow2" should have a file format of "qcow2v3"
|
55
|
+
|
56
|
+
Scenario: qcow download convert to raw from cache
|
57
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
58
|
+
And a cache of "img-qcow2" from container "test" at "/tmp/uricp"
|
59
|
+
When I retrieve "img-qcow2" with options "--target-format=raw --cache=/tmp/uricp" from container "test" into "file:///tmp/uricp/srv-test7"
|
60
|
+
Then a file named "/tmp/uricp/srv-test7" should exist
|
61
|
+
And the file named "/tmp/uricp/srv-test7" should have a file format of "raw"
|
62
|
+
And a file named "/tmp/uricp/cache/img-qcow2" should exist
|
63
|
+
And the file named "/tmp/uricp/cache/img-qcow2" should have a file format of "qcow2v3"
|
64
|
+
|
65
|
+
Scenario: qcow download convert to qcow2 from cache
|
66
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
67
|
+
And a cache of "img-qcow2" from container "test" at "/tmp/uricp"
|
68
|
+
When I retrieve "img-qcow2" with options "--target-format=qcow2 --cache=/tmp/uricp" from container "test" into "file:///tmp/uricp/srv-test8"
|
69
|
+
Then a file named "/tmp/uricp/srv-test8" should exist
|
70
|
+
And the file named "/tmp/uricp/srv-test8" should have a file format of "qcow2"
|
71
|
+
And a file named "/tmp/uricp/cache/img-qcow2" should exist
|
72
|
+
And the file named "/tmp/uricp/cache/img-qcow2" should have a file format of "qcow2v3"
|
73
|
+
|
74
|
+
Scenario: lz4 download convert to raw, cache
|
75
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
76
|
+
When I retrieve "img-lz4cy" with options "--target-format=raw --cache=/tmp/uricp" from container "test" into "file:///tmp/uricp/srv-test9"
|
77
|
+
Then a file named "/tmp/uricp/srv-test9" should exist
|
78
|
+
And the file named "/tmp/uricp/srv-test9" should have a file format of "raw"
|
79
|
+
And a file named "/tmp/uricp/cache/img-lz4cy" should exist
|
80
|
+
And the file named "/tmp/uricp/cache/img-lz4cy" should have a file format of "lz4"
|
81
|
+
|
82
|
+
Scenario: lz4 download convert to raw, from cache
|
83
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
84
|
+
And a cache of "img-lz4cy" from container "test" at "/tmp/uricp"
|
85
|
+
When I retrieve "img-lz4cy" with options "--target-format=raw --cache=/tmp/uricp" from container "test" into "file:///tmp/uricp/srv-testa"
|
86
|
+
Then a file named "/tmp/uricp/srv-testa" should exist
|
87
|
+
And the file named "/tmp/uricp/srv-testa" should have a file format of "raw"
|
88
|
+
And a file named "/tmp/uricp/cache/img-lz4cy" should exist
|
89
|
+
And the file named "/tmp/uricp/cache/img-lz4cy" should have a file format of "lz4"
|
90
|
+
|
91
|
+
Scenario: lz4 download convert to qcow2, cache
|
92
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
93
|
+
When I retrieve "img-lz4cy" with options "--target-format=qcow2 --cache=/tmp/uricp" from container "test" into "file:///tmp/uricp/srv-testb"
|
94
|
+
Then a file named "/tmp/uricp/srv-testb" should exist
|
95
|
+
And the file named "/tmp/uricp/srv-testb" should have a file format of "qcow2"
|
96
|
+
And a file named "/tmp/uricp/cache/img-lz4cy" should exist
|
97
|
+
And the file named "/tmp/uricp/cache/img-lz4cy" should have a file format of "lz4"
|
98
|
+
|
99
|
+
Scenario: lz4 download convert to qcow2, from cache
|
100
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
101
|
+
And a cache of "img-lz4cy" from container "test" at "/tmp/uricp"
|
102
|
+
When I retrieve "img-lz4cy" with options "--target-format=qcow2 --cache=/tmp/uricp" from container "test" into "file:///tmp/uricp/srv-testa"
|
103
|
+
Then a file named "/tmp/uricp/srv-testa" should exist
|
104
|
+
And the file named "/tmp/uricp/srv-testa" should have a file format of "qcow2"
|
105
|
+
And a file named "/tmp/uricp/cache/img-lz4cy" should exist
|
106
|
+
And the file named "/tmp/uricp/cache/img-lz4cy" should have a file format of "lz4"
|
@@ -0,0 +1,71 @@
|
|
1
|
+
Feature: Download Public VM images
|
2
|
+
In order to download public VM images to the target
|
3
|
+
As a command line user
|
4
|
+
I want to retrieve the URI via an optional cache and copy correctly to target in the right format
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given an empty directory named "/tmp/uricp"
|
8
|
+
And the default aruba timeout is 15 seconds
|
9
|
+
|
10
|
+
Scenario: HTTP URI qcow2 to qcow2
|
11
|
+
When I successfully run `uricp https://foss-lab-manual.googlecode.com/files/freedos.qcow2 file:///tmp/uricp/srv-testy`
|
12
|
+
Then a file named "/tmp/uricp/srv-testy" should exist
|
13
|
+
And the file named "/tmp/uricp/srv-testy" should have a file format of "qcow2"
|
14
|
+
|
15
|
+
Scenario: HTTP URI qcow2 via cache
|
16
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
17
|
+
When I successfully run `uricp --cache=/tmp/uricp https://foss-lab-manual.googlecode.com/files/freedos.qcow2 file:///tmp/uricp/srv-testy`
|
18
|
+
Then a file named "/tmp/uricp/srv-testy" should exist
|
19
|
+
And the file named "/tmp/uricp/srv-testy" should have a file format of "qcow2"
|
20
|
+
And a file named "/tmp/uricp/cache/freedos.qcow2" should exist
|
21
|
+
And the file named "/tmp/uricp/cache/freedos.qcow2" should have a file format of "qcow2"
|
22
|
+
|
23
|
+
Scenario: HTTP URI qcow2 to qcow2 via cache
|
24
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
25
|
+
When I successfully run `uricp --target-format=qcow2 --cache=/tmp/uricp https://foss-lab-manual.googlecode.com/files/freedos.qcow2 file:///tmp/uricp/srv-testy`
|
26
|
+
Then a file named "/tmp/uricp/srv-testy" should exist
|
27
|
+
And the file named "/tmp/uricp/srv-testy" should have a file format of "qcow2"
|
28
|
+
And a file named "/tmp/uricp/cache/freedos.qcow2" should exist
|
29
|
+
And the file named "/tmp/uricp/cache/freedos.qcow2" should have a file format of "qcow2"
|
30
|
+
|
31
|
+
Scenario: HTTP URI qcow2 to qcow2v3 via cache
|
32
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
33
|
+
When I successfully run `uricp --target-format=qcow2v3 --cache=/tmp/uricp https://foss-lab-manual.googlecode.com/files/freedos.qcow2 file:///tmp/uricp/srv-testy`
|
34
|
+
Then a file named "/tmp/uricp/srv-testy" should exist
|
35
|
+
And the file named "/tmp/uricp/srv-testy" should have a file format of "qcow2v3"
|
36
|
+
And a file named "/tmp/uricp/cache/freedos.qcow2" should exist
|
37
|
+
And the file named "/tmp/uricp/cache/freedos.qcow2" should have a file format of "qcow2"
|
38
|
+
|
39
|
+
Scenario: HTTP URI qcow2 to raw via cache
|
40
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
41
|
+
When I successfully run `uricp --target-format=raw --cache=/tmp/uricp https://foss-lab-manual.googlecode.com/files/freedos.qcow2 file:///tmp/uricp/srv-testy`
|
42
|
+
Then a file named "/tmp/uricp/srv-testy" should exist
|
43
|
+
And the file named "/tmp/uricp/srv-testy" should have a file format of "raw"
|
44
|
+
And a file named "/tmp/uricp/cache/freedos.qcow2" should exist
|
45
|
+
And the file named "/tmp/uricp/cache/freedos.qcow2" should have a file format of "qcow2"
|
46
|
+
|
47
|
+
|
48
|
+
Scenario: HTTP URI from cache
|
49
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
50
|
+
And a 102400 byte file named "/tmp/uricp/cache/freedos.qcow2"
|
51
|
+
When I successfully run `uricp --cache=/tmp/uricp https://foss-lab-manual.googlecode.com/files/freedos.qcow2 file:///tmp/uricp/srv-testy`
|
52
|
+
Then a 102400 byte file named "/tmp/uricp/srv-testy" should exist
|
53
|
+
And a 102400 byte file named "/tmp/uricp/cache/freedos.qcow2" should exist
|
54
|
+
|
55
|
+
Scenario: Unsupported source URI should error
|
56
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
57
|
+
When I run `uricp --target-format=raw --cache=/tmp/uricp wibble://some/url file:///tmp/uricp/srv-testy`
|
58
|
+
Then the exit status should not be 0
|
59
|
+
And the stderr should contain "Unsupported transfer"
|
60
|
+
|
61
|
+
Scenario: Unsupported target URI should error
|
62
|
+
Given a correctly initialised cache at "/tmp/uricp"
|
63
|
+
When I run `uricp --target-format=raw --cache=/tmp/uricp https://foss-lab-manual.googlecode.com/files/freedos.qcow2 http://foss-lab-manual.googlecode.com/files/freedos.qcow2`
|
64
|
+
Then the exit status should not be 0
|
65
|
+
And the stderr should contain "Unsupported transfer"
|
66
|
+
|
67
|
+
Scenario: Download from authorised http without authorisation
|
68
|
+
When I run `uricp https://orbit.brightbox.com/v1/acc-tqs4c/images/img-c5q5i file:///tmp/uricp/srv-testy`
|
69
|
+
Then the exit status should not be 0
|
70
|
+
And the stderr should contain "failed"
|
71
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
Feature: Documented Help
|
2
|
+
In order to work out what uricp does
|
3
|
+
As a command line user
|
4
|
+
I want to get detailed usage information
|
5
|
+
|
6
|
+
Scenario: Basic UI
|
7
|
+
When I get help for "uricp"
|
8
|
+
Then the exit status should be 0
|
9
|
+
And the banner should include the version
|
10
|
+
And the banner should document that this app takes options
|
11
|
+
And the following options should be documented:
|
12
|
+
|--version|
|
13
|
+
|--target-format|
|
14
|
+
|--cache|
|
15
|
+
|--auth-token|
|
16
|
+
|--auth-user|
|
17
|
+
|--auth-key|
|
18
|
+
|--segment|
|
19
|
+
And the option "compress" should be documented which is negatable
|
20
|
+
And the option "dry-run" should be documented which is negatable
|
21
|
+
And the banner should document that this app's arguments are:
|
22
|
+
|from_uri|which is required|
|
23
|
+
|to_uri|which is required|
|
24
|
+
|
25
|
+
Scenario: target format requires cache
|
26
|
+
When I run `uricp --target-format=qcow2 source target`
|
27
|
+
Then the exit status should not be 0
|
28
|
+
And the stderr should contain "missing argument"
|
29
|
+
|
30
|
+
Scenario: target format should be appropriate
|
31
|
+
When I run `uricp --target-format=fred --cache=/tmp source target`
|
32
|
+
Then the exit status should not be 0
|
33
|
+
And the stderr should contain "invalid argument"
|
34
|
+
|
35
|
+
Scenario: target format should support qcow3
|
36
|
+
When I run `uricp --target-format=qcow3 --cache=/tmp source target`
|
37
|
+
Then the exit status should not be 0
|
38
|
+
And the stderr should not contain "invalid argument"
|
39
|
+
|
40
|
+
Scenario: auth token and auth-user are mutually exclusive
|
41
|
+
When I run `uricp --auth-token abcdef --auth-user xyz --auth-key abc http://source file:///target`
|
42
|
+
Then the exit status should not be 0
|
43
|
+
And the stderr should contain "needless argument"
|
44
|
+
|
45
|
+
Scenario: auth user needs auth key
|
46
|
+
When I run `uricp --auth-user xyz http://source file:///target`
|
47
|
+
Then the exit status should not be 0
|
48
|
+
And the stderr should contain "missing argument"
|
49
|
+
|
50
|
+
Scenario: auth key needs auth user
|
51
|
+
When I run `uricp --auth-user xyz http://source file:///target`
|
52
|
+
Then the exit status should not be 0
|
53
|
+
And the stderr should contain "missing argument"
|
54
|
+
|
55
|
+
Scenario: authorisation with no http should fail
|
56
|
+
When I run `uricp --auth-token abcdef ftp://source file:///target`
|
57
|
+
Then the exit status should not be 0
|
58
|
+
And the stderr should contain "needless argument"
|
59
|
+
|
60
|
+
Scenario: authentication with normal http should fail
|
61
|
+
When I run `uricp --auth-user cli-xxxxx --auth-key fred https://foss-lab-manual.googlecode.com/files file://tmp/temp`
|
62
|
+
Then the exit status should not be 0
|
63
|
+
And the stderr should contain "Cannot authenticate"
|
64
|
+
|
65
|
+
Scenario: bad authentication should fail against orbit
|
66
|
+
When I run `uricp --auth-user cli-xxxxx --auth-key fred https://orbit.brightbox.com/v1/acc-xxxxx/test/test.img file://tmp/temp`
|
67
|
+
Then the exit status should not be 0
|
68
|
+
And the stderr should contain "Cannot authenticate"
|
69
|
+
|
70
|
+
Scenario: should not accept plain number for segment size
|
71
|
+
When I run `uricp --segment-size 100 --auth-token abcdef file:///tmp/temp https:///orbit.brightbox.com/v1/acc-xxxxx/test/test.img`
|
72
|
+
Then the exit status should not be 0
|
73
|
+
And the stderr should contain "Unparseable filesize"
|
@@ -0,0 +1,49 @@
|
|
1
|
+
@orbit
|
2
|
+
Feature: Upload VM images with authentication
|
3
|
+
In order to upload VM images to storage
|
4
|
+
As a command line user
|
5
|
+
I want to automatically convert and compress uploads to authenticated storage
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given a directory named "/tmp/uricp"
|
9
|
+
And the default aruba timeout is 15 seconds
|
10
|
+
And a container called "test_upload"
|
11
|
+
|
12
|
+
Scenario: Direct Upload
|
13
|
+
Given a 102400 byte file named "/tmp/uricp/srv-testy"
|
14
|
+
When I store "img-testy" into container "test_upload" from "file:///tmp/uricp/srv-testy"
|
15
|
+
Then a 102400 byte entry should exist in container "test_upload" called "img-testy"
|
16
|
+
|
17
|
+
Scenario: Compressed Upload
|
18
|
+
Given a 102400 byte file named "/tmp/uricp/srv-testy"
|
19
|
+
When I store "img-testy" with options "--compress" into container "test_upload" from "file:///tmp/uricp/srv-testy"
|
20
|
+
Then an lz4 compressed entry should exist in container "test_upload" called "img-testy"
|
21
|
+
|
22
|
+
Scenario: Direct Upload with userid
|
23
|
+
Given a 102400 byte file named "/tmp/uricp/srv-testa"
|
24
|
+
When I store "img-testa" into container "test_upload" from "file:///tmp/uricp/srv-testa" with a userid
|
25
|
+
Then a 102400 byte entry should exist in container "test_upload" called "img-testa"
|
26
|
+
|
27
|
+
Scenario: Direct segmented Upload with userid
|
28
|
+
Given a 102400 byte file named "/tmp/uricp/srv-testb"
|
29
|
+
When I store "img-testb" with segment size "10kiB" into container "test_upload" from "file:///tmp/uricp/srv-testb" with a userid
|
30
|
+
Then a 102400 byte entry should exist in container "test_upload" called "img-testb"
|
31
|
+
And the container "test_upload" should contain 11 entries
|
32
|
+
|
33
|
+
Scenario: Direct compressed segmented Upload with userid
|
34
|
+
Given a 102400 byte file named "/tmp/uricp/srv-testc"
|
35
|
+
When I store "img-testc" with segment size "10kiB" and options "--compress" into container "test_upload" from "file:///tmp/uricp/srv-testc" with a userid
|
36
|
+
Then an lz4 compressed entry should exist in container "test_upload" called "img-testc"
|
37
|
+
|
38
|
+
Scenario: Direct segmented Upload with userid in qcow2 format
|
39
|
+
Given a 102400 byte file named "/tmp/uricp/srv-testd"
|
40
|
+
And a correctly initialised cache at "/tmp/uricp"
|
41
|
+
When I store "img-testd" with segment size "10kiB" and options "--target-format 'qcow2' --cache /tmp/uricp" into container "test_upload" from "file:///tmp/uricp/srv-testd" with a userid
|
42
|
+
Then a qcow2 entry should exist in container "test_upload" called "img-testd"
|
43
|
+
|
44
|
+
Scenario: Direct segmented upload of lz4 file with userid in qcow2 format
|
45
|
+
Given a 102400 byte lz4 file named "/tmp/uricp/srv-teste"
|
46
|
+
And the default aruba timeout is 60 seconds
|
47
|
+
And a correctly initialised cache at "/tmp/uricp"
|
48
|
+
When I store "img-teste" with segment size "10kiB" and options "--target-format 'qcow2' --cache /tmp/uricp" into container "test_upload" from "file:///tmp/uricp/srv-teste" with a userid
|
49
|
+
Then a qcow2 entry should exist in container "test_upload" called "img-teste"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
@orbit
|
2
|
+
Feature: Segmented Upload Command
|
3
|
+
In order to upload streams in chunks
|
4
|
+
As a command line user
|
5
|
+
I want a tool that can do segmented uploads
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given a directory named "/tmp/uricp"
|
9
|
+
And the default aruba timeout is 15 seconds
|
10
|
+
And a container called "temp_dlo"
|
11
|
+
|
12
|
+
Scenario: Direct curl for smaller file
|
13
|
+
Given a 102400 byte file named "/tmp/uricp/srv-testy"
|
14
|
+
When I upload "img-testy" with segment size "100kib" into container "temp_dlo" from "/tmp/uricp/srv-testy"
|
15
|
+
Then a 102400 byte entry should exist in container "temp_dlo" called "img-testy"
|
16
|
+
|
17
|
+
Scenario: Create DLO with segmented file
|
18
|
+
Given a 102400 byte file named "/tmp/uricp/srv-testy"
|
19
|
+
When I upload "img-check" with segment size "10kib" into container "temp_dlo" from "/tmp/uricp/srv-testy"
|
20
|
+
Then a 102400 byte entry should exist in container "temp_dlo" called "img-check"
|
21
|
+
And the container "temp_dlo" should contain 11 entries
|
22
|
+
|
23
|
+
Scenario: Create DLO from stream
|
24
|
+
Given a 102400 byte file named "/tmp/uricp/srv-testb"
|
25
|
+
When I upload "img-testb" with segment size "10kib" into container "temp_dlo" from "/tmp/uricp/srv-testb" as a stream
|
26
|
+
Then a 102400 byte entry should exist in container "temp_dlo" called "img-testb"
|
27
|
+
And the container "temp_dlo" should contain 11 entries
|