uricp 0.0.15 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/Gemfile.lock +16 -21
  4. data/Jenkinsfile +90 -33
  5. data/Rakefile +24 -36
  6. data/almalinux8/Dockerfile +26 -0
  7. data/bin/uricp +25 -11
  8. data/bionic/Dockerfile +4 -3
  9. data/centos7/Dockerfile +17 -12
  10. data/cucumber.yml +1 -0
  11. data/features/check_uri_path.feature +14 -0
  12. data/features/rbd_access.feature +226 -0
  13. data/features/step_definitions/orbit_steps.rb +11 -4
  14. data/features/step_definitions/rbd_steps.rb +8 -0
  15. data/features/step_definitions/uricp_steps.rb +8 -4
  16. data/focal/Dockerfile +28 -0
  17. data/lib/segment_upload.rb +20 -22
  18. data/lib/uricp/curl_primitives.rb +31 -33
  19. data/lib/uricp/orbit_auth.rb +23 -27
  20. data/lib/uricp/segmenter.rb +12 -16
  21. data/lib/uricp/strategy/cache_common.rb +30 -12
  22. data/lib/uricp/strategy/cached_get.rb +19 -22
  23. data/lib/uricp/strategy/cleaner.rb +2 -8
  24. data/lib/uricp/strategy/common.rb +76 -18
  25. data/lib/uricp/strategy/local_convert.rb +10 -17
  26. data/lib/uricp/strategy/local_link.rb +10 -8
  27. data/lib/uricp/strategy/piped_cache.rb +11 -16
  28. data/lib/uricp/strategy/piped_cache_convert.rb +14 -18
  29. data/lib/uricp/strategy/piped_compress.rb +3 -8
  30. data/lib/uricp/strategy/piped_decompress.rb +7 -11
  31. data/lib/uricp/strategy/piped_local_compress.rb +0 -4
  32. data/lib/uricp/strategy/piped_local_decompress.rb +10 -16
  33. data/lib/uricp/strategy/piped_local_get.rb +0 -5
  34. data/lib/uricp/strategy/piped_local_put.rb +3 -9
  35. data/lib/uricp/strategy/piped_rbd_get.rb +30 -0
  36. data/lib/uricp/strategy/piped_remote_get.rb +20 -20
  37. data/lib/uricp/strategy/rbd_cache_base_snap.rb +27 -0
  38. data/lib/uricp/strategy/rbd_cache_check.rb +42 -0
  39. data/lib/uricp/strategy/rbd_cache_clone.rb +40 -0
  40. data/lib/uricp/strategy/rbd_cache_upload.rb +40 -0
  41. data/lib/uricp/strategy/rbd_cached_get.rb +36 -0
  42. data/lib/uricp/strategy/rbd_cached_put.rb +33 -0
  43. data/lib/uricp/strategy/rbd_flattener.rb +23 -0
  44. data/lib/uricp/strategy/rbd_put.rb +38 -0
  45. data/lib/uricp/strategy/rbd_snap.rb +56 -0
  46. data/lib/uricp/strategy/rbd_sweeper.rb +23 -0
  47. data/lib/uricp/strategy/remote_put.rb +11 -17
  48. data/lib/uricp/strategy/segmented_remote_put.rb +16 -28
  49. data/lib/uricp/strategy/sweeper.rb +2 -8
  50. data/lib/uricp/uri_strategy.rb +22 -13
  51. data/lib/uricp/version.rb +4 -2
  52. data/lib/uricp.rb +27 -19
  53. data/uricp.gemspec +3 -3
  54. data/xenial/Dockerfile +4 -3
  55. metadata +41 -25
  56. data/spec/something_spec.rb +0 -5
  57. data/trusty/Dockerfile +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34a83d1c4afd7b3c2b43eeec01b42e06ff8ea55edf8450110ca70363be693d64
4
- data.tar.gz: 64d75d6bc450453f5e2204ab085759a912c265116934be3d7595861f1b5dafb8
3
+ metadata.gz: e77694a18e045d2917d254afcb2db0a2c4cb7d81471d3ccabfe5c232bc340408
4
+ data.tar.gz: c063c5315485f25194e2f195c821470f0cc840cc242a0f88c174653a3a3bf167
5
5
  SHA512:
