Skip to content

Instantly share code, notes, and snippets.

View raphink's full-sized avatar
🐝
eBPF everything!

Raphaël Pinson raphink

🐝
eBPF everything!
View GitHub Profile
# /var/lib/puppet/spec/class/wrk4.wrk.cby.camptocamp.com/fail_spec.rb
describe 'failure' do
it { 2.should == 3 }
end
require 'catalog'
describe 'package' do
subject { Catalog.instance }
# subject { YAML.load_file('/tmp/catalog') }
it { should contain_package('augeas') }
it { should contain_package('augeas-lenses') }
it { should contain_package('augeas-tools') }
end
require 'serverspec'
require 'pathname'
require 'open3'
module ExecHelper
def ssh_exec(cmd, opts={})
stdin, stdout, stderr = Open3.popen3(cmd)
{ :stdout => stdout.gets, :stderr => stderr.gets, :exit_code => $?.to_i, :exit_signal => nil }
end
end
info: Retrieving plugin
err: Could not retrieve catalog from remote server: Unit tests failed:
.FF.F
Failures:
1) puppet
Failure/Error: it { should contain_package('ppet') }
expected that the catalogue would contain Package[ppet]
# /var/lib/puppet/spec/class/puppet__client__base/puppet_package_spec.rb:4
require 'timeout'
require 'open-uri'
def cache
'/var/tmp/public_ip.fact.cache'
end
def can_connect? (wait_sec=2, url)
Timeout::timeout(wait_sec) { open(url) }
return true
require 'puppet'
require 'puppet/type/user'
resource = Puppet::Type::User.new(:name => 'rpinson', :uid => '1502')
# resource = Puppet::Type::Exec.new(:name => '/bin/test', :unless => '/bin/true')
# resource = Puppet::Type::Service.new(:name => 'ssh', :ensure => 'running', :enable => 'false')
# Ensurable
if resource.provider.respond_to?(:exists?) and ! resource.provider.exists?
return false
$ RUBYLIB=/home/rpinson/dev/serverspec/lib/ rspec --color --format d
ssh
should be installed
should be enabled
should be running
port 22
should be listening
module PuppetSpecReport
def status= (status)
@status = status
end
end
class Puppet::Transaction::Report::RestSpec < Puppet::Transaction::Report::Rest
def save(request)
@raphink
raphink / local_tests
Last active February 4, 2016 00:44
Distributed serverspec tests using MCollective instead of SSH.
+-------------------------------------+ +-------------------------------------+
| Client | | Server |
|-------------------------------------| |-------------------------------------|
| | | |
| mco spec | | Serverspec |
| + | | ^ |
| | | | | |
| v | | + |
| MCollective::Application | | RSpec::Core::Runner#run |
| | | | ^ |
require 'spec_helper'
describe 'ssh', :classes => [ 'augeas' ], :facts => { :osfamily => 'Debian' } do
it { should be_installed }
it { should be_enabled }
it { should be_running }
end
describe 'port 22', :classes => ['ssh'] do
it { should be_listening }