provider-testing 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/LICENSE +58 -0
- data/README.md +33 -0
- data/Rakefile +12 -0
- data/lib/provider-testing.rb +22 -0
- data/lib/provider-testing/env.rb +13 -0
- data/lib/provider-testing/helper.rb +40 -0
- data/lib/provider-testing/mkreg.rb +43 -0
- data/lib/provider-testing/pegasus.rb +147 -0
- data/lib/provider-testing/registration.rb +52 -0
- data/lib/provider-testing/sfcb.rb +105 -0
- data/lib/tasks/clean.rake +2 -0
- data/lib/tasks/configuration.rake +7 -0
- data/lib/tasks/pegasus.rake +9 -0
- data/lib/tasks/registration.rake +15 -0
- data/lib/tasks/sfcb.rake +9 -0
- data/lib/tasks/test.rake +11 -0
- data/package/rubygem-provider-testing.changes +5 -0
- data/package/rubygem-provider-testing.spec +68 -0
- data/provider-testing.gemspec +31 -0
- data/tasks/clean.rake +9 -0
- data/tasks/doc.rake +14 -0
- data/tasks/test.rake +6 -0
- metadata +121 -0
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the GPL
|
3
|
+
(see COPYING.txt file), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a) place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b) use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c) rename any non-standard executables so the names do not conflict
|
21
|
+
with standard executables, which must also be provided.
|
22
|
+
|
23
|
+
d) make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or executable
|
26
|
+
form, provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a) distribute the executables and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b) accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c) give non-standard executables non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d) make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under this terms.
|
43
|
+
|
44
|
+
They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
|
45
|
+
files under the ./missing directory. See each file for the copying
|
46
|
+
condition.
|
47
|
+
|
48
|
+
5. The scripts and library files supplied as input to or produced as
|
49
|
+
output from the software do not automatically fall under the
|
50
|
+
copyright of the software, but belong to whomever generated them,
|
51
|
+
and may be sold commercially, and may be aggregated with this
|
52
|
+
software.
|
53
|
+
|
54
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
55
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
56
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
57
|
+
PURPOSE.
|
58
|
+
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# About
|
2
|
+
|
3
|
+
This is a full testsuite for (the Ruby part of) cmpi-bindings.
|
4
|
+
|
5
|
+
# Author
|
6
|
+
|
7
|
+
Copyright (c) 2013 Klaus Kämpf <kkaempf@suse.de>
|
8
|
+
|
9
|
+
# License
|
10
|
+
|
11
|
+
Licensed under the Ruby license
|
12
|
+
|
13
|
+
# Requirements
|
14
|
+
|
15
|
+
Ruby (1.8 or 1.9), rake, sblim-sfcb, sblim-sfcc and sfcc.gem (from rubygems.org)
|
16
|
+
|
17
|
+
# Invocation
|
18
|
+
|
19
|
+
Run
|
20
|
+
|
21
|
+
rake
|
22
|
+
|
23
|
+
to run all test cases.
|
24
|
+
|
25
|
+
This will spawn a local sfcbd listening at port 12345, point it to the
|
26
|
+
Ruby cmpi provider from build/swig/ruby, load Ruby class provider from
|
27
|
+
test/rake/samples/providers and execute the tests from
|
28
|
+
test/rake/test_*.rb
|
29
|
+
|
30
|
+
|
31
|
+
# Issues
|
32
|
+
|
33
|
+
The testsuite currently fails to stop sfcbd after running all tests.
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
TOPLEVEL = File.dirname(__FILE__)
|
5
|
+
NAME = File.basename TOPLEVEL
|
6
|
+
MOFDIR = "/usr/share/mof/#{NAME}"
|
7
|
+
CMPIDIR = "/usr/share/cmpi"
|
8
|
+
DESTDIR = ENV['DESTDIR']
|
9
|
+
|
10
|
+
task :default => [:test]
|
11
|
+
|
12
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# provider-testing.rb
|
3
|
+
#
|
4
|
+
# A Ruby-based testsuite for CIM providers
|
5
|
+
#
|
6
|
+
# Copyright (c) 2013 Klaus Kämpf <kkaempf@suse.de>
|
7
|
+
#
|
8
|
+
# Licensed under the Ruby license
|
9
|
+
#
|
10
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
11
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
12
|
+
|
13
|
+
module ProviderTesting
|
14
|
+
VERSION = '0.3.2'
|
15
|
+
require 'provider-testing/helper'
|
16
|
+
def self.setup klass = "", namespace = "root/cimv2"
|
17
|
+
Helper.setup klass, namespace
|
18
|
+
end
|
19
|
+
def self.teardown
|
20
|
+
Helper.teardown
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#
|
2
|
+
# test/env.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
unless defined? TOPLEVEL
|
6
|
+
TOPLEVEL = ENV['TOPLEVEL'] || "/tmp/provider-testing"
|
7
|
+
Dir.mkdir(TOPLEVEL) unless Dir.exists?(TOPLEVEL)
|
8
|
+
end
|
9
|
+
|
10
|
+
NAMESPACE = "test/test"
|
11
|
+
|
12
|
+
TMPDIR = File.join(TOPLEVEL, "tmp")
|
13
|
+
PROVIDERDIR = "#{TOPLEVEL}/src" unless defined?(PROVIDERDIR)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#
|
2
|
+
# test/helper.rb
|
3
|
+
#
|
4
|
+
|
5
|
+
require "provider-testing/env"
|
6
|
+
|
7
|
+
module ProviderTesting
|
8
|
+
class Helper
|
9
|
+
|
10
|
+
# called from rake
|
11
|
+
|
12
|
+
def self.cimom= name
|
13
|
+
@@cimom ||= case name
|
14
|
+
when :sfcb
|
15
|
+
require_relative "./sfcb"
|
16
|
+
Sfcb.new :tmpdir => TMPDIR, :provider => PROVIDERDIR
|
17
|
+
when :pegasus
|
18
|
+
require_relative "./pegasus"
|
19
|
+
Pegasus.new :tmpdir => TMPDIR, :provider => PROVIDERDIR
|
20
|
+
else
|
21
|
+
raise "Unknown CIMOM #{@cimom}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
def self.cimom
|
25
|
+
@@cimom rescue (self.cimom = :sfcb; @@cimom)
|
26
|
+
end
|
27
|
+
|
28
|
+
# called from test/unit
|
29
|
+
|
30
|
+
def self.setup klass = "", namespace = "root/cimv2"
|
31
|
+
client = Sfcc::Cim::Client.connect(:uri => self.cimom.uri, :verify => false)
|
32
|
+
raise "Connection error" unless client
|
33
|
+
op = Sfcc::Cim::ObjectPath.new(namespace, klass, client)
|
34
|
+
return client, op
|
35
|
+
end
|
36
|
+
def self.teardown
|
37
|
+
self.cimom.stop
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#
|
2
|
+
# Transform generic .registration format to
|
3
|
+
# sfcb-specific .reg format
|
4
|
+
#
|
5
|
+
module ProviderTesting
|
6
|
+
# read .registration file, return array of
|
7
|
+
# 0 1 2 3 4..-1
|
8
|
+
# classname namespace providername providermodule caps
|
9
|
+
def self.rdreg from
|
10
|
+
File.open(from, "r") do |f|
|
11
|
+
while (l = f.gets)
|
12
|
+
next if l =~ /^\s*#.*$/
|
13
|
+
l.chomp!
|
14
|
+
next if l.empty?
|
15
|
+
reg = l.split(" ")
|
16
|
+
raise unless reg.size > 4
|
17
|
+
yield reg
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.mkreg from, out
|
23
|
+
# STDERR.puts "mkreg #{from}"
|
24
|
+
self.rdreg from do |reg|
|
25
|
+
# 0 1 2 3 4..-1
|
26
|
+
# classname namespace providername providermodule caps
|
27
|
+
out.puts "[#{reg[0]}]"
|
28
|
+
out.puts " provider: #{reg[2]}"
|
29
|
+
out.puts " location: #{reg[3]}"
|
30
|
+
out.puts " type: #{reg[4..-1].join(' ')}"
|
31
|
+
out.puts " namespace: #{reg[1]}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.convert_registrations outfile, *regfiles
|
36
|
+
# STDERR.puts "convert_registrations => #{outfile}"
|
37
|
+
File.open(outfile, "w+") do |out|
|
38
|
+
regfiles.each do |regfile|
|
39
|
+
mkreg regfile, out
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
#
|
2
|
+
# Start and stop Pegasus for testing
|
3
|
+
#
|
4
|
+
require 'tmpdir'
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
require "provider-testing/env"
|
8
|
+
|
9
|
+
module ProviderTesting
|
10
|
+
class Pegasus
|
11
|
+
attr_reader :pid, :uri, :dir, :stage_dir, :registration_dir, :providers_dir
|
12
|
+
private
|
13
|
+
def getconfig name
|
14
|
+
result = nil
|
15
|
+
pipe = IO.popen "sudo cimconfig -g #{name}"
|
16
|
+
unless pipe
|
17
|
+
system "sudo cimserver"
|
18
|
+
pipe = IO.popen "sudo cimconfig -g #{name}"
|
19
|
+
end
|
20
|
+
if pipe.read =~ /^Current value:\s+(.*)$/
|
21
|
+
result = $1
|
22
|
+
end
|
23
|
+
pipe.close
|
24
|
+
result
|
25
|
+
end
|
26
|
+
def setconfig name, value
|
27
|
+
puts "Setting #{name} to '#{value}'"
|
28
|
+
system "sudo cimconfig -p -s '#{name}=#{value}'"
|
29
|
+
end
|
30
|
+
public
|
31
|
+
|
32
|
+
def initialize args = {}
|
33
|
+
@execfile = "/usr/sbin/cimserver"
|
34
|
+
@port = 12345
|
35
|
+
@pid = nil
|
36
|
+
@config = {}
|
37
|
+
|
38
|
+
tmpdir = args[:tmpdir] || Dir.tmpdir
|
39
|
+
|
40
|
+
File.directory?(tmpdir) || Dir.mkdir(tmpdir)
|
41
|
+
|
42
|
+
@dir = File.join(tmpdir, "pegasus")
|
43
|
+
Dir.mkdir @dir rescue nil
|
44
|
+
|
45
|
+
STDERR.puts "Pegasus directory at #{@dir}"
|
46
|
+
|
47
|
+
# location of cmpi-bindings for Ruby
|
48
|
+
@providers_dir = File.expand_path(File.join(TOPLEVEL,"..","..","build","swig","ruby"))
|
49
|
+
|
50
|
+
# location of cmpi-bindings for Python
|
51
|
+
@providers_dir = File.expand_path(File.join(TOPLEVEL,"..","..","build","swig","python"))
|
52
|
+
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
def uri
|
57
|
+
unless @uri
|
58
|
+
if getconfig("enableHttpConnection") == "true"
|
59
|
+
scheme = "http"
|
60
|
+
port = getconfig("httpPort") || 5988
|
61
|
+
elsif getconfig("enableHttpsConnection") == "true"
|
62
|
+
scheme = "https"
|
63
|
+
port = getconfig("httpsPort") || 5989
|
64
|
+
else
|
65
|
+
raise "No enabled connection"
|
66
|
+
end
|
67
|
+
# scheme, userinfo, host, port, registry, path, opaque, query and fragment,
|
68
|
+
@uri = URI::HTTP.new scheme, "wsman:secret", "localhost", port
|
69
|
+
end
|
70
|
+
@uri
|
71
|
+
end
|
72
|
+
|
73
|
+
def mkcfg
|
74
|
+
# trace_components = [ALL
|
75
|
+
# AsyncOpNode
|
76
|
+
# Authentication
|
77
|
+
# Authorization
|
78
|
+
# BinaryMessageHandler
|
79
|
+
# Channel
|
80
|
+
# CimData
|
81
|
+
# CIMExportRequestDispatcher
|
82
|
+
# CIMOMHandle
|
83
|
+
# Config
|
84
|
+
# ConfigurationManager
|
85
|
+
# ControlProvider
|
86
|
+
# CQL
|
87
|
+
# DiscardedData
|
88
|
+
# Dispatcher
|
89
|
+
# ExportClient
|
90
|
+
# Http
|
91
|
+
# IndDelivery
|
92
|
+
# IndicationHandlerService
|
93
|
+
# IndicationService
|
94
|
+
# IndicationServiceInternal
|
95
|
+
# IndHandler
|
96
|
+
# IPC
|
97
|
+
# L10N
|
98
|
+
# Listener
|
99
|
+
# Memory
|
100
|
+
# MessageQueueService
|
101
|
+
# MetaDispatcher
|
102
|
+
# ObjectResolution
|
103
|
+
# OsAbstraction
|
104
|
+
# ProviderAgent
|
105
|
+
# ProviderManager
|
106
|
+
# ProvManager
|
107
|
+
# Registration
|
108
|
+
# Repository
|
109
|
+
# Server
|
110
|
+
# Shutdown
|
111
|
+
# SubscriptionService
|
112
|
+
# Thread
|
113
|
+
# UserManager
|
114
|
+
# WQL
|
115
|
+
# XmlIO
|
116
|
+
# XmlParser
|
117
|
+
# XmlReader
|
118
|
+
# XmlWriter
|
119
|
+
@config = {
|
120
|
+
"daemon" => "false",
|
121
|
+
"enableAuthentication" => "false",
|
122
|
+
"enableHttpConnection" => "true",
|
123
|
+
"enableHttpsConnection" => "false",
|
124
|
+
"httpPort" => @port,
|
125
|
+
"traceFilePath" => File.join(@dir, "trace.log"),
|
126
|
+
"traceLevel" => 1, # 1,2,3,4
|
127
|
+
# "traceComponents" => "",
|
128
|
+
# "logLevel" => "INFORMATION", # TRACE, INFORMATION, WARNING, SEVERE, FATAL.
|
129
|
+
# "repositoryDir" => "/var/lib/Pegasus/repository",
|
130
|
+
"providerDir" => "#{@providers_dir}:/usr/lib64/cmpi:/usr/lib/cmpi:/usr/lib64/pycim:/usr/lib/pycim:/usr/lib64/Pegasus/providers:/usr/lib/Pegasus/providers"
|
131
|
+
}
|
132
|
+
end
|
133
|
+
|
134
|
+
def start
|
135
|
+
unless system "sudo #{@execfile} --status"
|
136
|
+
cmd = ["sudo", @execfile] + @config.collect{ |k,v| "#{k}=#{v}" }
|
137
|
+
puts cmd.inspect
|
138
|
+
system *cmd
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def stop
|
143
|
+
system "sudo #{@execfile} -s"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
end # module
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "provider-testing/env"
|
2
|
+
require "provider-testing/mkreg"
|
3
|
+
require "provider-testing/sfcb"
|
4
|
+
|
5
|
+
#
|
6
|
+
# register
|
7
|
+
# args: Hash
|
8
|
+
# :klass => CIM class name
|
9
|
+
# :namespace => namespace, defaults to test/test
|
10
|
+
# :mofdir => where to find <klass>.mof, defaults to TOPLEVEL/samples/mof
|
11
|
+
# :regdir => where to find <klass>.registration, defaults to TOPLEVEL/samples/registration
|
12
|
+
#
|
13
|
+
|
14
|
+
module ProviderTesting
|
15
|
+
def self.register_file file
|
16
|
+
self.rdreg file do |reg|
|
17
|
+
# 0 1 2 3 4..-1
|
18
|
+
# classname namespace providername providermodule caps
|
19
|
+
self.register_klass :klass => reg[0], :namespace => reg[1]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.register_klass args
|
24
|
+
args[:mofdir] ||= File.join(TOPLEVEL, "mof")
|
25
|
+
args[:regdir] ||= File.join(TOPLEVEL, "registration")
|
26
|
+
args[:namespace] ||= "test/test"
|
27
|
+
self.register args[:klass], args[:namespace], args[:mofdir], args[:regdir]
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.register klass, namespace, mofdir, regdir
|
31
|
+
raise "No :klass passed to registration" unless klass
|
32
|
+
tmpregname = File.join(TMPDIR, "#{klass}.reg")
|
33
|
+
|
34
|
+
# convert generic <klass>.registration to sfcb-specific <klass>.reg
|
35
|
+
convert_registrations tmpregname, File.join(regdir, "#{klass}.registration")
|
36
|
+
|
37
|
+
# stage .reg+.mof to namespace
|
38
|
+
cmd = "sfcbstage -s #{Helper.cimom.stage_dir} -n #{namespace} -r #{tmpregname} #{File.join(mofdir,klass)}.mof"
|
39
|
+
# STDERR.puts cmd
|
40
|
+
res = `#{cmd} 2> #{TMPDIR}/sfcbstage.err`
|
41
|
+
raise "Failed: #{cmd}" unless $? == 0
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.mkrepos
|
45
|
+
cimom = Helper.cimom
|
46
|
+
cmd = "sfcbrepos -f -s #{cimom.stage_dir} -r #{cimom.registration_dir}"
|
47
|
+
# STDERR.puts cmd
|
48
|
+
res = `#{cmd} 2> #{TMPDIR}/sfcbrepos.err`
|
49
|
+
raise "Failed: #{cmd}" unless $? == 0
|
50
|
+
end
|
51
|
+
|
52
|
+
end # module
|
@@ -0,0 +1,105 @@
|
|
1
|
+
#
|
2
|
+
# Start and stop sfcb for testing
|
3
|
+
#
|
4
|
+
require 'tmpdir'
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
require "provider-testing/env"
|
8
|
+
|
9
|
+
module ProviderTesting
|
10
|
+
class Sfcb
|
11
|
+
attr_reader :pid, :uri, :dir, :stage_dir, :registration_dir, :providers_dir
|
12
|
+
|
13
|
+
def initialize args = {}
|
14
|
+
@execfile = "/usr/sbin/sfcbd"
|
15
|
+
@port = 12345
|
16
|
+
@pid = nil
|
17
|
+
|
18
|
+
tmpdir = args[:tmpdir] || Dir.tmpdir
|
19
|
+
|
20
|
+
File.directory?(tmpdir) || Dir.mkdir(tmpdir)
|
21
|
+
|
22
|
+
@dir = File.join(tmpdir, "sfcb")
|
23
|
+
Dir.mkdir @dir rescue nil
|
24
|
+
|
25
|
+
# STDERR.puts "Sfcb directory at #{@dir}"
|
26
|
+
|
27
|
+
# location of cmpi-bindings for Ruby
|
28
|
+
@providers_dir = PROVIDERDIR
|
29
|
+
|
30
|
+
@stage_dir = File.join(dir, "stage")
|
31
|
+
Dir.mkdir @stage_dir rescue nil
|
32
|
+
File.symlink("/var/lib/sfcb/stage/default.reg", File.join(@stage_dir, "default.reg")) rescue nil
|
33
|
+
@mofs_dir = args[:mof] || File.join(@stage_dir, "mofs")
|
34
|
+
Dir.mkdir @mofs_dir rescue nil
|
35
|
+
|
36
|
+
@registration_dir = args[:registration] || File.join(dir, "registration")
|
37
|
+
Dir.mkdir @registration_dir rescue nil
|
38
|
+
|
39
|
+
# Kernel.system "sfcbrepos", "-s", @stage_dir, "-r", @registration_dir, "-f"
|
40
|
+
|
41
|
+
@uri = URI::HTTP.build :host => 'localhost', :port => @port, :userinfo => "wsman:secret"
|
42
|
+
end
|
43
|
+
|
44
|
+
def mkcfg
|
45
|
+
@cfgfile = File.join(@dir, "sfcb.cfg")
|
46
|
+
File.open(@cfgfile, "w+") do |f|
|
47
|
+
# create sfcb config file
|
48
|
+
|
49
|
+
{
|
50
|
+
"enableHttp" => true,
|
51
|
+
"httpPort" => @port,
|
52
|
+
"enableHttps" => false,
|
53
|
+
"enableSlp" => false,
|
54
|
+
"providerSampleInterval" => 5,
|
55
|
+
"providerTimeoutInterval" => 10,
|
56
|
+
"keepaliveTimeout" => 2,
|
57
|
+
"registrationDir" => @registration_dir,
|
58
|
+
"localSocketPath" => File.join(@dir, "sfcbLocalSocket"),
|
59
|
+
"httpSocketPath" => File.join(@dir, "sfcbHttpSocket"),
|
60
|
+
"providerDirs" => " #{@providers_dir} /usr/lib64/sfcb /usr/lib/sfcb /usr/lib64 /usr/lib /usr/lib64/cmpi /usr/lib/cmpi"
|
61
|
+
}.each do |k,v|
|
62
|
+
f.puts "#{k}: #{v}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def start
|
68
|
+
raise "Already running" if @pid
|
69
|
+
@pid = fork
|
70
|
+
if @pid.nil?
|
71
|
+
# child
|
72
|
+
sfcb_trace_file = File.join(TMPDIR, "sfcb_trace_file")
|
73
|
+
sblim_trace_file = File.join(TMPDIR, "sblim_trace_file")
|
74
|
+
ruby_providers_dir = PROVIDERDIR
|
75
|
+
Dir.chdir File.expand_path("..", File.dirname(__FILE__))
|
76
|
+
{
|
77
|
+
"SFCB_TRACE_FILE" => sfcb_trace_file,
|
78
|
+
"SFCB_TRACE" => 4,
|
79
|
+
"SBLIM_TRACE_FILE" => sblim_trace_file,
|
80
|
+
"SBLIM_TRACE" => 4,
|
81
|
+
# "CMPI_BINDINGS_TRACE_LEVEL" => 4,
|
82
|
+
# "CMPISFCC_DEBUG" => "true",
|
83
|
+
"RUBY_PROVIDERS_DIR" => ruby_providers_dir
|
84
|
+
}.each do |k,v|
|
85
|
+
ENV[k] = v.to_s
|
86
|
+
end
|
87
|
+
File.delete(sfcb_trace_file) rescue nil
|
88
|
+
File.delete(sblim_trace_file) rescue nil
|
89
|
+
$stderr.reopen(File.join(TMPDIR, "sfcbd.err"), "w")
|
90
|
+
$stdout.reopen(File.join(TMPDIR, "sfcbd.out"), "w")
|
91
|
+
Kernel.exec "#{@execfile}", "-c", "#{@cfgfile}"#, "-t", "32768"
|
92
|
+
end
|
93
|
+
@pid
|
94
|
+
end
|
95
|
+
|
96
|
+
def stop
|
97
|
+
return unless @pid
|
98
|
+
Process.kill "QUIT", @pid
|
99
|
+
sleep 3
|
100
|
+
Process.wait
|
101
|
+
@pid = nil
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end # module
|
@@ -0,0 +1,15 @@
|
|
1
|
+
task :sfcb_registration => [:sfcb_configuration] do |t|
|
2
|
+
puts "Register all providers"
|
3
|
+
|
4
|
+
require "provider-testing/registration"
|
5
|
+
Dir['registration/*.registration'].each do |regname|
|
6
|
+
puts " #{regname}"
|
7
|
+
ProviderTesting.register_file regname
|
8
|
+
end
|
9
|
+
ProviderTesting.mkrepos
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
task :pegasus_registration => [:pegasus_configuration] do
|
14
|
+
puts "Registering Pegasus providers"
|
15
|
+
end
|
data/lib/tasks/sfcb.rake
ADDED
data/lib/tasks/test.rake
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
#
|
2
|
+
# spec file for package rubygem-provider-testing (Version 0.0.1)
|
3
|
+
#
|
4
|
+
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
5
|
+
#
|
6
|
+
# All modifications and additions to the file contributed by third parties
|
7
|
+
# remain the property of their copyright owners, unless otherwise agreed
|
8
|
+
# upon. The license for this file, and modifications and additions to the
|
9
|
+
# file, is the same license as for the pristine package itself (unless the
|
10
|
+
# license for the pristine package is not an Open Source License, in which
|
11
|
+
# case the license is the MIT License). An "Open Source License" is a
|
12
|
+
# license that conforms to the Open Source Definition (Version 1.9)
|
13
|
+
# published by the Open Source Initiative.
|
14
|
+
|
15
|
+
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
16
|
+
#
|
17
|
+
|
18
|
+
# norootforbuild
|
19
|
+
|
20
|
+
Name: rubygem-provider-testing
|
21
|
+
Version: 0.2.0
|
22
|
+
%define mod_name provider-testing
|
23
|
+
%define mod_full_name %{mod_name}-%{version}
|
24
|
+
BuildRequires: ruby-macros >= 1
|
25
|
+
Url: http://en.opensuse.org/Software_Management/CIM
|
26
|
+
License: LGPL-2.1
|
27
|
+
Group: Development/Tools/Other
|
28
|
+
AutoReqProv: on
|
29
|
+
Release: 2
|
30
|
+
Summary: CIM provider test framework
|
31
|
+
Source: %{mod_full_name}.gem
|
32
|
+
Requires: sblim-sfcb
|
33
|
+
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
34
|
+
|
35
|
+
%description
|
36
|
+
A Ruby framework for automated CIM provider testing
|
37
|
+
|
38
|
+
%package doc
|
39
|
+
Summary: RDoc documentation for %{mod_name}
|
40
|
+
Group: Development/Languages/Ruby
|
41
|
+
Requires: %{name} = %{version}
|
42
|
+
|
43
|
+
%description doc
|
44
|
+
Documentation generated at gem installation time.
|
45
|
+
Usually in RDoc and RI formats.
|
46
|
+
|
47
|
+
%prep
|
48
|
+
#gem_unpack
|
49
|
+
#if you need patches, apply them here and replace the # with a % sign in the surrounding lines
|
50
|
+
#gem_build
|
51
|
+
|
52
|
+
%build
|
53
|
+
|
54
|
+
%install
|
55
|
+
%gem_install -f
|
56
|
+
|
57
|
+
%clean
|
58
|
+
rm -rf $RPM_BUILD_ROOT
|
59
|
+
|
60
|
+
%files
|
61
|
+
%defattr(-,root,root)
|
62
|
+
%{_libdir}/ruby/gems/%{rb_ver}/cache/%{mod_full_name}.gem
|
63
|
+
%{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name}/
|
64
|
+
%{_libdir}/ruby/gems/%{rb_ver}/specifications/%{mod_full_name}.gemspec
|
65
|
+
|
66
|
+
%files doc
|
67
|
+
%defattr(-,root,root,-)
|
68
|
+
%doc %{_libdir}/ruby/gems/%{rb_ver}/doc/%{mod_full_name}/
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "provider-testing"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "provider-testing"
|
7
|
+
s.version = ProviderTesting::VERSION
|
8
|
+
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.authors = ["Klaus Kämpf"]
|
11
|
+
s.email = ["kkaempf@suse.de"]
|
12
|
+
s.homepage = "https://github.com/kkaempf/providers-testing"
|
13
|
+
s.summary = %q{A testing framework for CIM providers}
|
14
|
+
s.description = %q{This framework uses Ruby, Rake and a local
|
15
|
+
instance of the SFCB CIMOM to run tests against CIM providers}
|
16
|
+
|
17
|
+
s.rubyforge_project = "provider-testing"
|
18
|
+
|
19
|
+
# Ruby SFCC bindings
|
20
|
+
s.add_dependency("sfcc", ["~> 0.6"])
|
21
|
+
|
22
|
+
s.add_development_dependency('rake')
|
23
|
+
s.add_development_dependency('bundler')
|
24
|
+
|
25
|
+
s.files = `git ls-files`.split("\n")
|
26
|
+
s.files.reject! { |fn| fn == '.gitignore' }
|
27
|
+
s.extra_rdoc_files = Dir['README.md', 'LICENSE']
|
28
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
29
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
30
|
+
s.require_paths = ["lib"]
|
31
|
+
end
|
data/tasks/clean.rake
ADDED
data/tasks/doc.rake
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
begin
|
2
|
+
require 'yard'
|
3
|
+
YARD::Rake::YardocTask.new(:doc) do |t|
|
4
|
+
t.files = ['lib/**/*.rb']
|
5
|
+
t.options = ['--no-private']
|
6
|
+
end
|
7
|
+
rescue LoadError
|
8
|
+
STDERR.puts "Install yard if you want prettier docs"
|
9
|
+
require 'rdoc/task'
|
10
|
+
Rake::RDocTask.new(:doc) do |rdoc|
|
11
|
+
rdoc.rdoc_dir = "doc"
|
12
|
+
rdoc.title = "provider-testing #{ProviderTesting::VERSION}"
|
13
|
+
end
|
14
|
+
end
|
data/tasks/test.rake
ADDED
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: provider-testing
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Klaus Kämpf
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sfcc
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.6'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.6'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: ! 'This framework uses Ruby, Rake and a local
|
63
|
+
|
64
|
+
instance of the SFCB CIMOM to run tests against CIM providers'
|
65
|
+
email:
|
66
|
+
- kkaempf@suse.de
|
67
|
+
executables: []
|
68
|
+
extensions: []
|
69
|
+
extra_rdoc_files:
|
70
|
+
- README.md
|
71
|
+
- LICENSE
|
72
|
+
files:
|
73
|
+
- Gemfile
|
74
|
+
- LICENSE
|
75
|
+
- README.md
|
76
|
+
- Rakefile
|
77
|
+
- lib/provider-testing.rb
|
78
|
+
- lib/provider-testing/env.rb
|
79
|
+
- lib/provider-testing/helper.rb
|
80
|
+
- lib/provider-testing/mkreg.rb
|
81
|
+
- lib/provider-testing/pegasus.rb
|
82
|
+
- lib/provider-testing/registration.rb
|
83
|
+
- lib/provider-testing/sfcb.rb
|
84
|
+
- lib/tasks/clean.rake
|
85
|
+
- lib/tasks/configuration.rake
|
86
|
+
- lib/tasks/pegasus.rake
|
87
|
+
- lib/tasks/registration.rake
|
88
|
+
- lib/tasks/sfcb.rake
|
89
|
+
- lib/tasks/test.rake
|
90
|
+
- package/rubygem-provider-testing.changes
|
91
|
+
- package/rubygem-provider-testing.spec
|
92
|
+
- provider-testing.gemspec
|
93
|
+
- tasks/clean.rake
|
94
|
+
- tasks/doc.rake
|
95
|
+
- tasks/test.rake
|
96
|
+
homepage: https://github.com/kkaempf/providers-testing
|
97
|
+
licenses: []
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ! '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project: provider-testing
|
116
|
+
rubygems_version: 1.8.23
|
117
|
+
signing_key:
|
118
|
+
specification_version: 3
|
119
|
+
summary: A testing framework for CIM providers
|
120
|
+
test_files: []
|
121
|
+
has_rdoc:
|