6
- metadata.gz: f92262c06bf7b035a453fb51358d429e8617487c76df209520abf3d0d322644787e4cbec5d83fdd77fa8a749de41d29e30e1b00248963efd2a26bdfcaf8edc56
7
- data.tar.gz: 1f6533f5334330c3653da3e952715428478f55f1b956d9fdb9b9b9290d7ff0c45391fce3363c132f8dcb85deeb47930ef4dda36cdc1baea9f52a12ae98c4d2f2
6
+ metadata.gz: e8af0949b1de2c8c414d8c60f69390ebc5c722189ff9d86b3c0201c3a30aecded256c8c38be244516834ba97ca7e3ee58c325444304f766cef55b11053d018af
7
+ data.tar.gz: db89854277d707b488ef4c86bad899407445ff62bd9815aa60259f636b473e17905a83bd53b120f287eabe60012cb20681015a45ef752d3d98660ed6e4b01f71
data/.rubocop.yml ADDED
@@ -0,0 +1,3 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uricp (0.0.15)
4
+ uricp (0.0.20)
5
+ childprocess (~> 1.0)
5
6
  filesize (= 0.0.2)
6
- methadone (~> 2.0.0)
7
+ methadone (~> 2.0.2)
7
8
  open4 (~> 1.3.0)
8
9
  sendfile (~> 1.2.0)
9
10
 
@@ -14,38 +15,33 @@ GEM
14
15
  childprocess (>= 0.3.6)
15
16
  cucumber (>= 1.1.1)
16
17
  rspec-expectations (>= 2.7.0)
17
- builder (3.2.3)
18
- childprocess (0.9.0)
19
- ffi (~> 1.0, >= 1.0.11)
18
+ builder (3.2.4)
19
+ childprocess (1.0.1)
20
+ rake (< 13.0)
20
21
  cucumber (1.3.20)
21
22
  builder (>= 2.1.2)
22
23
  diff-lcs (>= 1.1.3)
23
24
  gherkin (~> 2.12)
24
25
  multi_json (>= 1.7.5, < 2.0)
25
26
  multi_test (>= 0.1.2)
26
- diff-lcs (1.3)
27
- ffi (1.9.23)
27
+ diff-lcs (1.4.4)
28
28
  filesize (0.0.2)
29
29
  gherkin (2.12.2)
30
30
  multi_json (~> 1.3)
31
31
  inifile (1.1.0)
32
32
  json (1.8.6)
33
- methadone (2.0.0)
33
+ methadone (2.0.2)
34
34
  bundler
35
- multi_json (1.13.1)
35
+ multi_json (1.15.0)
36
36
  multi_test (0.1.2)
37
37
  open4 (1.3.4)
38
- rake (10.4.2)
38
+ rake (12.3.3)
39
39
  rdoc (4.2.2)
40
40
  json (~> 1.4)
41
- rspec (2.99.0)
42
- rspec-core (~> 2.99.0)
43
- rspec-expectations (~> 2.99.0)
44
- rspec-mocks (~> 2.99.0)
45
- rspec-core (2.99.2)
46
- rspec-expectations (2.99.2)
47
- diff-lcs (>= 1.1.3, < 2.0)
48
- rspec-mocks (2.99.4)
41
+ rspec-expectations (3.10.1)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.10.0)
44
+ rspec-support (3.10.2)
49
45
  sendfile (1.2.2)
50
46
 
51
47
  PLATFORMS
@@ -56,10 +52,9 @@ DEPENDENCIES
56
52
  bundler (~> 1.7)
57
53
  cucumber (~> 1.3)
58
54
  inifile (~> 1.1)
59
- rake (~> 10.4.0)
55
+ rake (~> 12.3)
60
56
  rdoc (~> 4.2.0)
61
- rspec (~> 2.99)
62
57
  uricp!
63
58
 
64
59
  BUNDLED WITH
