diff --git a/Vagrantfile b/Vagrantfile index 3f22eac..1f3d9f0 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -5,7 +5,7 @@ require 'fileutils' # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" -VAGRANT_HYPCONFIGMGMT_VERSION = "0.0.9" +VAGRANT_HYPCONFIGMGMT_VERSION = "0.0.10" # if vagrant-hypconfigmgmt is not installed, install it and abort if !Vagrant.has_plugin?("vagrant-hypconfigmgmt", version = VAGRANT_HYPCONFIGMGMT_VERSION) && !ARGV.include?("plugin") && !ARGV.include?("status") diff --git a/tools/hypernode-vagrant-runner/hypernode_vagrant_runner/commands.py b/tools/hypernode-vagrant-runner/hypernode_vagrant_runner/commands.py index ba25ad5..756ef5c 100644 --- a/tools/hypernode-vagrant-runner/hypernode_vagrant_runner/commands.py +++ b/tools/hypernode-vagrant-runner/hypernode_vagrant_runner/commands.py @@ -3,7 +3,7 @@ from hypernode_vagrant_runner.log import setup_logging from hypernode_vagrant_runner.runner import launch_runner from hypernode_vagrant_runner.settings import HYPERNODE_VAGRANT_PHP_VERSIONS, HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION, \ - HYPERNODE_VAGRANT_DEFAULT_USER, HYPERNODE_VAGRANT_USERS, UPLOAD_PATH + HYPERNODE_VAGRANT_DEFAULT_USER, HYPERNODE_VAGRANT_USERS, UPLOAD_PATH, PRECISE_UNAVAILABLE_PHP def parse_arguments(parser): @@ -86,10 +86,10 @@ def parse_start_runner_arguments(): help='Run "vagrant up" with the --no-provision flag' ) args = parse_arguments(parser) - if not args.xenial and args.php == '5.6': + if not args.xenial and args.php in PRECISE_UNAVAILABLE_PHP: parser.error( - "Can't use the Precise Hypernode with PHP5.6. " - "Add the --xenial flag to use the Xenial version" + "Can't use the Precise Hypernode with PHP{}. " + "Add the --xenial flag to use the Xenial version".format(args.php) ) return args diff --git a/tools/hypernode-vagrant-runner/hypernode_vagrant_runner/settings.py b/tools/hypernode-vagrant-runner/hypernode_vagrant_runner/settings.py index 3fcb45c..b50bd54 100644 --- a/tools/hypernode-vagrant-runner/hypernode_vagrant_runner/settings.py +++ b/tools/hypernode-vagrant-runner/hypernode_vagrant_runner/settings.py @@ -1,3 +1,4 @@ +PRECISE_UNAVAILABLE_PHP = ['5.6', '7.1'] HYPERNODE_VAGRANT_REPOSITORY = 'https://github.com/byteinternet/hypernode-vagrant' REQUIRED_VAGRANT_PLUGINS = [ 'vagrant-vbguest', @@ -6,7 +7,8 @@ HYPERNODE_VAGRANT_PHP_VERSIONS = [ '5.5', '5.6', - '7.0' + '7.0', + '7.1' ] HYPERNODE_VAGRANT_BOX_NAMES = { '5.5': 'hypernode_php5', @@ -28,8 +30,7 @@ 'vagrant' ] -# Use the last available PHP version as the default -HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION = HYPERNODE_VAGRANT_PHP_VERSIONS[-1] +HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION = '7.0' HYPERNODE_VAGRANT_CONFIGURATION = """ --- diff --git a/tools/hypernode-vagrant-runner/hypernode_vagrant_runner/vagrant/set_up.py b/tools/hypernode-vagrant-runner/hypernode_vagrant_runner/vagrant/set_up.py index 1f3289e..1c8691c 100644 --- a/tools/hypernode-vagrant-runner/hypernode_vagrant_runner/vagrant/set_up.py +++ b/tools/hypernode-vagrant-runner/hypernode_vagrant_runner/vagrant/set_up.py @@ -99,7 +99,7 @@ def write_hypernode_vagrant_configuration( directory, php_version=HYPERNODE_VAGRANT_DEFAULT_PHP_VERSION, xdebug_enabled=False, - xenial=False + xenial=True ): """ Write the hypernode-vagrant local.yml configuration file to the diff --git a/tools/hypernode-vagrant-runner/tests/unit/hypernode_vagrant_runner/commands/test_parse_start_runner_arguments.py b/tools/hypernode-vagrant-runner/tests/unit/hypernode_vagrant_runner/commands/test_parse_start_runner_arguments.py index e72a9c5..f91e26e 100644 --- a/tools/hypernode-vagrant-runner/tests/unit/hypernode_vagrant_runner/commands/test_parse_start_runner_arguments.py +++ b/tools/hypernode-vagrant-runner/tests/unit/hypernode_vagrant_runner/commands/test_parse_start_runner_arguments.py @@ -156,6 +156,14 @@ def test_parse_start_runner_arguments_errors_when_php56_and_precise(self): self.argument_parser.return_value.error.assert_called_once_with(ANY) + def test_parse_start_runner_arguments_errors_when_php71_and_precise(self): + self.parse_arguments.return_value.php = '7.1' + self.parse_arguments.return_value.xenial = False + + parse_start_runner_arguments() + + self.argument_parser.return_value.error.assert_called_once_with(ANY) + def test_parse_start_runner_arguments_does_not_error_when_php55_and_precise(self): self.parse_arguments.return_value.php = '5.5' self.parse_arguments.return_value.xenial = False @@ -170,3 +178,10 @@ def test_parse_start_runner_arguments_does_not_error_if_php56_and_xenial(self): parse_start_runner_arguments() self.assertFalse(self.argument_parser.return_value.error.called) + + def test_parse_start_runner_arguments_does_not_error_if_php71_and_xenial(self): + self.parse_arguments.return_value.php = '7.1' + + parse_start_runner_arguments() + + self.assertFalse(self.argument_parser.return_value.error.called) diff --git a/tools/hypernode-vagrant-runner/tests/unit/hypernode_vagrant_runner/vagrant/set_up/test_write_hypernode_vagrant_configuration.py b/tools/hypernode-vagrant-runner/tests/unit/hypernode_vagrant_runner/vagrant/set_up/test_write_hypernode_vagrant_configuration.py index a36bfb1..cf8bef0 100644 --- a/tools/hypernode-vagrant-runner/tests/unit/hypernode_vagrant_runner/vagrant/set_up/test_write_hypernode_vagrant_configuration.py +++ b/tools/hypernode-vagrant-runner/tests/unit/hypernode_vagrant_runner/vagrant/set_up/test_write_hypernode_vagrant_configuration.py @@ -18,7 +18,7 @@ def tearDown(self): rmtree(self.temp_dir, ignore_errors=True) def test_write_hypernode_vagrant_configuration_writes_configuration(self): - write_hypernode_vagrant_configuration(self.temp_dir) + write_hypernode_vagrant_configuration(self.temp_dir, xenial=False) with open(self.temp_config_file) as f: ret = f.read() @@ -36,7 +36,7 @@ def test_write_hypernode_vagrant_configuration_writes_configuration(self): self.assertEqual(ret, expected_configuration) def test_write_hypernode_vagrant_configuration_writes_config_with_specified_php_version(self): - write_hypernode_vagrant_configuration(self.temp_dir, php_version='5.5') + write_hypernode_vagrant_configuration(self.temp_dir, php_version='5.5', xenial=False) with open(self.temp_config_file) as f: ret = f.read() @@ -54,7 +54,7 @@ def test_write_hypernode_vagrant_configuration_writes_config_with_specified_php_ self.assertEqual(ret, expected_configuration) def test_write_hypernode_vagrant_configuration_writes_config_with_xdebug_enabled_if_specified(self): - write_hypernode_vagrant_configuration(self.temp_dir, xdebug_enabled=True) + write_hypernode_vagrant_configuration(self.temp_dir, xdebug_enabled=True, xenial=False) with open(self.temp_config_file) as f: ret = f.read() @@ -84,3 +84,19 @@ def test_write_hypernode_vagrant_configuration_writes_writes_config_with_xenial_ ubuntu_version='xenial' ) self.assertEqual(ret, expected_configuration) + + def test_write_hypernode_vagrant_configuration_writes_config_with_specified_xenial_exclusive_php_version(self): + write_hypernode_vagrant_configuration(self.temp_dir, php_version='7.1') + # PHP 7.1 is not available in the Ubuntu Precise hypernode-vagrant + + with open(self.temp_config_file) as f: + ret = f.read() + expected_configuration = HYPERNODE_VAGRANT_CONFIGURATION.format( + xdebug_enabled='false', + php_version='7.1', + box_name=HYPERNODE_XENIAL_BOX_NAME, + box_url=HYPERNODE_XENIAL_URL, + ubuntu_version='xenial' + ) + self.assertEqual(ret, expected_configuration) + diff --git a/vagrant/plugins/vagrant-hypconfigmgmt/Makefile b/vagrant/plugins/vagrant-hypconfigmgmt/Makefile index 192b11a..28de6aa 100644 --- a/vagrant/plugins/vagrant-hypconfigmgmt/Makefile +++ b/vagrant/plugins/vagrant-hypconfigmgmt/Makefile @@ -10,7 +10,7 @@ all: test: bundle exec rspec spec/ install: - find pkg/ -name '*.gem' | tail -n 1 | xargs vagrant plugin install + find pkg/ -name '*.gem' | sort -nr | tail -n 1 | xargs vagrant plugin install clean: git clean -xfd diff --git a/vagrant/plugins/vagrant-hypconfigmgmt/README.md b/vagrant/plugins/vagrant-hypconfigmgmt/README.md index 16c3b2b..d038a12 100644 --- a/vagrant/plugins/vagrant-hypconfigmgmt/README.md +++ b/vagrant/plugins/vagrant-hypconfigmgmt/README.md @@ -11,5 +11,33 @@ Create the gemfile (package) ``` $ make rake build -vagrant-hypconfigmgmt 0.0.8 built to pkg/vagrant-hypconfigmgmt-0.0.9.gem. +vagrant-hypconfigmgmt 0.0.10 built to pkg/vagrant-hypconfigmgmt-0.0.10.gem. ``` + +Installing a locally developed hypconfigmgmt +============================================ + +1. Bump the version to one later than the latest version + +Edit `Vagrantfile` and update `VAGRANT_HYPCONFIGMGMT_VERSION` + +Edit `vagrant/plugins/vagrant-hypconfigmgmt/README.md` and update the version there. + +Edit `vagrant/plugins/vagrant-hypconfigmgmt/lib/vagrant-hypconfigmgmt/version.rb` and update `VERSION`. + +2. Navigate to `vagrant/plugins/vagrant-hypconfigmgmt` and run `make && make install` + + +Deploying a new vagrant-hypconfigmgmt +===================================== + +1. Only for Byte staff members. + +2. Do the above, except the `make install` is not necessary + +3. Remove the previous latest gem from `vagrant/plugins/vagrant-hypconfigmgmt/pkg` so only your new version remains. + +4. Commit into your branch, make a PR, merge after review. + +5. Publish the new gem with `gem push vagrant-hypconfigmgmt-0.0..gem`, see http://guides.rubygems.org/publishing/ for details. Credentials are in the usual place. + diff --git a/vagrant/plugins/vagrant-hypconfigmgmt/lib/vagrant-hypconfigmgmt/command.rb b/vagrant/plugins/vagrant-hypconfigmgmt/lib/vagrant-hypconfigmgmt/command.rb index a716c11..62a6632 100644 --- a/vagrant/plugins/vagrant-hypconfigmgmt/lib/vagrant-hypconfigmgmt/command.rb +++ b/vagrant/plugins/vagrant-hypconfigmgmt/lib/vagrant-hypconfigmgmt/command.rb @@ -5,7 +5,7 @@ AVAILABLE_MAGENTO_VERSIONS = [1, 2] DEFAULT_PHP_VERSION = 7.0 -AVAILABLE_PHP_VERSIONS = [5.5, 5.6, 7.0] +AVAILABLE_PHP_VERSIONS = [5.5, 5.6, 7.0, 7.1] DEFAULT_VARNISH_STATE = false AVAILABLE_VARNISH_STATES = [true, false] @@ -292,8 +292,8 @@ def ensure_vagrant_box_type_configured(env) settings['vagrant']['box'] = 'hypernode_xenial' settings['vagrant']['box_url'] = 'http://vagrant.hypernode.com/customer/xenial/catalog.json' else - if settings['php']['version'] == 5.6 - env[:ui].warning("The Precise Hypernodes don't have PHP5.6. Falling back to 5.5. Use the Xenial version of this box if you want PHP5.6") + if [5.6, 7.1].include? settings['php']['version'] + env[:ui].warning("The Precise Hypernodes don't have PHP#{settings['php']['version']}. Falling back to 5.5. Use the Xenial version of this box if you want PHP#{settings['php']['version']}") settings['php']['version'] = 5.5 end case settings['php']['version'] diff --git a/vagrant/plugins/vagrant-hypconfigmgmt/lib/vagrant-hypconfigmgmt/version.rb b/vagrant/plugins/vagrant-hypconfigmgmt/lib/vagrant-hypconfigmgmt/version.rb index 3558ab2..ad77398 100644 --- a/vagrant/plugins/vagrant-hypconfigmgmt/lib/vagrant-hypconfigmgmt/version.rb +++ b/vagrant/plugins/vagrant-hypconfigmgmt/lib/vagrant-hypconfigmgmt/version.rb @@ -3,6 +3,6 @@ module Vagrant module Hypconfigmgmt - VERSION = "0.0.9" + VERSION = "0.0.10" end end diff --git a/vagrant/plugins/vagrant-hypconfigmgmt/pkg/vagrant-hypconfigmgmt-0.0.10.gem b/vagrant/plugins/vagrant-hypconfigmgmt/pkg/vagrant-hypconfigmgmt-0.0.10.gem new file mode 100644 index 0000000..2203cf7 Binary files /dev/null and b/vagrant/plugins/vagrant-hypconfigmgmt/pkg/vagrant-hypconfigmgmt-0.0.10.gem differ diff --git a/vagrant/plugins/vagrant-hypconfigmgmt/pkg/vagrant-hypconfigmgmt-0.0.9.gem b/vagrant/plugins/vagrant-hypconfigmgmt/pkg/vagrant-hypconfigmgmt-0.0.9.gem index 00c5659..860aadc 100644 Binary files a/vagrant/plugins/vagrant-hypconfigmgmt/pkg/vagrant-hypconfigmgmt-0.0.9.gem and b/vagrant/plugins/vagrant-hypconfigmgmt/pkg/vagrant-hypconfigmgmt-0.0.9.gem differ diff --git a/vagrant/plugins/vagrant-hypconfigmgmt/spec/unit/command/ensure_vagrant_box_type_configured_spec.rb b/vagrant/plugins/vagrant-hypconfigmgmt/spec/unit/command/ensure_vagrant_box_type_configured_spec.rb index 9a77dec..15cf4f7 100644 --- a/vagrant/plugins/vagrant-hypconfigmgmt/spec/unit/command/ensure_vagrant_box_type_configured_spec.rb +++ b/vagrant/plugins/vagrant-hypconfigmgmt/spec/unit/command/ensure_vagrant_box_type_configured_spec.rb @@ -31,236 +31,323 @@ context "when php 7.0 is configured but no ubuntu version specified" do let(:retrieved_settings) { { "php" => { "version" => 7.0 }, "vagrant" => Hash.new } } it "sets the box name and box url to the right values for PHP 7.0" do - expected_settings = { + expected_settings = { "ubuntu_version" => "precise", "php" => { - "version" => 7.0 - }, - "vagrant" => { - "box" => "hypernode_php7", - "box_url" => "http://vagrant.hypernode.com/customer/php7/catalog.json" - } - } - # check if settings are retrieved from disk and pretend they return a configuration for php 7.0 + "version" => 7.0 + }, + "vagrant" => { + "box" => "hypernode_php7", + "box_url" => "http://vagrant.hypernode.com/customer/php7/catalog.json" + } + } + # check if settings are retrieved from disk and pretend they return a configuration for php 7.0 expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings) - # check if the ubuntu version is gotten and pretend it returns precise - expect(subject).to receive(:get_ubuntu_version).once.with(env).and_return('precise') - # check if the settings that are written back to disk contain the right box (name) and box_url + # check if the ubuntu version is gotten and pretend it returns precise + expect(subject).to receive(:get_ubuntu_version).once.with(env).and_return('precise') + # check if the settings that are written back to disk contain the right box (name) and box_url expect(subject).to receive(:update_settings).once.with(expected_settings) end end + context "when php 7.0 is configured and precise ubuntu version specified" do let(:retrieved_settings) { { "php" => { "version" => 7.0 }, "vagrant" => Hash.new, "ubuntu_version" => "precise" } } it "sets the box name and box url to the right values for PHP 7.0" do - expected_settings = { + expected_settings = { "ubuntu_version" => "precise", "php" => { - "version" => 7.0 - }, - "vagrant" => { - "box" => "hypernode_php7", - "box_url" => "http://vagrant.hypernode.com/customer/php7/catalog.json" - } - } - # check if settings are retrieved from disk and pretend they return a configuration for php 7.0 + "version" => 7.0 + }, + "vagrant" => { + "box" => "hypernode_php7", + "box_url" => "http://vagrant.hypernode.com/customer/php7/catalog.json" + } + } + # check if settings are retrieved from disk and pretend they return a configuration for php 7.0 expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings) - # check if the ubuntu version is not gotten because we already have it specified in the settings - expect(subject).to receive(:get_ubuntu_version).never - # check if the settings that are written back to disk contain the right box (name) and box_url + # check if the ubuntu version is not gotten because we already have it specified in the settings + expect(subject).to receive(:get_ubuntu_version).never + # check if the settings that are written back to disk contain the right box (name) and box_url expect(subject).to receive(:update_settings).once.with(expected_settings) end end + context "when php 7.0 is configured and xenial ubuntu version specified" do let(:retrieved_settings) { { "php" => { "version" => 7.0 }, "vagrant" => Hash.new, "ubuntu_version" => "xenial" } } it "sets the box name and box url to the right values for PHP 7.0" do - expected_settings = { + expected_settings = { "ubuntu_version" => "xenial", "php" => { - "version" => 7.0 - }, - "vagrant" => { - "box" => "hypernode_xenial", - "box_url" => "http://vagrant.hypernode.com/customer/xenial/catalog.json" - } - } - # check if settings are retrieved from disk and pretend they return a configuration for php 7.0 + "version" => 7.0 + }, + "vagrant" => { + "box" => "hypernode_xenial", + "box_url" => "http://vagrant.hypernode.com/customer/xenial/catalog.json" + } + } + # check if settings are retrieved from disk and pretend they return a configuration for php 7.0 expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings) - # check if the ubuntu version is not gotten because we already have it specified in the settings - expect(subject).to receive(:get_ubuntu_version).never - # check if the settings that are written back to disk contain the right box (name) and box_url + # check if the ubuntu version is not gotten because we already have it specified in the settings + expect(subject).to receive(:get_ubuntu_version).never + # check if the settings that are written back to disk contain the right box (name) and box_url expect(subject).to receive(:update_settings).once.with(expected_settings) end end + context "when php 5.5 is configured but no ubuntu version specified" do let(:retrieved_settings) { { "php" => { "version" => 5.5 }, "vagrant" => Hash.new } } it "sets the box name and box url to the right values for PHP 5.5" do - expected_settings = { + expected_settings = { "ubuntu_version" => "precise", "php" => { - "version" => 5.5 - }, - "vagrant" => { - "box" => "hypernode_php5", - "box_url" => "http://vagrant.hypernode.com/customer/php5/catalog.json" - } - } - # check if settings are retrieved from disk and pretend they return a configuration for php 5.5 + "version" => 5.5 + }, + "vagrant" => { + "box" => "hypernode_php5", + "box_url" => "http://vagrant.hypernode.com/customer/php5/catalog.json" + } + } + # check if settings are retrieved from disk and pretend they return a configuration for php 5.5 expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings) - # check if the ubuntu version is gotten and pretend it returns precise - expect(subject).to receive(:get_ubuntu_version).once.with(env).and_return('precise') - # check if the settings that are written back to disk contain the right box (name) and box_url + # check if the ubuntu version is gotten and pretend it returns precise + expect(subject).to receive(:get_ubuntu_version).once.with(env).and_return('precise') + # check if the settings that are written back to disk contain the right box (name) and box_url expect(subject).to receive(:update_settings).once.with(expected_settings) end end + context "when php 5.5 is configured and precise ubuntu version specified" do let(:retrieved_settings) { { "php" => { "version" => 5.5 }, "vagrant" => Hash.new, "ubuntu_version" => "precise" } } it "sets the box name and box url to the right values for PHP 5.5" do - expected_settings = { + expected_settings = { "ubuntu_version" => "precise", "php" => { - "version" => 5.5 - }, - "vagrant" => { - "box" => "hypernode_php5", - "box_url" => "http://vagrant.hypernode.com/customer/php5/catalog.json" - } - } - # check if settings are retrieved from disk and pretend they return a configuration for php 5.5 + "version" => 5.5 + }, + "vagrant" => { + "box" => "hypernode_php5", + "box_url" => "http://vagrant.hypernode.com/customer/php5/catalog.json" + } + } + # check if settings are retrieved from disk and pretend they return a configuration for php 5.5 expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings) - # check if the ubuntu version is not gotten because we already have it specified in the settings - expect(subject).to receive(:get_ubuntu_version).never - # check if the settings that are written back to disk contain the right box (name) and box_url + # check if the ubuntu version is not gotten because we already have it specified in the settings + expect(subject).to receive(:get_ubuntu_version).never + # check if the settings that are written back to disk contain the right box (name) and box_url expect(subject).to receive(:update_settings).once.with(expected_settings) end end + context "when php 5.5 is configured and xenial ubuntu version specified" do let(:retrieved_settings) { { "php" => { "version" => 5.5 }, "vagrant" => Hash.new, "ubuntu_version" => "xenial" } } it "sets the box name and box url to the right values for PHP 5.5" do - expected_settings = { + expected_settings = { "ubuntu_version" => "xenial", "php" => { - "version" => 5.5 - }, - "vagrant" => { - "box" => "hypernode_xenial", - "box_url" => "http://vagrant.hypernode.com/customer/xenial/catalog.json" - } - } - # check if settings are retrieved from disk and pretend they return a configuration for php 5.5 + "version" => 5.5 + }, + "vagrant" => { + "box" => "hypernode_xenial", + "box_url" => "http://vagrant.hypernode.com/customer/xenial/catalog.json" + } + } + # check if settings are retrieved from disk and pretend they return a configuration for php 5.5 expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings) - # check if the ubuntu version is not gotten because we already have it specified in the settings - expect(subject).to receive(:get_ubuntu_version).never - # check if the settings that are written back to disk contain the right box (name) and box_url + # check if the ubuntu version is not gotten because we already have it specified in the settings + expect(subject).to receive(:get_ubuntu_version).never + # check if the settings that are written back to disk contain the right box (name) and box_url expect(subject).to receive(:update_settings).once.with(expected_settings) end end + context "when php 5.6 is configured but no ubuntu version specified" do let(:retrieved_settings) { { "php" => { "version" => 5.6 }, "vagrant" => Hash.new } } it "sets the box name and box url to the right values for PHP 5.6" do - expected_settings = { + expected_settings = { "ubuntu_version" => "precise", "php" => { - "version" => 5.5 - }, - "vagrant" => { + "version" => 5.5 + }, + "vagrant" => { # Falling back to php5.5, Precise Hypernodes have no PHP5.6 - "box" => "hypernode_php5", - "box_url" => "http://vagrant.hypernode.com/customer/php5/catalog.json" - } - } - # check if settings are retrieved from disk and pretend they return a configuration for php 5.5 + "box" => "hypernode_php5", + "box_url" => "http://vagrant.hypernode.com/customer/php5/catalog.json" + } + } + # check if settings are retrieved from disk and pretend they return a configuration for php 5.5 + expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings) + # check if the ubuntu version is gotten and pretend it returns precise + expect(subject).to receive(:get_ubuntu_version).once.with(env).and_return('precise') + # check if the settings that are written back to disk contain the right box (name) and box_url + expect(subject).to receive(:update_settings).once.with(expected_settings) + # check if the user is warned about falling back to 5.5 + expect(ui).to receive(:warning).once.with(/.*Falling back to 5.5*/) + end + end + + + context "when php 7.1 is configured but no ubuntu version specified" do + let(:retrieved_settings) { { "php" => { "version" => 7.1 }, "vagrant" => Hash.new } } + it "sets the box name and box url to the right values for PHP 7.1" do + expected_settings = { + "ubuntu_version" => "precise", + "php" => { + "version" => 5.5 + }, + "vagrant" => { + # Falling back to php5.5, Precise Hypernodes have no PHP7.1 + "box" => "hypernode_php5", + "box_url" => "http://vagrant.hypernode.com/customer/php5/catalog.json" + } + } + # check if settings are retrieved from disk and pretend they return a configuration for php 5.5 expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings) - # check if the ubuntu version is gotten and pretend it returns precise - expect(subject).to receive(:get_ubuntu_version).once.with(env).and_return('precise') - # check if the settings that are written back to disk contain the right box (name) and box_url + # check if the ubuntu version is gotten and pretend it returns precise + expect(subject).to receive(:get_ubuntu_version).once.with(env).and_return('precise') + # check if the settings that are written back to disk contain the right box (name) and box_url expect(subject).to receive(:update_settings).once.with(expected_settings) - # check if the user is warned about falling back to 5.5 - expect(ui).to receive(:warning).once.with(/.*Falling back to 5.5*/) + # check if the user is warned about falling back to 5.5 + expect(ui).to receive(:warning).once.with(/.*Falling back to 5.5*/) end end + context "when php 5.6 is configured and precise ubuntu version specified" do let(:retrieved_settings) { { "php" => { "version" => 5.6 }, "vagrant" => Hash.new, "ubuntu_version" => "precise" } } it "sets the box name and box url to the right values for PHP 5.5" do - expected_settings = { + expected_settings = { "ubuntu_version" => "precise", "php" => { # Falling back to php5.5, Precise Hypernodes have no PHP5.6 - "version" => 5.5 - }, - "vagrant" => { - "box" => "hypernode_php5", - "box_url" => "http://vagrant.hypernode.com/customer/php5/catalog.json" - } - } - # check if settings are retrieved from disk and pretend they return a configuration for php 5.5 + "version" => 5.5 + }, + "vagrant" => { + "box" => "hypernode_php5", + "box_url" => "http://vagrant.hypernode.com/customer/php5/catalog.json" + } + } + # check if settings are retrieved from disk and pretend they return a configuration for php 5.5 + expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings) + # check if the ubuntu version is not gotten because we already have it specified in the settings + expect(subject).to receive(:get_ubuntu_version).never + # check if the settings that are written back to disk contain the right box (name) and box_url + expect(subject).to receive(:update_settings).once.with(expected_settings) + # check if the user is warned about falling back to 5.5 + expect(ui).to receive(:warning).once.with(/.*Falling back to 5.5*/) + end + end + + + context "when php 5.6 is configured and precise ubuntu version specified" do + let(:retrieved_settings) { { "php" => { "version" => 7.1 }, "vagrant" => Hash.new, "ubuntu_version" => "precise" } } + it "sets the box name and box url to the right values for PHP 5.5" do + expected_settings = { + "ubuntu_version" => "precise", + "php" => { + # Falling back to php5.5, Precise Hypernodes have no PHP7.1 + "version" => 5.5 + }, + "vagrant" => { + "box" => "hypernode_php5", + "box_url" => "http://vagrant.hypernode.com/customer/php5/catalog.json" + } + } + # check if settings are retrieved from disk and pretend they return a configuration for php 5.5 expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings) - # check if the ubuntu version is not gotten because we already have it specified in the settings - expect(subject).to receive(:get_ubuntu_version).never - # check if the settings that are written back to disk contain the right box (name) and box_url + # check if the ubuntu version is not gotten because we already have it specified in the settings + expect(subject).to receive(:get_ubuntu_version).never + # check if the settings that are written back to disk contain the right box (name) and box_url expect(subject).to receive(:update_settings).once.with(expected_settings) - # check if the user is warned about falling back to 5.5 - expect(ui).to receive(:warning).once.with(/.*Falling back to 5.5*/) + # check if the user is warned about falling back to 5.5 + expect(ui).to receive(:warning).once.with(/.*Falling back to 5.5*/) end end + context "when php 5.6 is configured and xenial ubuntu version specified" do let(:retrieved_settings) { { "php" => { "version" => 5.6 }, "vagrant" => Hash.new, "ubuntu_version" => "xenial" } } it "sets the box name and box url to the right values for PHP 5.6" do - expected_settings = { + expected_settings = { + "ubuntu_version" => "xenial", + "php" => { + "version" => 5.6 + }, + "vagrant" => { + "box" => "hypernode_xenial", + "box_url" => "http://vagrant.hypernode.com/customer/xenial/catalog.json" + } + } + # check if settings are retrieved from disk and pretend they return a configuration for php 5.6 + expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings) + # check if the ubuntu version is not gotten because we already have it specified in the settings + expect(subject).to receive(:get_ubuntu_version).never + # check if the settings that are written back to disk contain the right box (name) and box_url + expect(subject).to receive(:update_settings).once.with(expected_settings) + # check that the user is not warned about falling back because we do have 5.6 on Xenial + expect(ui).to receive(:warning).never + end + end + + + context "when php 7.1 is configured and xenial ubuntu version specified" do + let(:retrieved_settings) { { "php" => { "version" => 7.1 }, "vagrant" => Hash.new, "ubuntu_version" => "xenial" } } + it "sets the box name and box url to the right values for PHP 7.1" do + expected_settings = { "ubuntu_version" => "xenial", "php" => { - "version" => 5.6 - }, - "vagrant" => { - "box" => "hypernode_xenial", - "box_url" => "http://vagrant.hypernode.com/customer/xenial/catalog.json" - } - } - # check if settings are retrieved from disk and pretend they return a configuration for php 5.5 + "version" => 7.1 + }, + "vagrant" => { + "box" => "hypernode_xenial", + "box_url" => "http://vagrant.hypernode.com/customer/xenial/catalog.json" + } + } + # check if settings are retrieved from disk and pretend they return a configuration for php 7.1 expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings) - # check if the ubuntu version is not gotten because we already have it specified in the settings - expect(subject).to receive(:get_ubuntu_version).never - # check if the settings that are written back to disk contain the right box (name) and box_url + # check if the ubuntu version is not gotten because we already have it specified in the settings + expect(subject).to receive(:get_ubuntu_version).never + # check if the settings that are written back to disk contain the right box (name) and box_url expect(subject).to receive(:update_settings).once.with(expected_settings) - # check that the user is not warned about falling back because we do have 5.6 on Xenial - expect(ui).to receive(:warning).never + # check that the user is not warned about falling back because we do have 5.6 on Xenial + expect(ui).to receive(:warning).never end end + context "when an unknown php version is configured" do let(:retrieved_settings) { { "php" => { "version" => 1.0 }, "vagrant" => Hash.new } } it "does not set the box name and box url" do - expected_settings = { + expected_settings = { "ubuntu_version" => "precise", "php" => { - "version" => 1.0 - }, - "vagrant" => Hash.new - } - # check if settings are retrieved from disk and pretend they return an invalid php version + "version" => 1.0 + }, + "vagrant" => Hash.new + } + # check if settings are retrieved from disk and pretend they return an invalid php version expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings) - # check if the ubuntu version is gotten and pretend it returns precise - expect(subject).to receive(:get_ubuntu_version).once.with(env).and_return('precise') - # check if the settings we write back to disk have an unaltered box (name) and box_url + # check if the ubuntu version is gotten and pretend it returns precise + expect(subject).to receive(:get_ubuntu_version).once.with(env).and_return('precise') + # check if the settings we write back to disk have an unaltered box (name) and box_url expect(subject).to receive(:update_settings).once.with(expected_settings) end end + context "when an unknown php version is configured and xenial ubuntu version specified" do let(:retrieved_settings) { { "php" => { "version" => 1.0 }, "vagrant" => Hash.new, "ubuntu_version" => "xenial" } } it "does not set the box name and box url" do - # check if settings are retrieved from disk and pretend they return an invalid php version + # check if settings are retrieved from disk and pretend they return an invalid php version expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings) - # check if the ubuntu version is not gotten because we already have it specified in the settings - expect(subject).to receive(:get_ubuntu_version).never - # check if the settings we write back to disk have an unaltered box (name) and box_url + # check if the ubuntu version is not gotten because we already have it specified in the settings + expect(subject).to receive(:get_ubuntu_version).never + # check if the settings we write back to disk have an unaltered box (name) and box_url expect(subject).to receive(:update_settings).once.with(retrieved_settings) end end diff --git a/vagrant/plugins/vagrant-hypconfigmgmt/spec/unit/command/get_options_string_spec.rb b/vagrant/plugins/vagrant-hypconfigmgmt/spec/unit/command/get_options_string_spec.rb index c011112..858a90b 100644 --- a/vagrant/plugins/vagrant-hypconfigmgmt/spec/unit/command/get_options_string_spec.rb +++ b/vagrant/plugins/vagrant-hypconfigmgmt/spec/unit/command/get_options_string_spec.rb @@ -34,7 +34,7 @@ context "when the options are floats" do it "it casts the floats to strings and returns them separated by 'or'" do - expect( subject.get_options_string([5.5, 5.6, 7.0]) ).to eq("5.5 or 5.6 or 7.0") + expect( subject.get_options_string([5.5, 5.6, 7.0, 7.1]) ).to eq("5.5 or 5.6 or 7.0 or 7.1") end end diff --git a/vagrant/plugins/vagrant-hypconfigmgmt/spec/unit/command/get_php_version_spec.rb b/vagrant/plugins/vagrant-hypconfigmgmt/spec/unit/command/get_php_version_spec.rb index e3e8fe4..241fd2e 100644 --- a/vagrant/plugins/vagrant-hypconfigmgmt/spec/unit/command/get_php_version_spec.rb +++ b/vagrant/plugins/vagrant-hypconfigmgmt/spec/unit/command/get_php_version_spec.rb @@ -25,14 +25,14 @@ context "when PHP 5.5 is configured" do it "it notifies the user that PHP 5.5 will be used and returns the value" do - # check if the setting is prompted for and pretend it returns a "PHP 5.5" answer + # check if the setting is prompted for and pretend it returns a "PHP 5.5" answer expect(subject).to receive(:get_setting).with( - env, AVAILABLE_PHP_VERSIONS, DEFAULT_PHP_VERSION, - "Is this a PHP #{subject.get_options_string(AVAILABLE_PHP_VERSIONS)} Hypernode? [default #{DEFAULT_PHP_VERSION}]: " - ).and_return("5.5") + env, AVAILABLE_PHP_VERSIONS, DEFAULT_PHP_VERSION, + "Is this a PHP #{subject.get_options_string(AVAILABLE_PHP_VERSIONS)} Hypernode? [default #{DEFAULT_PHP_VERSION}]: " + ).and_return("5.5") # check if the user is notified about the PHP version expect(ui).to receive(:info).once.with(/.*PHP 5.5*/) - # check if the function returns float 5.5 if a PHP 5.5 Vagrant is to be used + # check if the function returns float 5.5 if a PHP 5.5 Vagrant is to be used expect( subject.get_php_version(env) ).to eq(5.5) end end @@ -40,14 +40,14 @@ context "when PHP 5.6 is configured" do it "it notifies the user that PHP 5.6 will be used and returns the value" do - # check if the setting is prompted for and pretend it returns a "PHP 5.6" answer + # check if the setting is prompted for and pretend it returns a "PHP 5.6" answer expect(subject).to receive(:get_setting).with( - env, AVAILABLE_PHP_VERSIONS, DEFAULT_PHP_VERSION, - "Is this a PHP #{subject.get_options_string(AVAILABLE_PHP_VERSIONS)} Hypernode? [default #{DEFAULT_PHP_VERSION}]: " - ).and_return("5.6") + env, AVAILABLE_PHP_VERSIONS, DEFAULT_PHP_VERSION, + "Is this a PHP #{subject.get_options_string(AVAILABLE_PHP_VERSIONS)} Hypernode? [default #{DEFAULT_PHP_VERSION}]: " + ).and_return("5.6") # check if the user is notified about the PHP version expect(ui).to receive(:info).once.with(/.*PHP 5.6*/) - # check if the function returns float 5.5 if a PHP 5.5 Vagrant is to be used + # check if the function returns float 5.5 if a PHP 5.5 Vagrant is to be used expect( subject.get_php_version(env) ).to eq(5.6) end end @@ -55,17 +55,32 @@ context "when PHP 7.0 is configured" do it "it notifies the user that PHP 7.0 will be used and returns the value" do - # check if the setting is prompted for and pretend it returns a "PHP 7.0" answer + # check if the setting is prompted for and pretend it returns a "PHP 7.0" answer expect(subject).to receive(:get_setting).with( - env, AVAILABLE_PHP_VERSIONS, DEFAULT_PHP_VERSION, - "Is this a PHP #{subject.get_options_string(AVAILABLE_PHP_VERSIONS)} Hypernode? [default #{DEFAULT_PHP_VERSION}]: " - ).and_return("7.0") + env, AVAILABLE_PHP_VERSIONS, DEFAULT_PHP_VERSION, + "Is this a PHP #{subject.get_options_string(AVAILABLE_PHP_VERSIONS)} Hypernode? [default #{DEFAULT_PHP_VERSION}]: " + ).and_return("7.0") # check if the user is notified about the PHP version expect(ui).to receive(:info).once.with(/.*PHP 7.0*/) - # check if the function returns float 7.0 if a PHP 7.0 Vagrant is to be used + # check if the function returns float 7.0 if a PHP 7.0 Vagrant is to be used expect( subject.get_php_version(env) ).to eq(7.0) end end + + + context "when PHP 7.1 is configured" do + it "it notifies the user that PHP 7.1 will be used and returns the value" do + # check if the setting is prompted for and pretend it returns a "PHP 7.1" answer + expect(subject).to receive(:get_setting).with( + env, AVAILABLE_PHP_VERSIONS, DEFAULT_PHP_VERSION, + "Is this a PHP #{subject.get_options_string(AVAILABLE_PHP_VERSIONS)} Hypernode? [default #{DEFAULT_PHP_VERSION}]: " + ).and_return("7.1") + # check if the user is notified about the PHP version + expect(ui).to receive(:info).once.with(/.*PHP 7.1*/) + # check if the function returns float 7.1 if a PHP 7.1 Vagrant is to be used + expect( subject.get_php_version(env) ).to eq(7.1) + end + end end end diff --git a/vagrant/provisioning/hypernode.sh b/vagrant/provisioning/hypernode.sh index aacc0f2..78cb818 100644 --- a/vagrant/provisioning/hypernode.sh +++ b/vagrant/provisioning/hypernode.sh @@ -95,6 +95,7 @@ if $xdebug_enabled; then which php5.5 && PHP_VERSION="php5" || /bin/true which php5.6 && PHP_VERSION="php5.6" || /bin/true which php7.0 && PHP_VERSION="php7.0" || /bin/true + which php7.1 && PHP_VERSION="php7.1" || /bin/true if [ -z $PHP_VERSION ]; then echo "No supported PHP version found for this xdebug installation script. Skipping.." @@ -121,12 +122,14 @@ if $xdebug_enabled; then [ "$PHP_VERSION" == "php5.5" ] && MODULES_DIR="/usr/lib/php5/20121212/" [ "$PHP_VERSION" == "php5.6" ] && MODULES_DIR="/usr/lib/php5/20131226/" [ "$PHP_VERSION" == "php7.0" ] && MODULES_DIR="/usr/lib/php/20151012/" + [ "$PHP_VERSION" == "php7.1" ] && MODULES_DIR="/usr/lib/php/20160303/" cp -f modules/xdebug.so $MODULES_DIR [ "$PHP_VERSION" == "php5" ] && PHP_DIR="/etc/php5/" [ "$PHP_VERSION" == "php5.5" ] && PHP_DIR="/etc/php/5.5/" [ "$PHP_VERSION" == "php5.6" ] && PHP_DIR="/etc/php/5.6/" [ "$PHP_VERSION" == "php7.0" ] && PHP_DIR="/etc/php/7.0/" + [ "$PHP_VERSION" == "php7.1" ] && PHP_DIR="/etc/php/7.1/" # Configure PHP to load xdebug.so for i in fpm cli; do @@ -142,6 +145,7 @@ if $xdebug_enabled; then [ "$PHP_VERSION" == "php5.5" ] && service php5.5-fpm restart [ "$PHP_VERSION" == "php5.6" ] && service php5.6-fpm restart [ "$PHP_VERSION" == "php7.0" ] && service php7.0-fpm restart + [ "$PHP_VERSION" == "php7.1" ] && service php7.1-fpm restart service nginx restart fi echo ""