vagrant-hypconfigmgmt 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b27e5b0ad9ed5e0a31db8176cb3c439a2206741e
4
- data.tar.gz: 9642e941dae96c39f741a523fa9abf9a566861ef
3
+ metadata.gz: f62543b9cfe6dacdf66c31382c50129a190a02f1
4
+ data.tar.gz: e155f19effe974672617050a36902cf3ae04373b
5
5
  SHA512:
6
- metadata.gz: 9ca8d0dc091ebdf6ca7aeb256052a9ff78adc2f9768b493f7cdf1c465c44d8ba7e5bd3fe43c141516bdbfb051a9d1938a01f80c58f23e24af67f48cd762db428
7
- data.tar.gz: 3210f4d40bdb425cb71adc56fdb897e2620b87d40972a58a43698981927dde64847e3426ad480b244e09a06bcbe646c405d75a9f43e23e1c1a71acac1d42b0e6
6
+ metadata.gz: 2a4840c860526f349a5779d84eeeb0dd85a5d62a123d44b381c8b8aa94a3ea453c61801b172e67786f2cb14879ea0e901c91fe7450840f475b0c51a8ddfb8a5c
7
+ data.tar.gz: ebed8ca5546dbf1d3ab9ab6f8b2c2ebb3f17e019201a2da94ae7bc52373afb5ba0e4b5709d05fc9a6480c2f477e5b71427aa071f13f2a2e91b715570dd34302e
data/README.md CHANGED
@@ -11,5 +11,5 @@ Create the gemfile (package)
11
11
  ```
12
12
  $ make
13
13
  rake build
14
- vagrant-hypconfigmgmt 0.0.3 built to pkg/vagrant-hypconfigmgmt-0.0.3.gem.
14
+ vagrant-hypconfigmgmt 0.0.4 built to pkg/vagrant-hypconfigmgmt-0.0.4.gem.
15
15
  ```
@@ -13,6 +13,9 @@ AVAILABLE_VARNISH_STATES = [true, false]
13
13
  DEFAULT_FIREWALL_STATE = false
14
14
  AVAILABLE_FIREWALL_STATES = [true, false]
15
15
 
16
+ DEFAULT_CGROUP_STATE = false
17
+ AVAILABLE_CGROUP_STATES = [true, false]
18
+
16
19
  # paths to local settings file
17
20
  H_V_SETTINGS_FILE = "local.yml"
18
21
  H_V_BASE_SETTINGS_FILE = ".local.base.yml"
@@ -134,6 +137,19 @@ module VagrantHypconfigmgmt
134
137
  env[:ui].info(message)
135
138
  return firewall_state
136
139
  end
140
+
141
+
142
+ def get_cgroup_state(env)
143
+ ask_message = "Do you want to enable production-like memory management? \n"
144
+ ask_message << "This might be slower but it is more in-line with a real Hypernode. \n"
145
+ ask_message << "Note: for LXC boxes this setting is disabled. \n"
146
+ ask_message << "Enter true or false [default false]: "
147
+ cgroup_enabled = get_setting(env, AVAILABLE_CGROUP_STATES, DEFAULT_CGROUP_STATE, ask_message)
148
+ cgroup_state = cgroup_enabled == 'true' ? true : false
149
+ message = "Production-like memory management will be #{cgroup_state ? 'enabled' : 'disabled'}"
150
+ env[:ui].info(message)
151
+ return cgroup_state
152
+ end
137
153
 
138
154
 
139
155
  def get_fs_type(env)
@@ -306,6 +322,15 @@ HEREDOC
306
322
  AVAILABLE_FIREWALL_STATES
307
323
  ) { get_firewall_state(env) }
308
324
  end
325
+
326
+
327
+ def configure_cgroup(env)
328
+ ensure_setting_exists('cgroup')
329
+ ensure_attribute_configured(
330
+ env, 'cgroup', 'state',
331
+ AVAILABLE_CGROUP_STATES
332
+ ) { get_cgroup_state(env) }
333
+ end
309
334
 
310
335
 
311
336
  def configure_synced_folders(env)
@@ -330,6 +355,7 @@ HEREDOC
330
355
  configure_varnish(env)
331
356
  configure_synced_folders(env)
332
357
  configure_firewall(env)
358
+ configure_cgroup(env)
333
359
  configure_vagrant(env)
334
360
  new_settings = retrieve_settings()
335
361
  return new_settings.to_yaml != old_settings.to_yaml
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Vagrant
5
5
  module Hypconfigmgmt
6
- VERSION = "0.0.3"
6
+ VERSION = "0.0.4"
7
7
  end
8
8
  end
@@ -0,0 +1,35 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # vim: set fileencoding=utf-8
3
+
4
+ require 'spec_helper'
5
+ require "vagrant-hypconfigmgmt/command"
6
+
7
+ describe VagrantHypconfigmgmt::Command do
8
+ # create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
9
+ let(:app) { }
10
+ let(:env) { }
11
+
12
+ # Call the method under test after every 'it'. Similar to setUp in Python TestCase
13
+ after do
14
+ subject.configure_cgroup(env)
15
+ end
16
+
17
+ # instantiate class of which a method is to be tested
18
+ subject { described_class.new(app, env) }
19
+
20
+ # the method that we are going to test
21
+ describe "#configure_cgroup" do
22
+
23
+ context "when env is passed" do
24
+ it "configures the settings for cgroup" do
25
+ # check the cgroup settings is ensured to exist in the configuration file
26
+ expect(subject).to receive(:ensure_setting_exists).with('cgroup')
27
+ # check the cgroup state is ensured to be configured
28
+ expect(subject).to receive(:ensure_attribute_configured).with(
29
+ env, 'cgroup', 'state', AVAILABLE_CGROUP_STATES
30
+ )
31
+ end
32
+ end
33
+ end
34
+ end
35
+
@@ -43,6 +43,8 @@ describe VagrantHypconfigmgmt::Command do
43
43
  expect(subject).to receive(:configure_synced_folders).with(env)