65
- 1.16.1
60
+ 1.17.3
data/Jenkinsfile CHANGED
@@ -2,6 +2,8 @@ pipeline {
2
2
  environment {
3
3
  ORBIT = credentials('ced8ecd0-dbe4-4bf6-bdde-101a661565f5')
4
4
  ORBIT_URL = credentials('c0c95c56-b4e9-45c2-85c5-bf292aef7301')
5
+ RBD = credentials('9bfb46f5-65eb-40c3-bfda-7ac5fe469ff4')
6
+ CEPH_MON = credentials('ceph-mon')
5
7
  ORBIT_USER = "${ORBIT_USR}"
6
8
  ORBIT_KEY = "${ORBIT_PSW}"
7
9
  }
@@ -14,73 +16,128 @@ pipeline {
14
16
  }
15
17
  agent none
16
18
  stages {
19
+ stage("AlmaLinux 8") {
20
+ agent {
21
+ dockerfile {
22
+ dir 'almalinux8'
23
+ label "docker"
24
+ additionalBuildArgs '--build-arg CEPH_MON --build-arg RBD_USR --build-arg RBD_PSW'
25
+ }
26
+ }
27
+ steps {
28
+ sh 'rbd --id "${RBD_USR}" ls servers'
29
+ sh 'bundle install --deployment'
30
+ sh 'bundle exec rake features:new_qemu'
31
+ }
32
+ post {
33
+ always {
34
+ sh 'bundle exec rake features:clean'
35
+ }
36
+ failure {
37
+ mail to: 'sysadmin@brightbox.co.uk',
38
+ subject: "Uricp Tests Failed: ${currentBuild.fullDisplayName}",
39
+ body: "${env.BUILD_URL}"
40
+ }
41
+ }
42
+ }
17
43
  stage("CentOS 7") {
18
44
  agent {
19
- dockerfile {
20
- dir 'centos7'
21
- label "docker"
22
- }
45
+ dockerfile {
46
+ dir 'centos7'
47
+ label "docker"
48
+ additionalBuildArgs '--build-arg CEPH_MON --build-arg RBD_USR --build-arg RBD_PSW'
49
+ }
23
50
  }
24
51
  steps {
25
- sh 'bundle install --deployment'
26
- sh 'bundle exec rake features:new_qemu'
52
+ sh 'rbd --id "${RBD_USR}" ls servers'
53
+ sh 'bundle install --deployment'
54
+ sh 'bundle exec rake features:new_qemu'
27
55
  }
28
56
  post {
29
57
  always {
30
- sh 'bundle exec rake features:clean'
31
- }
58
+ sh 'bundle exec rake features:clean'
59
+ }
60
+ failure {
61
+ mail to: 'sysadmin@brightbox.co.uk',
62
+ subject: "Uricp Tests Failed: ${currentBuild.fullDisplayName}",
63
+ body: "${env.BUILD_URL}"
64
+ }
32
65
  }
33
66
  }
34
- stage("Trusty, Ruby 1.9.3") {
67
+ stage("Focal, Ruby 2.7.0") {
35
68
  agent {
36
- dockerfile {
37
- dir 'trusty'
38
- label "docker"
39
- }
69
+ dockerfile {
70
+ dir 'focal'
71
+ label "docker"
72
+ additionalBuildArgs '--build-arg CEPH_MON --build-arg RBD_USR --build-arg RBD_PSW'
73
+ }
40
74
  }
41
75
  steps {
42
- sh 'bundle install --deployment'
43
- sh 'bundle exec rake features:new_qemu'
76
+ sh 'rbd --id "${RBD_USR}" ls servers'
77
+ sh 'bundle install --deployment'
78
+ sh 'bundle exec rake features:new_qemu'
44
79
  }
45
80
  post {
46
81
  always {
47
- sh 'bundle exec rake features:clean'
48
- }
82
+ sh 'bundle exec rake features:clean'
83
+ }
84
+ failure {
85
+ mail to: 'sysadmin@brightbox.co.uk',
86
+ subject: "Uricp Tests Failed: ${currentBuild.fullDisplayName}",
87
+ body: "${env.BUILD_URL}"
88
+ }
49
89
  }
50
90
  }
51
91
  stage("Xenial, Ruby 2.3.1") {
52
92
  agent {
53
- dockerfile {
54
- dir 'xenial'
55
- label "docker"
56
- }
93
+ dockerfile {
94
+ dir 'xenial'
95
+ label "docker"
96
+ }
57
97
  }
58
98
  steps {
59
- sh 'bundle install --deployment'
60
- sh 'bundle exec rake features:new_qemu'
99
+ sh 'bundle install --deployment'
100
+ sh 'bundle exec rake features:new_qemu'
61
101
  }
62
102
  post {
63
103
  always {
64
- sh 'bundle exec rake features:clean'
65
- }
104
+ sh 'bundle exec rake features:clean'
105
+ }
106
+ failure {
107
+ mail to: 'sysadmin@brightbox.co.uk',
108
+ subject: "Uricp Tests Failed: ${currentBuild.fullDisplayName}",
109
+ body: "${env.BUILD_URL}"
110
+ }
66
111
  }
67
112
  }
