specinfra 2.38.0 → 2.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/specinfra/command/freebsd/base/interface.rb +15 -0
- data/lib/specinfra/command.rb +1 -0
- data/lib/specinfra/version.rb +1 -1
- data/spec/backend/exec/child_process_spec.rb +18 -0
- data/spec/backend/exec/read_noblock_spec.rb +50 -0
- data/spec/backend/exec/stdxxx_handler_spec.rb +25 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 972b0b4d232e4437b861f29d76317693630733bf
|
4
|
+
data.tar.gz: 266ceb8f83189aa3730c96c3a3c986bad4ca21cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c346d60997449ddb9148b252f1e766108d335e39a7a2869a8d533ae504a0e8ecb899ab4d1f86c44f8eb457b84019510e5434218a74125138c56f96e545940731
|
7
|
+
data.tar.gz: 891c0baffa2a8b9ee7af9e22023092e94bf833e4b9328ceb3e4a6402df8574379bd5db94c526cb14e3db7d63e23082f47c493a5497242dd372ee8b7ef0c0bf2f
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Specinfra::Command::Freebsd::Base::Interface < Specinfra::Command::Base::Interface
|
2
|
+
class << self
|
3
|
+
def check_exists(name)
|
4
|
+
"ifconfig #{name}"
|
5
|
+
end
|
6
|
+
|
7
|
+
def check_has_ipv4_address(interface, ip_address)
|
8
|
+
"ifconfig #{interface} | grep -w inet | cut -d ' ' -f 2"
|
9
|
+
end
|
10
|
+
|
11
|
+
def check_has_ipv6_address(interface, ip_address)
|
12
|
+
"ifconfig #{interface} | grep -w inet6 | cut -d ' ' -f 2"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/specinfra/command.rb
CHANGED
@@ -210,6 +210,7 @@ require 'specinfra/command/opensuse/base/service'
|
|
210
210
|
require 'specinfra/command/freebsd'
|
211
211
|
require 'specinfra/command/freebsd/base'
|
212
212
|
require 'specinfra/command/freebsd/base/file'
|
213
|
+
require 'specinfra/command/freebsd/base/interface'
|
213
214
|
require 'specinfra/command/freebsd/base/inventory'
|
214
215
|
require 'specinfra/command/freebsd/base/package'
|
215
216
|
require 'specinfra/command/freebsd/base/port'
|
data/lib/specinfra/version.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Ref: https://github.com/sorah/infra_operator/blob/6259aada3fdd9d4bed5759115d39bd1df25a81f2/spec/backends/exec_spec.rb#L36
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
context "when executed process launches child process like a daemon, and the daemon doesn't close stdout,err" do
|
6
|
+
subject(:result) { Specinfra::Runner.run_command("ruby -e 'pid = fork { sleep 10; puts :bye }; Process.detach(pid); puts pid'") }
|
7
|
+
|
8
|
+
it "doesn't block" do
|
9
|
+
a = Time.now
|
10
|
+
result # exec
|
11
|
+
b = Time.now
|
12
|
+
expect((b-a) < 3).to be_truthy
|
13
|
+
|
14
|
+
expect(result.stderr).to be_empty
|
15
|
+
expect(result.stdout.chomp).to match(/\A\d+\z/)
|
16
|
+
Process.kill :TERM, result.stdout.chomp.to_i
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
def command(cmd)
|
4
|
+
Specinfra::Runner.run_command(cmd)
|
5
|
+
end
|
6
|
+
|
7
|
+
shared_examples "IO checks" do
|
8
|
+
let (:generator) { "seq 1 #{max}" }
|
9
|
+
let (:expected) { (1..max).map { |x| x.to_s }.join("\n") << "\n" }
|
10
|
+
|
11
|
+
it "stdout only" do
|
12
|
+
out = command(generator).stdout
|
13
|
+
expect(out).to eq expected
|
14
|
+
end
|
15
|
+
|
16
|
+
it "stderr only" do
|
17
|
+
out = command("#{generator} >&2" ).stderr
|
18
|
+
expect(out).to eq expected
|
19
|
+
end
|
20
|
+
|
21
|
+
it "stdout then stderr" do
|
22
|
+
cmd = command("#{generator}; #{generator} >&2" )
|
23
|
+
expect(cmd.stdout).to eq expected
|
24
|
+
expect(cmd.stderr).to eq expected
|
25
|
+
end
|
26
|
+
|
27
|
+
it "stderr then stdout" do
|
28
|
+
cmd = command("#{generator} >&2; #{generator}" )
|
29
|
+
expect(cmd.stdout).to eq expected
|
30
|
+
expect(cmd.stderr).to eq expected
|
31
|
+
end
|
32
|
+
|
33
|
+
it "stdout and stderr" do
|
34
|
+
cmd = command("(#{generator} &); #{generator} >&2; sleep 2" )
|
35
|
+
expect(cmd.stdout).to eq expected
|
36
|
+
expect(cmd.stderr).to eq expected
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "buffer overflow problem" do
|
41
|
+
context "with small output amount" do
|
42
|
+
let (:max) { 10 }
|
43
|
+
include_examples "IO checks"
|
44
|
+
end
|
45
|
+
|
46
|
+
context "with huge output amount" do
|
47
|
+
let (:max) { 999999 }
|
48
|
+
include_examples "IO checks"
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
backend = Specinfra::Backend::Exec.new
|
4
|
+
|
5
|
+
context 'Output of stdout_handler' do
|
6
|
+
subject(:stdout) do
|
7
|
+
out = ''
|
8
|
+
backend.stdout_handler = Proc.new {|o| out += o }
|
9
|
+
backend.run_command('echo foo')
|
10
|
+
out
|
11
|
+
end
|
12
|
+
|
13
|
+
it { expect(stdout).to eq "foo\n" }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'Output of stderr_handler' do
|
17
|
+
subject(:stderr) do
|
18
|
+
err = ''
|
19
|
+
backend.stderr_handler = Proc.new {|e| err += e }
|
20
|
+
backend.run_command('echo foo 1>&2')
|
21
|
+
err
|
22
|
+
end
|
23
|
+
|
24
|
+
it { expect(stderr).to eq "foo\n" }
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specinfra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.38.
|
4
|
+
version: 2.38.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gosuke Miyashita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-scp
|
@@ -252,6 +252,7 @@ files:
|
|
252
252
|
- lib/specinfra/command/freebsd.rb
|
253
253
|
- lib/specinfra/command/freebsd/base.rb
|
254
254
|
- lib/specinfra/command/freebsd/base/file.rb
|
255
|
+
- lib/specinfra/command/freebsd/base/interface.rb
|
255
256
|
- lib/specinfra/command/freebsd/base/inventory.rb
|
256
257
|
- lib/specinfra/command/freebsd/base/package.rb
|
257
258
|
- lib/specinfra/command/freebsd/base/port.rb
|
@@ -439,7 +440,10 @@ files:
|
|
439
440
|
- lib/specinfra/runner.rb
|
440
441
|
- lib/specinfra/version.rb
|
441
442
|
- spec/backend/exec/build_command_spec.rb
|
443
|
+
- spec/backend/exec/child_process_spec.rb
|
442
444
|
- spec/backend/exec/env_spec.rb
|
445
|
+
- spec/backend/exec/read_noblock_spec.rb
|
446
|
+
- spec/backend/exec/stdxxx_handler_spec.rb
|
443
447
|
- spec/backend/ssh/build_command_spec.rb
|
444
448
|
- spec/command/amazon/interface_spec.rb
|
445
449
|
- spec/command/amazon/package_spec.rb
|
@@ -525,7 +529,10 @@ specification_version: 4
|
|
525
529
|
summary: Common layer for serverspec and itamae
|
526
530
|
test_files:
|
527
531
|
- spec/backend/exec/build_command_spec.rb
|
532
|
+
- spec/backend/exec/child_process_spec.rb
|
528
533
|
- spec/backend/exec/env_spec.rb
|
534
|
+
- spec/backend/exec/read_noblock_spec.rb
|
535
|
+
- spec/backend/exec/stdxxx_handler_spec.rb
|
529
536
|
- spec/backend/ssh/build_command_spec.rb
|
530
537
|
- spec/command/amazon/interface_spec.rb
|
531
538
|
- spec/command/amazon/package_spec.rb
|
@@ -584,3 +591,4 @@ test_files:
|
|
584
591
|
- spec/host_inventory/openbsd/filesystem_spec.rb
|
585
592
|
- spec/host_inventory/solaris/filesystem_spec.rb
|
586
593
|
- spec/spec_helper.rb
|
594
|
+
has_rdoc:
|