44
44
  # check the firewall settings are configured
45
45
  expect(subject).to receive(:configure_firewall).with(env)
46
+ # check the memory management settings are configured
47
+ expect(subject).to receive(:configure_cgroup).with(env)
46
48
  # check the vagrant settings are configured
47
49
  expect(subject).to receive(:configure_vagrant).with(env)
48
50
  # check true is returned when settings are updated
@@ -64,6 +66,8 @@ describe VagrantHypconfigmgmt::Command do
64
66
  expect(subject).to receive(:configure_synced_folders).with(env)
65
67
  # check the firewall settings are configured
66
68
  expect(subject).to receive(:configure_firewall).with(env)
69
+ # check the memory management settings are configured
70
+ expect(subject).to receive(:configure_cgroup).with(env)
67
71
  # check the vagrant settings are configured
68
72
  expect(subject).to receive(:configure_vagrant).with(env)
69
73
  # check false is returned when settings are not updated
@@ -0,0 +1,57 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # vim: set fileencoding=utf-8
3
+
4
+ require 'spec_helper'
5
+ require "vagrant-hypconfigmgmt/command"
6
+
7
+ describe VagrantHypconfigmgmt::Command do
8
+ # create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
9
+ let(:app) { }
10
+ let(:env) { { :ui => ui } }
11
+
12
+ # pretend env contains the Vagrant ui element
13
+ let(:ui) do
14
+ double('ui').tap do |ui|
15
+ allow(ui).to receive(:info) { nil }
16
+ end
17
+ end
18
+
19
+ # instantiate class of which a method is to be tested
20
+ subject { described_class.new(app, env) }
21
+
22
+ # the method that we are going to test
23
+ describe "#get_cgroup_state" do
24
+ expected_message = "Do you want to enable production-like memory management? \n"
25
+ expected_message << "This might be slower but it is more in-line with a real Hypernode. \n"
26
+ expected_message << "Note: for LXC boxes this setting is disabled. \n"
27
+ expected_message << "Enter true or false [default false]: "
28
+
29
+ context "when the state is enabled" do
30
+ it "it notifies the user that it will be enabled and returns the value" do
31
+ # check if the setting is prompted for and pretend it returns a "cgroup enabled" answer
32
+ expect(subject).to receive(:get_setting).with(
33
+ env, AVAILABLE_CGROUP_STATES, DEFAULT_CGROUP_STATE, expected_message
34
+ ).and_return("true")
35
+ # check if the user is notified that the cgroup will be enabled
36
+ expect(ui).to receive(:info).once.with(/.*enabled.*/)
37
+ # check if the function returns true if the cgroup should be enabled
38
+ expect( subject.get_cgroup_state(env) ).to eq(true)
39
+ end
40
+ end
41
+
42
+
43
+ context "when the state is disabled" do
44
+ it "it notifies the user that it will be disabled and returns the value" do
45
+ # check if the setting is prompted for and pretend it returns a "cgroup disabled" answer
46
+ expect(subject).to receive(:get_setting).with(
47
+ env, AVAILABLE_CGROUP_STATES, DEFAULT_CGROUP_STATE, expected_message
48
+ ).and_return("false")
49
+ # check if the user is notified that the cgroup will be disabled
50
+ expect(ui).to receive(:info).once.with(/.*disabled.*/)
51
+ # check if the function returns false if the cgroup should be disabled
52
+ expect( subject.get_cgroup_state(env) ).to eq(false)
53
+ end
54
+ end
55
+ end
56
+ end
57
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-hypconfigmgmt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick van de Loo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-28 00:00:00.000000000 Z
11
+ date: 2016-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -95,13 +95,12 @@ files:
95
95
  - README.md
96
96
  - Rakefile
97
97
  - lib/vagrant-hypconfigmgmt.rb
98
- - lib/vagrant-hypconfigmgmt/.command.rb.swo
99
98
  - lib/vagrant-hypconfigmgmt/command.rb
100
99
  - lib/vagrant-hypconfigmgmt/config.rb
101
100
  - lib/vagrant-hypconfigmgmt/version.rb
102
- - pkg/vagrant-hypconfigmgmt-0.0.3.gem
103
101
  - spec/spec_helper.rb
104
102
  - spec/unit/command/call_spec.rb
103
+ - spec/unit/command/configure_cgroup_spec.rb
105
104
  - spec/unit/command/configure_firewall_spec.rb
106
105
  - spec/unit/command/configure_magento_spec.rb
107
106
  - spec/unit/command/configure_php_spec.rb
@@ -116,6 +115,7 @@ files:
116
115
  - spec/unit/command/ensure_setting_exists_spec.rb
117
116
  - spec/unit/command/ensure_settings_are_configured_spec.rb
118
117
  - spec/unit/command/ensure_vagrant_box_type_configured_spec.rb
118
+ - spec/unit/command/get_cgroup_state_spec.rb
119
119
  - spec/unit/command/get_firewall_state_spec.rb
120
120
  - spec/unit/command/get_fs_type_spec.rb
121
121
  - spec/unit/command/get_magento_version_spec.rb
Binary file