68
113
  stage("Bionic, Ruby 2.5.1") {
69
114
  agent {
70
- dockerfile {
71
- dir 'bionic'
72
- label "docker"
73
- }
115
+ dockerfile {
116
+ dir 'bionic'
117
+ label "docker"
118
+ }
74
119
  }
75
120
  steps {
76
- sh 'bundle install --deployment'
77
- sh 'bundle exec rake features:new_qemu'
121
+ sh 'bundle install --deployment'
122
+ sh 'bundle exec rake features:new_qemu'
78
123
  }
79
124
  post {
80
125
  always {
81
- sh 'bundle exec rake features:clean'
82
- }
126
+ sh 'bundle exec rake features:clean'
127
+ }
128
+ failure {
129
+ mail to: 'sysadmin@brightbox.co.uk',
130
+ subject: "Uricp Tests Failed: ${currentBuild.fullDisplayName}",
131
+ body: "${env.BUILD_URL}"
132
+ }
83
133
  }
84
134
  }
85
135
  }
136
+ post {
137
+ failure {
138
+ mail to: 'sysadmin@brightbox.co.uk',
139
+ subject: "Uricp Tests Failed: ${currentBuild.fullDisplayName}",
140
+ body: "${env.BUILD_URL}"
141
+ }
142
+ }
86
143
  }
data/Rakefile CHANGED
@@ -2,19 +2,19 @@ def dump_load_path
2
2
  puts $LOAD_PATH.join("\n")
3
3
  found = nil
4
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
5
+ next unless File.exist?(File.join(path, 'rspec'))
6
+
7
+ puts "Found rspec in #{path}"
8
+ if File.exist?(File.join(path, 'rspec', 'core'))
9
+ puts 'Found core'
10
+ if File.exist?(File.join(path, 'rspec', 'core', 'rake_task'))
11
+ puts 'Found rake_task'
12
+ found = path
15
13
  else
16
- puts "!!! no core"
14
+ puts '!! no rake_task'
17
15
  end
16
+ else
17
+ puts '!!! no core'
18
18
  end
19
19
  end
20
20
  if found.nil?
@@ -26,13 +26,6 @@ end
26
26
  require 'bundler'
27
27
  require 'rake/clean'
28
28
 
29
- begin
30
- require 'rspec/core/rake_task'
31
- rescue LoadError
32
- dump_load_path
33
- raise
34
- end
35
-
36
29
  require 'cucumber'
37
30
  require 'cucumber/rake/task'
38
31
  gem 'rdoc' # we need the installed RDoc gem, not the system one
@@ -42,13 +35,7 @@ include Rake::DSL
42
35
 
43
36
  Bundler::GemHelper.install_tasks
44
37
 
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'
38
+ CUKE_RESULTS = 'results.html'.freeze
52
39
  CLEAN << CUKE_RESULTS
53
40
  namespace(:features) do
54
41
  Cucumber::Rake::Task.new(:new_qemu) do |t|
@@ -61,14 +48,17 @@ namespace(:features) do
61
48
  t.fork = false
62
49
  t.profile = 'old-qemu-image'
63
50
  end
51
+ Cucumber::Rake::Task.new(:rbd) do |t|
52
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
53
+ t.fork = false
54
+ t.profile = 'rbd'
55
+ end
64
56
 
65
57
  task(:clean) do
66
58
  if ENV['ORBIT_USER'] && ENV['ORBIT_KEY']
67
- %w{temp_dlo test_upload}.each do |test_file|
68
- sh "swift --quiet --insecure -A #{ENV['ORBIT_URL'] || "https://orbit.gb1.brightbox.com/v1"} -U #{ENV['ORBIT_USER']} -K #{ENV['ORBIT_KEY']} delete #{test_file}" do |ok, res|
69
- if !ok
70
- puts "Delete failed: #{res.exitstatus}"
71
- end
59
+ %w[temp_dlo test_upload].each do |test_file|
60
+ sh "swift --quiet --insecure -A #{ENV['ORBIT_URL'] || 'https://orbit.gb1.brightbox.com/v1'} -U #{ENV['ORBIT_USER']} -K #{ENV['ORBIT_KEY']} delete #{test_file}" do |ok, res|
61
+ puts "Delete failed: #{res.exitstatus}" unless ok
72
62
  end
