
The 'swiftinit' provider is a custom provider of the service type that manages swift services using swift-init. Use of the swiftinit service provider is optional, the default is to use service providers specified in params file. This provider also manages swift services starting at boot by adding or removing a templated init or services file and making systemctl calls. See README for more detail. A wrapper defined type 'swift::service' has been created to simplify use of the swiftinit provider without adding logic to every class. this wrapper also aids in input validation and testing of the swiftinit provider. Two extra runs of apply_manifest have been added to the basic_swift_spec acceptance test. The service_provider is set to "swiftinit". The first run catches any errors upgrading to the swiftinit service provider and the second run tests idempotency. This patch is an initial step towards using swift-init to manage multiple swift services out of different configuration files such as is needed to run a separate replication network. Change-Id: I2f71c82c7a6c463f8c76a193409c0a17daa15bda
72 lines
1.7 KiB
Ruby
72 lines
1.7 KiB
Ruby
#! /usr/bin/env ruby
|
|
##
|
|
## Unit testing for the swiftinit service provider
|
|
##
|
|
|
|
require 'spec_helper'
|
|
|
|
provider_class = Puppet::Type.type(:service).provider(:swiftinit)
|
|
|
|
describe provider_class do
|
|
|
|
|
|
before(:each) do
|
|
# Create a mock resource
|
|
@resource = stub 'resource'
|
|
|
|
@provider = provider_class.new
|
|
|
|
# A catch all; no parameters set
|
|
@resource.stubs(:[]).returns(nil)
|
|
|
|
# But set name, source and path
|
|
@resource.stubs(:[]).with(:name).returns "swift-object-server"
|
|
@resource.stubs(:[]).with(:ensure).returns :enable
|
|
@resource.stubs(:[]).with(:pattern).returns "swift-object"
|
|
@resource.stubs(:[]).with(:manifest).returns "object-server"
|
|
@resource.stubs(:ref).returns "Service[myservice]"
|
|
|
|
@provider.resource = @resource
|
|
|
|
@provider.stubs(:command).with(:systemctl_run).returns "systemctl_run"
|
|
|
|
@provider.stubs(:systemctl_run)
|
|
|
|
end
|
|
|
|
it "should have an status method" do
|
|
expect(@provider).to respond_to(:status)
|
|
end
|
|
|
|
it "should have an start method" do
|
|
expect(@provider).to respond_to(:start)
|
|
end
|
|
|
|
it "should have an stop method" do
|
|
expect(@provider).to respond_to(:stop)
|
|
end
|
|
|
|
it "should have an restart method" do
|
|
expect(@provider).to respond_to(:restart)
|
|
end
|
|
|
|
it "should have an refresh method" do
|
|
expect(@provider).to respond_to(:refresh)
|
|
end
|
|
|
|
it "should have an enabled? method" do
|
|
expect(@provider).to respond_to(:enabled?)
|
|
end
|
|
|
|
it "should have an enable method" do
|
|
expect(@provider).to respond_to(:enable)
|
|
end
|
|
|
|
it "should have a disable method" do
|
|
expect(@provider).to respond_to(:disable)
|
|
end
|
|
|
|
end
|
|
|
|
##### TODO figure out how to stub out files and test each method more.
|