Skip to content
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.

Ability to control refresh of service #15

Merged
merged 1 commit into from
Nov 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class { 'ravendb':
ravendb_filesystems_database_directory => 'C:\\RavenDB\\FileSystems',
service_ensure => 'running',
service_enable => true,
service_restart_on_config_change => true,
config => {
'Raven/Esent/DbExtensionSize' => 128,
'Raven/Esent/MaxCursors' => 4096,
Expand Down Expand Up @@ -106,6 +107,22 @@ class { 'ravendb':

A full list of documented configuration possiblities that exist can be found at https://ravendb.net/docs/article-page/3.5/csharp/server/configuration/configuration-options.

### Prevent restarting RavenDB Service on configuration file changes

Generally in production you don't want your database to restart in an uncontrolled manner. For Example, If you are not allowed to restart the database during production hours because it would cause downtime. If that is the case then in your production environment you will want to use hiera to set service_restart_on_config_change to false. You can then push out your code changes to production and at some point in the future during a green window trigger a restart of the service using any method you prefer. ( Puppet Tasks/MCollective/WinRM )

```puppet
class { 'ravendb':
package_ensure => 'present',
service_restart_on_config_change => false,
config => {
'Raven/Esent/DbExtensionSize' => 128,
'Raven/Esent/MaxCursors' => 4096,
'Raven/Esent/MaxVerPages' => 6144,
},
}
```

## Reference

### Classes
Expand Down Expand Up @@ -200,6 +217,12 @@ Whether or not the ravendb service should be enabled to start at boot or disable

Default: 'true'.

#### `service_restart_on_config_change`

Whether ot not to restart the ravendb service when the ravendb configuration file is updated/changed by puppet. (Raven.Server.exe.config)

Default: true.

#### `config`

Which configuration key values pairs should exist in the ravendb configuration file. (Raven.Server.exe.config)
Expand Down
9 changes: 8 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
Stdlib::Absolutepath $ravendb_filesystems_database_directory = $ravendb::params::ravendb_filesystems_database_directory,
Enum['running', 'stopped'] $service_ensure = $ravendb::params::service_ensure,
Variant[ Boolean, Enum['manual'] ] $service_enable = $ravendb::params::service_enable,
Boolean $service_restart_on_config_change = $ravendb::params::service_restart_on_config_change,
Hash $config = $ravendb::params::config,
) inherits ravendb::params {

Expand Down Expand Up @@ -48,6 +49,12 @@

Class['ravendb::install']
-> Class['ravendb::config']
~> Class['ravendb::service']

if ($service_restart_on_config_change) {
Class['ravendb::config'] ~> Class['ravendb::service']

} else {
Class['ravendb::config'] -> Class['ravendb::service']
}

}
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
$ravendb_port = 8080
$service_ensure = 'running'
$service_enable = true
$service_restart_on_config_change = true

$ravendb_server_exe_config_absolute_path = "${ravendb_install_folder}\\Raven.Server.exe.config"

Expand Down
2 changes: 1 addition & 1 deletion manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
enable => $service_enable,
}
}
}
}
65 changes: 30 additions & 35 deletions spec/acceptance/ravendb_installation_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
require 'spec_helper_acceptance'

describe 'ravendb' do

