From 34386478f2cac04498e317409f2119298ae48557 Mon Sep 17 00:00:00 2001 From: Eric Herot Date: Thu, 19 Nov 2015 15:18:38 -0500 Subject: [PATCH] Massive find-and-replace for slave to agent (so very breaking) --- .kitchen.yml | 24 ++--- README.md | 40 ++++---- attributes/default.rb | 10 +- metadata.rb | 10 +- recipes/{slave.rb => agent.rb} | 42 ++++---- recipes/master.rb | 2 +- spec/recipes/{slave_spec.rb => agent_spec.rb} | 98 +++++++++---------- spec/recipes/master_spec.rb | 12 +-- templates/default/agents.erb | 3 + ...-slave.erb => etc-default-mesos-agent.erb} | 0 ...lave-env.sh.erb => mesos-agent-env.sh.erb} | 8 +- templates/default/mesos-deploy-env.sh.erb | 2 +- templates/default/slaves.erb | 3 - templates/default/upstart.conf.for.source.erb | 2 +- ...onfiguration.rb => agent_configuration.rb} | 24 ++--- .../serverspec/master_configuration.rb | 14 +-- .../helpers/serverspec/source_installation.rb | 6 +- .../helpers/serverspec/spec_helper.rb | 2 +- .../localhost/mesosphere_agent_spec.rb} | 30 +++--- .../serverspec/localhost/source_agent_spec.rb | 18 ++++ .../serverspec/localhost/source_slave_spec.rb | 18 ---- 21 files changed, 184 insertions(+), 184 deletions(-) rename recipes/{slave.rb => agent.rb} (55%) rename spec/recipes/{slave_spec.rb => agent_spec.rb} (50%) create mode 100644 templates/default/agents.erb rename templates/default/{etc-default-mesos-slave.erb => etc-default-mesos-agent.erb} (100%) rename templates/default/{mesos-slave-env.sh.erb => mesos-agent-env.sh.erb} (78%) delete mode 100644 templates/default/slaves.erb rename test/integration/helpers/serverspec/{slave_configuration.rb => agent_configuration.rb} (67%) rename test/integration/{mesosphere_slave/serverspec/localhost/mesosphere_slave_spec.rb => mesosphere_agent/serverspec/localhost/mesosphere_agent_spec.rb} (74%) create mode 100644 test/integration/source_agent/serverspec/localhost/source_agent_spec.rb delete mode 100644 test/integration/source_slave/serverspec/localhost/source_slave_spec.rb diff --git a/.kitchen.yml b/.kitchen.yml index 9a03ca8..a905f6b 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -41,20 +41,20 @@ suites: - 10.0.0.1 - 10.0.0.2 - 10.0.0.3 - slave_ips: + agent_ips: - 10.0.0.4 - 10.0.0.5 - 10.0.0.6 - - name: mesosphere_slave + - name: mesosphere_agent run_list: - # master recipe is only for asserting mesos-slave healthy startup. + # master recipe is only for asserting mesos-agent healthy startup. - recipe[et_mesos::master] - - recipe[et_mesos::slave] + - recipe[et_mesos::agent] attributes: et_mesos: type: mesosphere - slave: + agent: attributes: rackid: us-east-1b master: 'zk://localhost:2181/mesos' @@ -66,7 +66,7 @@ suites: - 10.0.0.1 - 10.0.0.2 - 10.0.0.3 - slave_ips: + agent_ips: - 10.0.0.4 - 10.0.0.5 - 10.0.0.6 @@ -86,16 +86,16 @@ suites: - 10.0.0.1 - 10.0.0.2 - 10.0.0.3 - slave_ips: + agent_ips: - 10.0.0.4 - 10.0.0.5 - 10.0.0.6 - - name: source_slave + - name: source_agent run_list: - # master recipe is only for asserting mesos-slave healthy startup. + # master recipe is only for asserting mesos-agent healthy startup. - recipe[et_mesos::master] - - recipe[et_mesos::slave] + - recipe[et_mesos::agent] attributes: et_mesos: type: source @@ -103,7 +103,7 @@ suites: zk: 'zk://localhost:2181/mesos' ip: 127.0.0.1 quorum: 1 - slave: + agent: attributes: rackid: us-east-1b master: 127.0.0.1:5050 @@ -112,7 +112,7 @@ suites: - 10.0.0.1 - 10.0.0.2 - 10.0.0.3 - slave_ips: + agent_ips: - 10.0.0.4 - 10.0.0.5 - 10.0.0.6 diff --git a/README.md b/README.md index 508eb4a..eec5bc3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mesos Cookbook [![Build Status](https://travis-ci.org/evertrue/mesos-cookbook.png?branch=master)](https://travis-ci.org/evertrue/mesos-cookbook) -Install Mesos () and configure mesos master and slave. +Install Mesos () and configure mesos master and agent. This cookbook also supports installation by both bulding from source and with [Mesosphere](http://mesosphere.io) package. You can switch installation type using the `node[:et_mesos][:type]` attribute (`source` or `mesosphere`). @@ -41,7 +41,7 @@ Configure master and cluster deployment configuration files, and start `mesos-master`. * `node[:et_mesos][:deploy_dir]/masters` -* `node[:et_mesos][:deploy_dir]/slaves` +* `node[:et_mesos][:deploy_dir]/agents` * `node[:et_mesos][:deploy_dir]/mesos-deploy-env.sh` * `node[:et_mesos][:deploy_dir]/mesos-master-env.sh` @@ -75,25 +75,25 @@ mesos-master --zk=zk://localhost:2181/mesos --port=5050 --log_dir=/var/log/mesos See the [latest Mesos config docs](http://mesos.apache.org/documentation/latest/configuration/) for available options or the output of `mesos-master --help`. -### et_mesos::slave +### et_mesos::agent -Configure slave configuration files, and start `mesos-slave`. +Configure agent configuration files, and start `mesos-agent`. -* `node[:et_mesos][:deploy_dir]/mesos-slave-env.sh` +* `node[:et_mesos][:deploy_dir]/mesos-agent-env.sh` Furthermore, this recipe also configures upstart configuration files. * `/etc/mesos/zk` * `/etc/defaults/mesos` -* `/etc/defaults/mesos-slave` +* `/etc/defaults/mesos-agent` -#### How to configure `mesos-slave` +#### How to configure `mesos-agent` -You can configure `mesos-slave` command line options by `node[:et_mesos][:slave]` hash. +You can configure `mesos-agent` command line options by `node[:et_mesos][:agent]` hash. If you have a configuration as shown below: ``` -node[:et_mesos][:slave] = { +node[:et_mesos][:agent] = { master: 'zk://localhost:2181/mesos', log_dir: '/var/log/mesos', containerizers: 'docker,mesos', @@ -102,19 +102,19 @@ node[:et_mesos][:slave] = { } ``` -Then `mesos-slave` will be invoked with command line options like this: +Then `mesos-agent` will be invoked with command line options like this: ``` -mesos-slave --master=zk://localhost:2181/mesos --log_dir=/var/log/mesos --containerizers=docker,mesos --isolation=cgroups/cpu,cgroups/mem --work_dir=/var/run/work +mesos-agent --master=zk://localhost:2181/mesos --log_dir=/var/log/mesos --containerizers=docker,mesos --isolation=cgroups/cpu,cgroups/mem --work_dir=/var/run/work ``` -See the [latest Mesos config docs](http://mesos.apache.org/documentation/latest/configuration/) for available options or the output of `mesos-slave --help`. +See the [latest Mesos config docs](http://mesos.apache.org/documentation/latest/configuration/) for available options or the output of `mesos-agent --help`. ## Usage -Wrap this cookbook, setting the `node[:et_mesos][:type]` attribute as appropriate for your installation, and `include_recipe 'et_mesos::master'` or `include_recipe 'et_mesos::slave'`, depending on what part of the cluster you need to provision. +Wrap this cookbook, setting the `node[:et_mesos][:type]` attribute as appropriate for your installation, and `include_recipe 'et_mesos::master'` or `include_recipe 'et_mesos::agent'`, depending on what part of the cluster you need to provision. -The recommendation would be to have two wrapper cookbooks, one for the master(s), and another for your slave(s). +The recommendation would be to have two wrapper cookbooks, one for the master(s), and another for your agent(s). ## Attributes @@ -186,9 +186,9 @@ The recommendation would be to have two wrapper cookbooks, one for the master(s) [ ] - [:et_mesos][:slave_ips] + [:et_mesos][:agent_ips] Array of String - IP list of slaves used in mesos-[start|stop]-cluster + IP list of agents used in mesos-[start|stop]-cluster [ ] @@ -219,15 +219,15 @@ The recommendation would be to have two wrapper cookbooks, one for the master(s) - [:et_mesos][:slave][:master] + [:et_mesos][:agent][:master] String [REQUIRED] mesos master url.This should be ip:port for non-ZooKeeper based masters, otherwise a zk:// . when mesosphere, you should set zk:// address. - [:et_mesos][:slave][:option_name] + [:et_mesos][:agent][:option_name] String - Like [:et_mesos][:master][:option_name] above, arbitrary options may be specified as a key for a slave by replacing `option_name` with your option’s key. + Like [:et_mesos][:master][:option_name] above, arbitrary options may be specified as a key for a agent by replacing `option_name` with your option’s key. @@ -239,7 +239,7 @@ There are a couple of test suites in place: * `chefspec` for unit tests. * `test-kitchen` with `serverspec` for integration tests (using `vagrant`). -These test both `source` and `mesosphere` type installations (using both the `master` and `slave` recipes). +These test both `source` and `mesosphere` type installations (using both the `master` and `agent` recipes). ## Contributing diff --git a/attributes/default.rb b/attributes/default.rb index 3643356..022fe04 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -7,7 +7,7 @@ default['et_mesos']['deploy_with_sudo'] = '1' default['et_mesos']['deploy_dir'] = '/usr/etc/mesos' default['et_mesos']['master_ips'] = [] -default['et_mesos']['slave_ips'] = [] +default['et_mesos']['agent_ips'] = [] default['et_mesos']['mesosphere']['with_zookeeper'] = false @@ -17,11 +17,11 @@ default['et_mesos']['master']['work_dir'] = '/tmp/mesos' default['et_mesos']['master']['port'] = '5050' -default['et_mesos']['slave']['log_dir'] = '/var/log/mesos' -default['et_mesos']['slave']['work_dir'] = '/tmp/mesos' -default['et_mesos']['slave']['isolation'] = 'cgroups/cpu,cgroups/mem' +default['et_mesos']['agent']['log_dir'] = '/var/log/mesos' +default['et_mesos']['agent']['work_dir'] = '/tmp/mesos' +default['et_mesos']['agent']['isolation'] = 'cgroups/cpu,cgroups/mem' -default['et_mesos']['slave']['cgroups_hierarchy'] = value_for_platform( +default['et_mesos']['agent']['cgroups_hierarchy'] = value_for_platform( 'centos' => { 'default' => '/cgroup' }, diff --git a/metadata.rb b/metadata.rb index 2f200d6..e832a78 100644 --- a/metadata.rb +++ b/metadata.rb @@ -13,7 +13,7 @@ recipe 'et_mesos::mesosphere', 'install mesos from mesosphere package.' recipe 'et_mesos::source', 'install mesos from source(default recipe).' recipe 'et_mesos::master', 'configure the machine as master.' -recipe 'et_mesos::slave', 'configure the machine as slave.' +recipe 'et_mesos::agent', 'configure the machine as agent.' depends 'java', '~> 1.35' depends 'python', '~> 1.4' @@ -27,7 +27,7 @@ suggests 'zookeeper' attribute 'et_mesos/type', - recipes: ['et_mesos::source', 'et_mesos::mesosphere', 'et_mesos::master', 'et_mesos::slave'], + recipes: ['et_mesos::source', 'et_mesos::mesosphere', 'et_mesos::master', 'et_mesos::agent'], display_name: 'installation type', description: "Value should be 'source' | 'mesosphere'.", default: 'source' @@ -45,7 +45,7 @@ default: 'false' attribute 'et_mesos/prefix', - recipes: ['et_mesos::source', 'et_mesos::master', 'et_mesos::slave'], + recipes: ['et_mesos::source', 'et_mesos::master', 'et_mesos::agent'], display_name: 'Prefix value to be passed to configure script', description: 'prefix value to be passed to configure script', default: '/usr/local' @@ -79,7 +79,7 @@ display_name: 'IP list of masters', description: 'used in mesos-start/stop-cluster scripts.' -attribute 'et_mesos/slave_ips', +attribute 'et_mesos/agent_ips', recipes: ['et_mesos::master'], - display_name: 'IP list of slaves', + display_name: 'IP list of agents', description: 'used in mesos-start/stop-cluster scripts.' diff --git a/recipes/slave.rb b/recipes/agent.rb similarity index 55% rename from recipes/slave.rb rename to recipes/agent.rb index 43598a0..cbfc1d9 100644 --- a/recipes/slave.rb +++ b/recipes/agent.rb @@ -1,11 +1,11 @@ # # Cookbook Name:: et_mesos -# Recipe:: slave +# Recipe:: agent # include_recipe 'et_mesos::default' -service 'mesos-slave' do +service 'mesos-agent' do provider Chef::Provider::Service::Upstart supports restart: true, reload: true action :nothing @@ -17,53 +17,53 @@ recursive true end -unless node['et_mesos']['slave']['master'] - fail "node['et_mesos']['slave']['master'] is required to configure mesos-slave." +unless node['et_mesos']['agent']['master'] + fail "node['et_mesos']['agent']['master'] is required to configure mesos-agent." end # configuration files for mesos-daemon.sh provided by both source and mesosphere -template "#{deploy_dir}/mesos-slave-env.sh" do - source 'mesos-slave-env.sh.erb' - notifies :reload, 'service[mesos-slave]', :delayed - notifies :restart, 'service[mesos-slave]', :delayed +template "#{deploy_dir}/mesos-agent-env.sh" do + source 'mesos-agent-env.sh.erb' + notifies :reload, 'service[mesos-agent]', :delayed + notifies :restart, 'service[mesos-agent]', :delayed end -template '/etc/init/mesos-slave.conf' do +template '/etc/init/mesos-agent.conf' do source "upstart.conf.for.#{node['et_mesos']['type']}.erb" - variables init_state: 'start', role: 'slave' - notifies :reload, 'service[mesos-slave]' + variables init_state: 'start', role: 'agent' + notifies :reload, 'service[mesos-agent]' end # configuration files for service scripts(mesos-init-wrapper) by mesosphere package. if node['et_mesos']['type'] == 'mesosphere' template '/etc/mesos/zk' do source 'etc-mesos-zk.erb' - variables zk: node['et_mesos']['slave']['master'] + variables zk: node['et_mesos']['agent']['master'] end template '/etc/default/mesos' do source 'etc-default-mesos.erb' - variables log_dir: node['et_mesos']['slave']['log_dir'] + variables log_dir: node['et_mesos']['agent']['log_dir'] end - template '/etc/default/mesos-slave' do - source 'etc-default-mesos-slave.erb' - variables isolation: node['et_mesos']['slave']['isolation'] + template '/etc/default/mesos-agent' do + source 'etc-default-mesos-agent.erb' + variables isolation: node['et_mesos']['agent']['isolation'] end - directory '/etc/mesos-slave' do + directory '/etc/mesos-agent' do recursive true end # TODO: Refactor this or add a guard to provide idempotency - jeffbyrnes - execute 'rm -rf /etc/mesos-slave/*' + execute 'rm -rf /etc/mesos-agent/*' - node['et_mesos']['slave'].each do |key, val| + node['et_mesos']['agent'].each do |key, val| next if %w(master_url master isolation log_dir).include?(key) next if val.nil? if val.respond_to? :to_path_hash val.to_path_hash.each do |path_h| - attr_path = "/etc/mesos-slave/#{key}" + attr_path = "/etc/mesos-agent/#{key}" directory attr_path @@ -72,7 +72,7 @@ end end else - file "/etc/mesos-slave/#{key}" do + file "/etc/mesos-agent/#{key}" do content "#{val}\n" end end diff --git a/recipes/master.rb b/recipes/master.rb index 428b81a..4e05e0f 100644 --- a/recipes/master.rb +++ b/recipes/master.rb @@ -30,7 +30,7 @@ # by both source and mesosphere template "#{deploy_dir}/masters" -template "#{deploy_dir}/slaves" +template "#{deploy_dir}/agents" template "#{deploy_dir}/mesos-deploy-env.sh" diff --git a/spec/recipes/slave_spec.rb b/spec/recipes/agent_spec.rb similarity index 50% rename from spec/recipes/slave_spec.rb rename to spec/recipes/agent_spec.rb index 948935f..b655a9d 100644 --- a/spec/recipes/slave_spec.rb +++ b/spec/recipes/agent_spec.rb @@ -1,30 +1,30 @@ # # Cookbook Name:: mesos -# Spec:: slave +# Spec:: agent # require 'spec_helper' -describe 'et_mesos::slave' do +describe 'et_mesos::agent' do deploy_dir = '/usr/local/var/mesos/deploy' - context "when node['et_mesos']['slave']['master'] is not set" do + context "when node['et_mesos']['agent']['master'] is not set" do let(:chef_run) { ChefSpec::ServerRunner.new.converge described_recipe } it 'exits the Chef run' do expect { chef_run }.to raise_error.with_message( - "node['et_mesos']['slave']['master'] is required to configure mesos-slave." + "node['et_mesos']['agent']['master'] is required to configure mesos-agent." ) end end context( - "when node['et_mesos']['slave']['master'] is set, " \ + "when node['et_mesos']['agent']['master'] is set, " \ 'but all other attributes are default, on Ubuntu 14.04' ) do let(:chef_run) do ChefSpec::ServerRunner.new do |node| - node.set['et_mesos']['slave']['master'] = 'test-master' + node.set['et_mesos']['agent']['master'] = 'test-master' end.converge described_recipe end @@ -32,8 +32,8 @@ expect(chef_run).to include_recipe 'et_mesos::default' end - it 'does nothing to service[mesos-slave]' do - resource = chef_run.service 'mesos-slave' + it 'does nothing to service[mesos-agent]' do + resource = chef_run.service 'mesos-agent' expect(resource).to do_nothing end @@ -43,46 +43,46 @@ ) end - describe 'slave env file' do + describe 'agent env file' do it 'creates it' do - expect(chef_run).to create_template "#{deploy_dir}/mesos-slave-env.sh" + expect(chef_run).to create_template "#{deploy_dir}/mesos-agent-env.sh" end - it 'notifies service[mesos-slave] to reload configurations and restart' do - conf = chef_run.template("#{deploy_dir}/mesos-slave-env.sh") - expect(conf).to notify('service[mesos-slave]').to(:reload).delayed - expect(conf).to notify('service[mesos-slave]').to(:restart).delayed + it 'notifies service[mesos-agent] to reload configurations and restart' do + conf = chef_run.template("#{deploy_dir}/mesos-agent-env.sh") + expect(conf).to notify('service[mesos-agent]').to(:reload).delayed + expect(conf).to notify('service[mesos-agent]').to(:restart).delayed end end - describe 'mesos-slave upstart script' do + describe 'mesos-agent upstart script' do it 'installs it to /etc/init' do - expect(chef_run).to create_template '/etc/init/mesos-slave.conf' + expect(chef_run).to create_template '/etc/init/mesos-agent.conf' end - it 'describe service name "mesos slave"' do - expect(chef_run).to render_file('/etc/init/mesos-slave.conf') - .with_content 'description "mesos slave"' + it 'describe service name "mesos agent"' do + expect(chef_run).to render_file('/etc/init/mesos-agent.conf') + .with_content 'description "mesos agent"' end it 'contains start on stopped rc with runlevel 2,3,4,5' do - expect(chef_run).to render_file('/etc/init/mesos-slave.conf') + expect(chef_run).to render_file('/etc/init/mesos-agent.conf') .with_content 'start on stopped rc RUNLEVEL=[2345]' end it 'contains respawn' do - expect(chef_run).to render_file('/etc/init/mesos-slave.conf') + expect(chef_run).to render_file('/etc/init/mesos-agent.conf') .with_content 'respawn' end it 'sets the correct role' do - expect(chef_run).to render_file('/etc/init/mesos-slave.conf') - .with_content 'role=slave' + expect(chef_run).to render_file('/etc/init/mesos-agent.conf') + .with_content 'role=agent' end - it 'notifies service[mesos-slave] to reload service configuration' do - conf = chef_run.template('/etc/init/mesos-slave.conf') - expect(conf).to notify('service[mesos-slave]').to(:reload).delayed + it 'notifies service[mesos-agent] to reload service configuration' do + conf = chef_run.template('/etc/init/mesos-agent.conf') + expect(conf).to notify('service[mesos-agent]').to(:reload).delayed end end end @@ -91,20 +91,20 @@ let :chef_run do ChefSpec::ServerRunner.new do |node| node.set['et_mesos']['type'] = 'mesosphere' - node.set['et_mesos']['slave']['master'] = 'test-master' - node.set['et_mesos']['slave']['slave_key'] = 'slave_value' - node.set['et_mesos']['slave']['attributes']['rackid'] = 'us-east-1b' + node.set['et_mesos']['agent']['master'] = 'test-master' + node.set['et_mesos']['agent']['agent_key'] = 'agent_value' + node.set['et_mesos']['agent']['attributes']['rackid'] = 'us-east-1b' end.converge(described_recipe) end - it "has a slave env file with each key-value pair from node['et_mesos']['slave']" do - expect(chef_run).to render_file("#{deploy_dir}/mesos-slave-env.sh") - .with_content 'export MESOS_slave_key=slave_value' + it "has a agent env file with each key-value pair from node['et_mesos']['agent']" do + expect(chef_run).to render_file("#{deploy_dir}/mesos-agent-env.sh") + .with_content 'export MESOS_agent_key=agent_value' end - it 'has a mesos-slave upstart script with a different command' do - expect(chef_run).to render_file('/etc/init/mesos-slave.conf') - .with_content 'exec /usr/bin/mesos-init-wrapper slave' + it 'has a mesos-agent upstart script with a different command' do + expect(chef_run).to render_file('/etc/init/mesos-agent.conf') + .with_content 'exec /usr/bin/mesos-init-wrapper agent' end describe '/etc/mesos/zk' do @@ -128,39 +128,39 @@ end end - describe '/etc/default/mesos-slave' do + describe '/etc/default/mesos-agent' do it 'creates it' do - expect(chef_run).to create_template '/etc/default/mesos-slave' + expect(chef_run).to create_template '/etc/default/mesos-agent' end it 'contains ISOLATION variable' do - expect(chef_run).to render_file('/etc/default/mesos-slave') + expect(chef_run).to render_file('/etc/default/mesos-agent') .with_content %r{^ISOLATION=cgroups/cpu,cgroups/mem$} end end - it 'creates /etc/mesos-slave' do - expect(chef_run).to create_directory('/etc/mesos-slave').with( + it 'creates /etc/mesos-agent' do + expect(chef_run).to create_directory('/etc/mesos-agent').with( recursive: true ) end - it 'removes the contents of /etc/mesos-slave dir' do - expect(chef_run).to run_execute 'rm -rf /etc/mesos-slave/*' + it 'removes the contents of /etc/mesos-agent dir' do + expect(chef_run).to run_execute 'rm -rf /etc/mesos-agent/*' end - describe 'configuration files in /etc/mesos-slave' do - it "sets the content of the file matching a key in node['et_mesos']['slave'] " \ + describe 'configuration files in /etc/mesos-agent' do + it "sets the content of the file matching a key in node['et_mesos']['agent'] " \ 'to its corresponding value' do - expect(chef_run).to render_file('/etc/mesos-slave/work_dir') + expect(chef_run).to render_file('/etc/mesos-agent/work_dir') .with_content '/tmp/mesos' - expect(chef_run).to render_file('/etc/mesos-slave/slave_key') - .with_content 'slave_value' + expect(chef_run).to render_file('/etc/mesos-agent/agent_key') + .with_content 'agent_value' - expect(chef_run).to create_directory '/etc/mesos-slave/attributes' + expect(chef_run).to create_directory '/etc/mesos-agent/attributes' - expect(chef_run).to render_file('/etc/mesos-slave/attributes/rackid') + expect(chef_run).to render_file('/etc/mesos-agent/attributes/rackid') .with_content 'us-east-1b' end end diff --git a/spec/recipes/master_spec.rb b/spec/recipes/master_spec.rb index c5f9fff..5eabcec 100644 --- a/spec/recipes/master_spec.rb +++ b/spec/recipes/master_spec.rb @@ -62,8 +62,8 @@ expect(chef_run).to create_template "#{deploy_dir}/masters" end - it 'creates the slaves config file' do - expect(chef_run).to create_template "#{deploy_dir}/slaves" + it 'creates the agents config file' do + expect(chef_run).to create_template "#{deploy_dir}/agents" end describe 'deploy env file' do @@ -131,14 +131,14 @@ end end - context 'when master and slave IPs are specified in attributes' do + context 'when master and agent IPs are specified in attributes' do let :chef_run do ChefSpec::ServerRunner.new do |node| # These attributes are set to avoid failing the Chef run node.set['et_mesos']['master']['zk'] = 'zk-string' node.set['et_mesos']['master']['quorum'] = '1' node.set['et_mesos']['master_ips'] = %w(10.0.0.1) - node.set['et_mesos']['slave_ips'] = %w(10.0.0.4) + node.set['et_mesos']['agent_ips'] = %w(10.0.0.4) end.converge described_recipe end @@ -147,8 +147,8 @@ .with_content(/^10.0.0.1$/) end - it 'has a slaves config with supplied IPs' do - expect(chef_run).to render_file("#{deploy_dir}/slaves") + it 'has a agents config with supplied IPs' do + expect(chef_run).to render_file("#{deploy_dir}/agents") .with_content(/^10.0.0.4$/) end end diff --git a/templates/default/agents.erb b/templates/default/agents.erb new file mode 100644 index 0000000..20341c5 --- /dev/null +++ b/templates/default/agents.erb @@ -0,0 +1,3 @@ +<% node['et_mesos']['agent_ips'].each do |s| %> +<%= s %> +<% end %> diff --git a/templates/default/etc-default-mesos-slave.erb b/templates/default/etc-default-mesos-agent.erb similarity index 100% rename from templates/default/etc-default-mesos-slave.erb rename to templates/default/etc-default-mesos-agent.erb diff --git a/templates/default/mesos-slave-env.sh.erb b/templates/default/mesos-agent-env.sh.erb similarity index 78% rename from templates/default/mesos-slave-env.sh.erb rename to templates/default/mesos-agent-env.sh.erb index e108964..d64a722 100644 --- a/templates/default/mesos-slave-env.sh.erb +++ b/templates/default/mesos-agent-env.sh.erb @@ -1,5 +1,5 @@ -# This file contains environment variables that are passed to mesos-slave. -# To get a description of all options run mesos-slave --help; any option +# This file contains environment variables that are passed to mesos-agent. +# To get a description of all options run mesos-agent --help; any option # supported as a command-line option is also supported as an environment # variable. @@ -8,8 +8,8 @@ # The mesos master URL to contact. Should be host:port for # non-ZooKeeper based masters, otherwise a zk:// or file:// URL. -<% if node['et_mesos']['slave'] %> - <% node['et_mesos']['slave'].each do |key, val| %> +<% if node['et_mesos']['agent'] %> + <% node['et_mesos']['agent'].each do |key, val| %> <% if val.respond_to?(:to_path_hash) -%> <% val.to_path_hash('_').each do |path_h| -%> export MESOS_<%= key %>_<%= path_h[:path] %>=<%= path_h[:content] %> diff --git a/templates/default/mesos-deploy-env.sh.erb b/templates/default/mesos-deploy-env.sh.erb index a513cdb..900c4d2 100644 --- a/templates/default/mesos-deploy-env.sh.erb +++ b/templates/default/mesos-deploy-env.sh.erb @@ -9,5 +9,5 @@ export SSH_OPTS="<%= node['et_mesos']['ssh_opts'] %>" -# Use sudo for launching masters and slaves. +# Use sudo for launching masters and agents. export DEPLOY_WITH_SUDO="<%= node['et_mesos']['deploy_with_sudo'] %>" diff --git a/templates/default/slaves.erb b/templates/default/slaves.erb deleted file mode 100644 index 7b4d0d2..0000000 --- a/templates/default/slaves.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% node['et_mesos']['slave_ips'].each do |s| %> -<%= s %> -<% end %> diff --git a/templates/default/upstart.conf.for.source.erb b/templates/default/upstart.conf.for.source.erb index ba4a303..a4a7da1 100644 --- a/templates/default/upstart.conf.for.source.erb +++ b/templates/default/upstart.conf.for.source.erb @@ -11,7 +11,7 @@ respawn # because it uses 'nohup' for spawning mesos-<%= @role %> script prefix=<%= node['et_mesos']['prefix'] %> - role=<%= @role %> # 'master' or 'slave' + role=<%= @role %> # 'master' or 'agent' exec_prefix=${prefix} deploy_dir=${prefix}/var/mesos/deploy # Increase the default number of open file descriptors. diff --git a/test/integration/helpers/serverspec/slave_configuration.rb b/test/integration/helpers/serverspec/agent_configuration.rb similarity index 67% rename from test/integration/helpers/serverspec/slave_configuration.rb rename to test/integration/helpers/serverspec/agent_configuration.rb index f2d35eb..7d82510 100644 --- a/test/integration/helpers/serverspec/slave_configuration.rb +++ b/test/integration/helpers/serverspec/agent_configuration.rb @@ -1,6 +1,6 @@ # encoding: utf-8 -shared_examples_for 'a slave node' do +shared_examples_for 'a agent node' do describe 'deploy env template' do let :deploy_env_file do file '/usr/etc/mesos/mesos-deploy-env.sh' @@ -21,39 +21,39 @@ end end - describe 'slave env template' do - let :slave_env_file do - file '/usr/etc/mesos/mesos-slave-env.sh' + describe 'agent env template' do + let :agent_env_file do + file '/usr/etc/mesos/mesos-agent-env.sh' end it 'exists in deploy directory' do - expect(slave_env_file).to be_a_file + expect(agent_env_file).to be_a_file end it 'contains log_dir variable' do - expect(slave_env_file.content).to match %r{^export MESOS_log_dir=/var/log/mesos$} + expect(agent_env_file.content).to match %r{^export MESOS_log_dir=/var/log/mesos$} end it 'contains work_dir variable' do - expect(slave_env_file.content).to match %r{^export MESOS_work_dir=/tmp/mesos$} + expect(agent_env_file.content).to match %r{^export MESOS_work_dir=/tmp/mesos$} end it 'contains isolation variable' do - expect(slave_env_file.content).to match %r{^export MESOS_isolation=cgroups/cpu,cgroups/mem$} + expect(agent_env_file.content).to match %r{^export MESOS_isolation=cgroups/cpu,cgroups/mem$} end it 'contains rackid variable' do - expect(slave_env_file.content).to match(/^export MESOS_attributes_rackid=us-east-1b$/) + expect(agent_env_file.content).to match(/^export MESOS_attributes_rackid=us-east-1b$/) end end - context 'slave upstart script' do - describe file '/etc/init/mesos-slave.conf' do + context 'agent upstart script' do + describe file '/etc/init/mesos-agent.conf' do it { is_expected.to be_file } end end - describe service('mesos-slave') do + describe service('mesos-agent') do it { should be_enabled } if %w(ubuntu debian).include? os[:family] # service mesos-master is required in order which the below was passed. it { should be_running } diff --git a/test/integration/helpers/serverspec/master_configuration.rb b/test/integration/helpers/serverspec/master_configuration.rb index 7c5d56e..4776ef0 100644 --- a/test/integration/helpers/serverspec/master_configuration.rb +++ b/test/integration/helpers/serverspec/master_configuration.rb @@ -17,19 +17,19 @@ end end - describe 'slaves file' do - let :slaves_file do - file '/usr/etc/mesos/slaves' + describe 'agents file' do + let :agents_file do + file '/usr/etc/mesos/agents' end it 'creates it' do - expect(slaves_file).to be_a_file + expect(agents_file).to be_a_file end it 'contains a newline separated list of configured master IPs' do - expect(slaves_file.content).to match(/^10.0.0.4$/) - expect(slaves_file.content).to match(/^10.0.0.5$/) - expect(slaves_file.content).to match(/^10.0.0.6$/) + expect(agents_file.content).to match(/^10.0.0.4$/) + expect(agents_file.content).to match(/^10.0.0.5$/) + expect(agents_file.content).to match(/^10.0.0.6$/) end end diff --git a/test/integration/helpers/serverspec/source_installation.rb b/test/integration/helpers/serverspec/source_installation.rb index a5e82ed..12acfbd 100644 --- a/test/integration/helpers/serverspec/source_installation.rb +++ b/test/integration/helpers/serverspec/source_installation.rb @@ -102,13 +102,13 @@ %w( mesos-daemon.sh mesos-master - mesos-slave + mesos-agent mesos-start-cluster.sh mesos-start-masters.sh - mesos-start-slaves.sh + mesos-start-agents.sh mesos-stop-cluster.sh mesos-stop-masters.sh - mesos-stop-slaves.sh + mesos-stop-agents.sh ).map { |script| "/usr/local/sbin/#{script}" } end diff --git a/test/integration/helpers/serverspec/spec_helper.rb b/test/integration/helpers/serverspec/spec_helper.rb index 6568cd3..f017787 100644 --- a/test/integration/helpers/serverspec/spec_helper.rb +++ b/test/integration/helpers/serverspec/spec_helper.rb @@ -6,4 +6,4 @@ require 'mesosphere_installation' require 'source_installation' require 'master_configuration' -require 'slave_configuration' +require 'agent_configuration' diff --git a/test/integration/mesosphere_slave/serverspec/localhost/mesosphere_slave_spec.rb b/test/integration/mesosphere_agent/serverspec/localhost/mesosphere_agent_spec.rb similarity index 74% rename from test/integration/mesosphere_slave/serverspec/localhost/mesosphere_slave_spec.rb rename to test/integration/mesosphere_agent/serverspec/localhost/mesosphere_agent_spec.rb index de9bdf2..c35dc66 100644 --- a/test/integration/mesosphere_slave/serverspec/localhost/mesosphere_slave_spec.rb +++ b/test/integration/mesosphere_agent/serverspec/localhost/mesosphere_agent_spec.rb @@ -2,16 +2,16 @@ require 'spec_helper' -describe 'et_mesos::slave' do +describe 'et_mesos::agent' do it_behaves_like 'an installation from mesosphere', with_zookeeper: true - it_behaves_like 'a slave node' + it_behaves_like 'a agent node' - context 'slave upstart script' do - describe file '/etc/init/mesos-slave.conf' do + context 'agent upstart script' do + describe file '/etc/init/mesos-agent.conf' do describe '#content' do subject { super().content } - it { is_expected.to include 'exec /usr/bin/mesos-init-wrapper slave' } + it { is_expected.to include 'exec /usr/bin/mesos-init-wrapper agent' } end end end @@ -49,32 +49,32 @@ end end - describe 'slave specific configuration file' do - let :slave_file do - file('/etc/default/mesos-slave') + describe 'agent specific configuration file' do + let :agent_file do + file('/etc/default/mesos-agent') end it 'creates it' do - expect(slave_file).to be_a_file + expect(agent_file).to be_a_file end it 'contains MASTER variable' do - expect(slave_file.content).to match %r{^MASTER=`cat /etc/mesos/zk`$} + expect(agent_file.content).to match %r{^MASTER=`cat /etc/mesos/zk`$} end it 'contains ISOLATION variable' do - expect(slave_file.content).to match %r{^ISOLATION=cgroups/cpu,cgroups/mem$} + expect(agent_file.content).to match %r{^ISOLATION=cgroups/cpu,cgroups/mem$} end end - describe 'mesos-slave directory' do + describe 'mesos-agent directory' do it 'creates it' do - expect(file('/etc/mesos-slave')).to be_a_directory + expect(file('/etc/mesos-agent')).to be_a_directory end describe 'work dir file' do let :work_dir_file do - file '/etc/mesos-slave/work_dir' + file '/etc/mesos-agent/work_dir' end it 'creates it' do @@ -88,7 +88,7 @@ describe 'rack id file' do let :rack_id_file do - file '/etc/mesos-slave/attributes/rackid' + file '/etc/mesos-agent/attributes/rackid' end it 'exists' do diff --git a/test/integration/source_agent/serverspec/localhost/source_agent_spec.rb b/test/integration/source_agent/serverspec/localhost/source_agent_spec.rb new file mode 100644 index 0000000..b3b522f --- /dev/null +++ b/test/integration/source_agent/serverspec/localhost/source_agent_spec.rb @@ -0,0 +1,18 @@ +# encoding: utf-8 + +require 'spec_helper' + +describe 'et_mesos::agent' do + it_behaves_like 'an installation from source' + + it_behaves_like 'a agent node' + + context 'agent upstart script' do + describe file '/etc/init/mesos-agent.conf' do + describe '#content' do + subject { super().content } + it { is_expected.to include 'role=agent' } + end + end + end +end diff --git a/test/integration/source_slave/serverspec/localhost/source_slave_spec.rb b/test/integration/source_slave/serverspec/localhost/source_slave_spec.rb deleted file mode 100644 index c8ba292..0000000 --- a/test/integration/source_slave/serverspec/localhost/source_slave_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -# encoding: utf-8 - -require 'spec_helper' - -describe 'et_mesos::slave' do - it_behaves_like 'an installation from source' - - it_behaves_like 'a slave node' - - context 'slave upstart script' do - describe file '/etc/init/mesos-slave.conf' do - describe '#content' do - subject { super().content } - it { is_expected.to include 'role=slave' } - end - end - end -end