73
63
  end
74
64
  end
@@ -76,11 +66,9 @@ namespace(:features) do
76
66
  end
77
67
 
78
68
  Rake::RDocTask.new do |rd|
79
-
80
- rd.main = "README.rdoc"
81
-
82
- rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
83
- end
69
+ rd.main = 'README.rdoc'
84
70
 
85
- task :default => [:spec,"features:new_qemu"]
71
+ rd.rdoc_files.include('README.rdoc', 'lib/**/*.rb', 'bin/**/*')
72
+ end
86
73
 
74
+ task default: [:spec, 'features:new_qemu']
@@ -0,0 +1,26 @@
1
+ FROM almalinux:8
2
+ MAINTAINER support@brightbox.co.uk
3
+
4
+ RUN echo "gem: --no-ri --no-rdoc" >> "$HOME/.gemrc"
5
+ RUN dnf -y install dnf-plugins-core
6
+ RUN dnf config-manager --add-repo https://repo.almalinux.org/almalinux/8.4/devel/almalinux-devel.repo
7
+ RUN dnf -y update
8
+ RUN dnf config-manager --set-enabled powertools,devel
9
+ RUN dnf -y group install "Development Tools"
10
+ RUN dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
11
+ RUN dnf -y install https://www.rdoproject.org/repos/rdo-release.el8.rpm
12
+ RUN dnf -y install \
13
+ git \
14
+ lz4 \
15
+ qemu-img \
16
+ ruby-devel \
17
+ rubygems \
18
+ rubygem-bundler \
19
+ python3-swiftclient \
20
+ ceph-common
21
+ RUN mkdir -p /etc/ceph
22
+ ARG RBD_USR=libvirt
23
+ ARG RBD_PSW
24
+ ARG CEPH_MON
25
+ RUN echo -e "[client.$RBD_USR]\nkey = $RBD_PSW\n" > /etc/ceph/ceph.client.$RBD_USR.keyring
26
+ RUN echo -e "[global]\nmon_host = $CEPH_MON\n" > /etc/ceph/ceph.conf
data/bin/uricp CHANGED
@@ -4,7 +4,7 @@ require 'optparse'
4
4
  require 'uri'
5
5
  require 'methadone'
6
6
  require 'filesize'
7
- require 'uricp.rb'
7
+ require 'uricp'
8
8
 
9
9
  class App
10
10
  include Methadone::Main
@@ -52,20 +52,32 @@ class App
52
52
  def self.build_command
53
53
  command_sequence = Uricp::UriStrategy.choose_strategy(options)
54
54
  debug "#{self.name} Command sequence is #{command_sequence.inspect}"
55
- command_sequence.map{|c| c.command}.join('')
55
+ command_sequence.map do |c|
56
+ debug c.class.name
57
+ c.command
58
+ end.join('')
56
59
  end
57
60
 
58
61
  def self.validate_options
59
- unless options['cache']
60
- case
61
- when options['target-format']
62
- raise ::OptionParser::MissingArgument,
63
- "'target-format' requires 'cache' option"
64
- when options['max-cache']
65
- raise ::OptionParser::MissingArgument,
66
- "'max-cache' requires 'cache' option"
67
- end
62
+ case
63
+ when options['from_uri'].path.nil?
64
+ raise ::OptionParser::InvalidArgument,
65
+ "'from_uri' has missing path"
66
+ when options['to_uri'].path.nil?
67
+ raise ::OptionParser::InvalidArgument,
68
+ "'to_uri' has missing path"
68
69
  end
70
+ return if options['cache']
71
+
72
+ case
73
+ when options['target-format']
74
+ raise ::OptionParser::MissingArgument,
75
+ "'target-format' requires 'cache' option"
76
+ when options['max-cache']
77
+ raise ::OptionParser::MissingArgument,
78
+ "'max-cache' requires 'cache' option"
79
+ end
80
+
69
81
  end
70
82
 
71
83
  def self.add_cache_name
@@ -109,6 +121,8 @@ class App
109
121
  "Compress output")
110
122
  on("--[no-]dry-run",
111
123
  "Show what would be run,", "but don't run the command")
124
+ on("--[no-]dry-cache",
125
+ "On dry runs assume the cache is populated")
112
126
  on("--[no-]force",
113
127
  "Always write sparsely")
114
128
  #Arguments