context 'when installing with provided mandatory parameters' do
let(:install_manifest) {
let(:install_manifest) do
<<-MANIFEST
class { 'ravendb':
package_ensure => 'present',
Expand All @@ -15,89 +14,85 @@ class { 'ravendb':
ravendb_filesystems_database_directory => 'C:\\RavenDB\\FileSystems',
}
MANIFEST
}
end

it 'should run without errors' do
apply_manifest(install_manifest, :catch_failures => true)
it 'runs without errors' do
apply_manifest(install_manifest, catch_failures: true)
end

it 'should be idempotent' do
apply_manifest(install_manifest, :catch_changes => true)
it 'is idempotent' do
apply_manifest(install_manifest, catch_changes: true)
end



describe file('C:\RavenDB-3.5.4.Tools.zip') do
it { should_not exist }
it { is_expected.not_to exist }
end

describe file('C:\RavenDB Tools') do
it { should_not exist }
it { is_expected.not_to exist }
end


describe file('C:\RavenDB-3.5.4.Setup.exe') do
it { should exist }
it { is_expected.to exist }
end

describe file('C:\RavenDB.install.log') do
it { should exist }
it { is_expected.to exist }
end

describe package('RavenDB') do
it { should be_installed }
it { is_expected.to be_installed }
end

describe port(8080) do
it { should be_listening }
it { is_expected.to be_listening }
end

describe service('RavenDB') do
it { should be_installed }
it { should be_running }
it { should be_enabled }
it { is_expected.to be_installed }
it { is_expected.to be_running }
it { is_expected.to be_enabled }
end
end


context 'when uninstalling with provided mandatory parameters' do
let(:install_manifest) {
let(:install_manifest) do
<<-MANIFEST
class { 'ravendb':
package_ensure => 'absent',
ravendb_uninstall_log_absolute_path => 'C:\\RavenDB.uninstall.log',
}
MANIFEST
}
end

it 'should run without errors' do
apply_manifest(install_manifest, :catch_failures => true)
it 'runs without errors' do
apply_manifest(install_manifest, catch_failures: true)
end

it 'should be idempotent' do
apply_manifest(install_manifest, :catch_changes => true)
it 'is idempotent' do
apply_manifest(install_manifest, catch_changes: true)
end

describe file('C:\RavenDB-3.5.4.Setup.exe') do
it { should_not exist }
it { is_expected.not_to exist }
end

describe file('C:\RavenDB.uninstall.log') do
it { should exist }
it { is_expected.to exist }
end

describe package('RavenDB') do
it { should_not be_installed }
it { is_expected.not_to be_installed }
end

describe port(8080) do
it { should_not be_listening }
it { is_expected.not_to be_listening }
end

describe service('RavenDB') do
it { should_not be_installed }
it { should_not be_running }
it { should_not be_enabled }
it { is_expected.not_to be_installed }
it { is_expected.not_to be_running }
it { is_expected.not_to be_enabled }
end
end

end
end
49 changes: 23 additions & 26 deletions spec/acceptance/ravendb_management_tools_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
require 'spec_helper_acceptance'

describe 'ravendb' do

context 'when installing management tools' do
let(:install_manifest) {
let(:install_manifest) do
<<-MANIFEST
class { 'ravendb':
package_ensure => 'present',
Expand All @@ -15,65 +14,63 @@ class { 'ravendb':
ravendb_filesystems_database_directory => 'C:\\RavenDB\\FileSystems',
}
MANIFEST
}
end

it 'should run without errors' do
apply_manifest(install_manifest, :catch_failures => true)
it 'runs without errors' do
apply_manifest(install_manifest, catch_failures: true)
end

it 'should be idempotent' do
apply_manifest(install_manifest, :catch_changes => true)
it 'is idempotent' do
apply_manifest(install_manifest, catch_changes: true)
end

describe file('C:\RavenDB-3.5.4.Tools.zip') do
it { should exist }
it { is_expected.to exist }
end

describe file('C:\RavenDB Tools') do
it { should exist }
it { is_expected.to exist }
end
end


context 'when uninstalling management tools' do
let(:install_manifest) {
let(:install_manifest) do
<<-MANIFEST
class { 'ravendb':
package_ensure => 'present',
include_management_tools => false,
}
MANIFEST
}
end

it 'should run without errors' do
apply_manifest(install_manifest, :catch_failures => true)
it 'runs without errors' do
apply_manifest(install_manifest, catch_failures: true)
end

it 'should be idempotent' do
apply_manifest(install_manifest, :catch_changes => true)
it 'is idempotent' do
apply_manifest(install_manifest, catch_changes: true)
end

describe file('C:\RavenDB-3.5.4.Tools.zip') do
it { should_not exist }
it { is_expected.not_to exist }
end

describe file('C:\RavenDB Tools') do
it { should exist }
it { is_expected.to exist }
end

describe package('RavenDB') do
it { should_not be_installed }
it { is_expected.not_to be_installed }
end

describe port(8080) do
it { should_not be_listening }
it { is_expected.not_to be_listening }
end

describe service('RavenDB') do
it { should_not be_installed }
it { should_not be_running }
it { should_not be_enabled }
it { is_expected.not_to be_installed }
it { is_expected.not_to be_running }
it { is_expected.not_to be_enabled }
end
end

end
end
38 changes: 20 additions & 18 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@

describe 'ravendb::config' do
context 'with default values for all parameters' do
it { is_expected.to contain_class('ravendb::config') }
it { is_expected.to contain_class('ravendb::params') }

it { should contain_class('ravendb::config') }
it { should contain_class('ravendb::params') }

it { should contain_file('C:\\RavenDB\Raven.Server.exe.config').with({
:ensure => 'file',
})
.with_content(/#{Regexp.escape('<add key="Raven/Port" value="8080"/>')}/) }
it {
is_expected.to contain_file('C:\\RavenDB\Raven.Server.exe.config').with(ensure: 'file')
.with_content(%r{#{Regexp.escape('<add key="Raven/Port" value="8080"/>')}})
}
end

context 'config => { owner => root, group => root, mode => 0644 }' do
let (:params) {{
:config => { 'Raven/Esent/MaxVerPages' => 6144, 'Raven/Esent/DbExtensionSize' => 128, }
}}
it { should contain_file('C:\\RavenDB\Raven.Server.exe.config').with({
:ensure => 'file',
})
.with_content(/#{Regexp.escape('<add key="Raven/Port" value="8080"/>')}/)
.with_content(/#{Regexp.escape('<add key="Raven/Esent/MaxVerPages" value="6144"/>')}/)
.with_content(/#{Regexp.escape('<add key="Raven/Esent/DbExtensionSize" value="128"/>')}/) }
context 'with config => { owner => root, group => root, mode => 0644 }' do
let(:params) do
{
config: { 'Raven/Esent/MaxVerPages' => 6144, 'Raven/Esent/DbExtensionSize' => 128 },
}
end

it {
is_expected.to contain_file('C:\\RavenDB\Raven.Server.exe.config').with(ensure: 'file')
.with_content(%r{#{Regexp.escape('<add key="Raven/Port" value="8080"/>')}})
.with_content(%r{#{Regexp.escape('<add key="Raven/Esent/MaxVerPages" value="6144"/>')}})
.with_content(%r{#{Regexp.escape('<add key="Raven/Esent/DbExtensionSize" value="128"/>')}})
}
end
end
end