From 09ba7e190e78cf79a7e42fde3cb0cc86d11aa836 Mon Sep 17 00:00:00 2001 From: Igor Rzegocki Date: Fri, 8 Oct 2021 12:59:26 +0200 Subject: [PATCH] fix: update rubies for ruby-nq and fullstack, set default ruby to 2.7 Fixes #266 --- .kitchen.yml | 3 +- attributes/default.rb | 2 +- docs/attributes.md | 2 +- spec/unit/recipes/setup_spec.rb | 240 ++++++++++-------- .../serverspec/all_options_spec.rb | 2 +- .../default/serverspec/default_spec.rb | 2 +- .../serverspec/maximum_override_spec.rb | 2 +- .../nullified/serverspec/nullified_spec.rb | 2 +- .../s3_thin_nginx_padrino_delayed_job_spec.rb | 2 +- 9 files changed, 142 insertions(+), 115 deletions(-) diff --git a/.kitchen.yml b/.kitchen.yml index d20254e4..d8c7803e 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -87,6 +87,7 @@ suites: - recipe[opsworks_ruby::setup] - recipe[opsworks_ruby::deploy] attributes: + 'ruby-version': '2.6' deploy: dummy_project: framework: @@ -220,4 +221,4 @@ suites: webserver: adapter: 'apache2' port: 8081 - 'ruby-version': '2.6' + 'ruby-version': '2.7' diff --git a/attributes/default.rb b/attributes/default.rb index 0db5c691..adfdf347 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -18,7 +18,7 @@ # ruby default['apt']['compile_time_update'] = true default['build-essential']['compile_time'] = true -default['ruby-version'] = node['ruby'].try(:[], 'version') || '2.6' +default['ruby-version'] = node['ruby'].try(:[], 'version') || '2.7' default['ruby-provider'] = 'ruby-ng' default['nginx']['source']['modules'] = %w[ nginx::http_ssl_module nginx::http_realip_module nginx::http_gzip_static_module nginx::headers_more_module diff --git a/docs/attributes.md b/docs/attributes.md index 7eb310c2..3356705c 100644 --- a/docs/attributes.md +++ b/docs/attributes.md @@ -42,7 +42,7 @@ They should'nt be used under `node['deploy'][]` (notice l (for example `ruby-ng` gets freshest versions of ruby way earlier than Amazon Linux). - **Type:** string - - **Default:** `2.6` + - **Default:** `3.0` - Sets the Ruby version used through the system. For debian-based distributions, a `ruby-ng` cookbook is used (check [ruby-ng cookbook documentation](https://supermarket.chef.io/cookbooks/ruby-ng)). For Amazon Linux, packages provided by distribution (i.e. `ruby23`, `ruby23-devel` etc.). diff --git a/spec/unit/recipes/setup_spec.rb b/spec/unit/recipes/setup_spec.rb index b5db3f70..1dee8ccd 100644 --- a/spec/unit/recipes/setup_spec.rb +++ b/spec/unit/recipes/setup_spec.rb @@ -185,6 +185,13 @@ end it 'installs ruby 2.6' do + chef_run = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |solo_node| + solo_node.set['ruby'] = { 'version' => '2.6' } + solo_node.set['lsb'] = node['lsb'] + solo_node.set['deploy'] = node['deploy'] + solo_node.set['ruby-provider'] = 'fullstaq' + end.converge(described_recipe) + expect(chef_run).to install_package('fullstaq-ruby-2.6') end @@ -200,6 +207,52 @@ expect(chef_run).to install_package('fullstaq-ruby-2.6-jemalloc') end + it 'installs ruby 2.7' do + chef_run = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |solo_node| + solo_node.set['ruby'] = { 'version' => '2.7' } + solo_node.set['lsb'] = node['lsb'] + solo_node.set['deploy'] = node['deploy'] + solo_node.set['ruby-provider'] = 'fullstaq' + end.converge(described_recipe) + + expect(chef_run).to install_package('fullstaq-ruby-2.7') + end + + it 'installs ruby 2.7 with variant' do + chef_run = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |solo_node| + solo_node.set['ruby'] = { 'version' => '2.7' } + solo_node.set['lsb'] = node['lsb'] + solo_node.set['deploy'] = node['deploy'] + solo_node.set['ruby-provider'] = 'fullstaq' + solo_node.set['ruby-variant'] = 'jemalloc' + end.converge(described_recipe) + + expect(chef_run).to install_package('fullstaq-ruby-2.7-jemalloc') + end + + it 'installs ruby 3.0' do + chef_run = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |solo_node| + solo_node.set['ruby'] = { 'version' => '3.0' } + solo_node.set['lsb'] = node['lsb'] + solo_node.set['deploy'] = node['deploy'] + solo_node.set['ruby-provider'] = 'fullstaq' + end.converge(described_recipe) + + expect(chef_run).to install_package('fullstaq-ruby-3.0') + end + + it 'installs ruby 3.0 with variant' do + chef_run = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |solo_node| + solo_node.set['ruby'] = { 'version' => '3.0' } + solo_node.set['lsb'] = node['lsb'] + solo_node.set['deploy'] = node['deploy'] + solo_node.set['ruby-provider'] = 'fullstaq' + solo_node.set['ruby-variant'] = 'jemalloc' + end.converge(described_recipe) + + expect(chef_run).to install_package('fullstaq-ruby-3.0-jemalloc') + end + it 'adds fullstaq apt repository' do keyurl = 'https://raw.githubusercontent.com/fullstaq-labs/fullstaq-ruby-server-edition/main/fullstaq-ruby.asc' @@ -252,6 +305,13 @@ end it 'installs ruby 2.6' do + chef_run_rhel = ChefSpec::SoloRunner.new(platform: 'amazon', version: '2015.03') do |solo_node| + solo_node.set['ruby'] = { 'version' => '2.6' } + solo_node.set['lsb'] = node['lsb'] + solo_node.set['deploy'] = node['deploy'] + solo_node.set['ruby-provider'] = 'fullstaq' + end.converge(described_recipe) + expect(chef_run_rhel).to install_package('fullstaq-ruby-2.6') end @@ -267,6 +327,52 @@ expect(chef_run_rhel).to install_package('fullstaq-ruby-2.6-jemalloc') end + it 'installs ruby 2.7' do + chef_run_rhel = ChefSpec::SoloRunner.new(platform: 'amazon', version: '2015.03') do |solo_node| + solo_node.set['ruby'] = { 'version' => '2.7' } + solo_node.set['lsb'] = node['lsb'] + solo_node.set['deploy'] = node['deploy'] + solo_node.set['ruby-provider'] = 'fullstaq' + end.converge(described_recipe) + + expect(chef_run_rhel).to install_package('fullstaq-ruby-2.7') + end + + it 'installs ruby 2.7 with variant' do + chef_run_rhel = ChefSpec::SoloRunner.new(platform: 'amazon', version: '2015.03') do |solo_node| + solo_node.set['ruby'] = { 'version' => '2.7' } + solo_node.set['lsb'] = node['lsb'] + solo_node.set['deploy'] = node['deploy'] + solo_node.set['ruby-provider'] = 'fullstaq' + solo_node.set['ruby-variant'] = 'jemalloc' + end.converge(described_recipe) + + expect(chef_run_rhel).to install_package('fullstaq-ruby-2.7-jemalloc') + end + + it 'installs ruby 3.0' do + chef_run_rhel = ChefSpec::SoloRunner.new(platform: 'amazon', version: '2015.03') do |solo_node| + solo_node.set['ruby'] = { 'version' => '3.0' } + solo_node.set['lsb'] = node['lsb'] + solo_node.set['deploy'] = node['deploy'] + solo_node.set['ruby-provider'] = 'fullstaq' + end.converge(described_recipe) + + expect(chef_run_rhel).to install_package('fullstaq-ruby-3.0') + end + + it 'installs ruby 3.0 with variant' do + chef_run_rhel = ChefSpec::SoloRunner.new(platform: 'amazon', version: '2015.03') do |solo_node| + solo_node.set['ruby'] = { 'version' => '3.0' } + solo_node.set['lsb'] = node['lsb'] + solo_node.set['deploy'] = node['deploy'] + solo_node.set['ruby-provider'] = 'fullstaq' + solo_node.set['ruby-variant'] = 'jemalloc' + end.converge(described_recipe) + + expect(chef_run_rhel).to install_package('fullstaq-ruby-3.0-jemalloc') + end + it 'adds fullstaq yum repository' do expect(chef_run_rhel).to create_yum_repository('fullstaq-ruby').with( baseurl: 'https://yum.fullstaqruby.org/centos-7/$basearch', @@ -283,156 +389,76 @@ context 'Rubies' do context 'Debian' do context 'ruby-ng' do - it 'installs ruby 2.0' do - chef_run = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |solo_node| - solo_node.set['ruby'] = { 'version' => '2.0' } - solo_node.set['lsb'] = node['lsb'] - solo_node.set['deploy'] = node['deploy'] - end.converge(described_recipe) - - expect(chef_run).to install_package('ruby2.0') - expect(chef_run).to install_package('ruby2.0-dev') - end - - it 'installs ruby 2.1' do - chef_run = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |solo_node| - solo_node.set['ruby'] = { 'version' => '2.1' } - solo_node.set['lsb'] = node['lsb'] - solo_node.set['deploy'] = node['deploy'] - end.converge(described_recipe) - - expect(chef_run).to install_package('ruby2.1') - expect(chef_run).to install_package('ruby2.1-dev') - end - - it 'installs ruby 2.2' do - chef_run = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |solo_node| - solo_node.set['ruby'] = { 'version' => '2.2' } - solo_node.set['lsb'] = node['lsb'] - solo_node.set['deploy'] = node['deploy'] - end.converge(described_recipe) - - expect(chef_run).to install_package('ruby2.2') - expect(chef_run).to install_package('ruby2.2-dev') - end - - it 'installs ruby 2.3' do + it 'installs ruby 2.5' do chef_run = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |solo_node| - solo_node.set['ruby'] = { 'version' => '2.3' } + solo_node.set['ruby'] = { 'version' => '2.5' } solo_node.set['lsb'] = node['lsb'] solo_node.set['deploy'] = node['deploy'] end.converge(described_recipe) - expect(chef_run).to install_package('ruby2.3') - expect(chef_run).to install_package('ruby2.3-dev') + expect(chef_run).to install_package('ruby2.5') + expect(chef_run).to install_package('ruby2.5-dev') end - it 'installs ruby 2.4' do + it 'installs ruby 2.6' do chef_run = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |solo_node| - solo_node.set['ruby'] = { 'version' => '2.4' } + solo_node.set['ruby'] = { 'version' => '2.6' } solo_node.set['lsb'] = node['lsb'] solo_node.set['deploy'] = node['deploy'] end.converge(described_recipe) - expect(chef_run).to install_package('ruby2.4') - expect(chef_run).to install_package('ruby2.4-dev') + expect(chef_run).to install_package('ruby2.6') + expect(chef_run).to install_package('ruby2.6-dev') end - it 'installs ruby 2.5' do + it 'installs ruby 2.7' do chef_run = ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |solo_node| - solo_node.set['ruby'] = { 'version' => '2.5' } + solo_node.set['ruby'] = { 'version' => '2.7' } solo_node.set['lsb'] = node['lsb'] solo_node.set['deploy'] = node['deploy'] end.converge(described_recipe) - expect(chef_run).to install_package('ruby2.5') - expect(chef_run).to install_package('ruby2.5-dev') - end - - it 'installs ruby 2.6' do - expect(chef_run).to install_package('ruby2.6') - expect(chef_run).to install_package('ruby2.6-dev') + expect(chef_run).to install_package('ruby2.7') + expect(chef_run).to install_package('ruby2.7-dev') end end end context 'rhel' do - it 'installs ruby 2.0' do - chef_run_rhel = ChefSpec::SoloRunner.new(platform: 'amazon', version: '2015.03') do |solo_node| - solo_node.set['ruby'] = { 'version' => '2.0' } - solo_node.set['lsb'] = node['lsb'] - solo_node.set['deploy'] = node['deploy'] - end.converge(described_recipe) - - expect(chef_run_rhel).to install_package('ruby20') - expect(chef_run_rhel).to install_package('ruby20-devel') - expect(chef_run_rhel).to run_execute('/usr/sbin/alternatives --set ruby /usr/bin/ruby2.0') - end - - it 'installs ruby 2.1' do - chef_run_rhel = ChefSpec::SoloRunner.new(platform: 'amazon', version: '2015.03') do |solo_node| - solo_node.set['ruby'] = { 'version' => '2.1' } - solo_node.set['lsb'] = node['lsb'] - solo_node.set['deploy'] = node['deploy'] - end.converge(described_recipe) - - expect(chef_run_rhel).to install_package('ruby21') - expect(chef_run_rhel).to install_package('ruby21-devel') - expect(chef_run_rhel).to run_execute('/usr/sbin/alternatives --set ruby /usr/bin/ruby2.1') - end - - it 'installs ruby 2.2' do - chef_run_rhel = ChefSpec::SoloRunner.new(platform: 'amazon', version: '2015.03') do |solo_node| - solo_node.set['ruby'] = { 'version' => '2.2' } - solo_node.set['lsb'] = node['lsb'] - solo_node.set['deploy'] = node['deploy'] - end.converge(described_recipe) - - expect(chef_run_rhel).to install_package('ruby22') - expect(chef_run_rhel).to install_package('ruby22-devel') - expect(chef_run_rhel).to run_execute('/usr/sbin/alternatives --set ruby /usr/bin/ruby2.2') - end - - it 'installs ruby 2.3' do + it 'installs ruby 2.5' do chef_run_rhel = ChefSpec::SoloRunner.new(platform: 'amazon', version: '2015.03') do |solo_node| - solo_node.set['ruby'] = { 'version' => '2.3' } + solo_node.set['ruby'] = { 'version' => '2.5' } solo_node.set['lsb'] = node['lsb'] solo_node.set['deploy'] = node['deploy'] end.converge(described_recipe) - expect(chef_run_rhel).to install_package('ruby23') - expect(chef_run_rhel).to install_package('ruby23-devel') - expect(chef_run_rhel).to run_execute('/usr/sbin/alternatives --set ruby /usr/bin/ruby2.3') + expect(chef_run_rhel).to install_package('ruby25') + expect(chef_run_rhel).to install_package('ruby25-devel') + expect(chef_run_rhel).to run_execute('/usr/sbin/alternatives --set ruby /usr/bin/ruby2.5') end - it 'installs ruby 2.4' do + it 'installs ruby 2.6' do chef_run_rhel = ChefSpec::SoloRunner.new(platform: 'amazon', version: '2015.03') do |solo_node| - solo_node.set['ruby'] = { 'version' => '2.4' } + solo_node.set['ruby'] = { 'version' => '2.6' } solo_node.set['lsb'] = node['lsb'] solo_node.set['deploy'] = node['deploy'] end.converge(described_recipe) - expect(chef_run_rhel).to install_package('ruby24') - expect(chef_run_rhel).to install_package('ruby24-devel') - expect(chef_run_rhel).to run_execute('/usr/sbin/alternatives --set ruby /usr/bin/ruby2.4') + expect(chef_run_rhel).to install_package('ruby26') + expect(chef_run_rhel).to install_package('ruby26-devel') + expect(chef_run_rhel).to run_execute('/usr/sbin/alternatives --set ruby /usr/bin/ruby2.6') end - it 'installs ruby 2.5' do + it 'installs ruby 2.7' do chef_run_rhel = ChefSpec::SoloRunner.new(platform: 'amazon', version: '2015.03') do |solo_node| - solo_node.set['ruby'] = { 'version' => '2.5' } + solo_node.set['ruby'] = { 'version' => '2.7' } solo_node.set['lsb'] = node['lsb'] solo_node.set['deploy'] = node['deploy'] end.converge(described_recipe) - expect(chef_run_rhel).to install_package('ruby25') - expect(chef_run_rhel).to install_package('ruby25-devel') - expect(chef_run_rhel).to run_execute('/usr/sbin/alternatives --set ruby /usr/bin/ruby2.5') - end - - it 'installs ruby 2.6' do - expect(chef_run_rhel).to install_package('ruby26') - expect(chef_run_rhel).to install_package('ruby26-devel') - expect(chef_run_rhel).to run_execute('/usr/sbin/alternatives --set ruby /usr/bin/ruby2.6') + expect(chef_run_rhel).to install_package('ruby27') + expect(chef_run_rhel).to install_package('ruby27-devel') + expect(chef_run_rhel).to run_execute('/usr/sbin/alternatives --set ruby /usr/bin/ruby2.7') end end end diff --git a/test/integration/all_options/serverspec/all_options_spec.rb b/test/integration/all_options/serverspec/all_options_spec.rb index c92583e4..adf88554 100644 --- a/test/integration/all_options/serverspec/all_options_spec.rb +++ b/test/integration/all_options/serverspec/all_options_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'opsworks_ruby::setup' do - describe package('ruby2.6') do + describe package('ruby2.7') do it { should be_installed } end diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb index 1d7c7772..df5d03e6 100644 --- a/test/integration/default/serverspec/default_spec.rb +++ b/test/integration/default/serverspec/default_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'opsworks_ruby::setup' do - describe package('ruby2.6') do + describe package('ruby2.7') do it { should be_installed } end diff --git a/test/integration/maximum_override/serverspec/maximum_override_spec.rb b/test/integration/maximum_override/serverspec/maximum_override_spec.rb index 25f2c5cc..b68d1367 100644 --- a/test/integration/maximum_override/serverspec/maximum_override_spec.rb +++ b/test/integration/maximum_override/serverspec/maximum_override_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'opsworks_ruby::setup' do - describe package('ruby2.6') do + describe package('ruby2.7') do it { should be_installed } end diff --git a/test/integration/nullified/serverspec/nullified_spec.rb b/test/integration/nullified/serverspec/nullified_spec.rb index ad804f4d..d5042af1 100644 --- a/test/integration/nullified/serverspec/nullified_spec.rb +++ b/test/integration/nullified/serverspec/nullified_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'opsworks_ruby::setup' do - describe package('ruby2.6') do + describe package('ruby2.7') do it { should be_installed } end diff --git a/test/integration/s3_thin_nginx_padrino_delayed_job/serverspec/s3_thin_nginx_padrino_delayed_job_spec.rb b/test/integration/s3_thin_nginx_padrino_delayed_job/serverspec/s3_thin_nginx_padrino_delayed_job_spec.rb index f7ad5fb4..2dc2bcf9 100644 --- a/test/integration/s3_thin_nginx_padrino_delayed_job/serverspec/s3_thin_nginx_padrino_delayed_job_spec.rb +++ b/test/integration/s3_thin_nginx_padrino_delayed_job/serverspec/s3_thin_nginx_padrino_delayed_job_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'opsworks_ruby::setup' do - describe package('ruby2.6') do + describe package('ruby2.7') do it { should be_installed } end