4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

'No backend type is specified. Fall back to :exec type.'が大量に出てくる場合の対処法

Posted at

test-kitchenでchefrepoのテストを仮想マシン上で行っている時にちょっと気持ち悪い警告がいっぱいでました。

$ kitchen verify
-----> Starting Kitchen (v1.3.1)
-----> Verifying <default-ubuntu-1410>...
       Removing /tmp/busser/suites/serverspec
       Uploading /tmp/busser/suites/serverspec/base_spec.rb (mode=0644)
-----> Running serverspec test suite
       /opt/chef/embedded/bin/ruby -I/tmp/busser/suites/serverspec -I/tmp/busser/gems/gems/rspec-support-3.2.2/lib:/tmp/busser/gems/gems/rspec-core-3.2.2/lib /opt/chef/embedded/bin/rspec --pattern /tmp/busser/suites/serverspec/\*\*/\*_spec.rb --color --format documentation --default-path /tmp/busser/suites/serverspec

       Command "getenforce"
         stdout
       No backend type is specified. Fall back to :exec type.
       No backend type is specified. Fall back to :exec type.
       No backend type is specified. Fall back to :exec type.
       No backend type is specified. Fall back to :exec type.
       No backend type is specified. Fall back to :exec type.
       No backend type is specified. Fall back to :exec type.
       No backend type is specified. Fall back to :exec type.
       No backend type is specified. Fall back to :exec type.
       No backend type is specified. Fall back to :exec type.
       No backend type is specified. Fall back to :exec type.
       No backend type is specified. Fall back to :exec type.
       No backend type is specified. Fall back to :exec type.
       No backend type is specified. Fall back to :exec type.
       No backend type is specified. Fall back to :exec type.
       No backend type is specified. Fall back to :exec type.
       No backend type is specified. Fall back to :exec type.
           should match "Disabled"

       Finished in 0.11633 seconds (files took 0.30969 seconds to load)
       1 example, 0 failures

       Finished verifying <default-ubuntu-1410> (0m1.87s).

No backend type is specified. Fall back to :exec type.がたくさん出てくる。この場合のbackend typeというのはserverspec-initコマンドで初期設定を行うときに聞かれるあのbackend type。「SSHとEXECのどっちにする?」と聞かれたと思います。

$ serverspec-init
Select OS type:

  1) UN*X
  2) Windows

Select number: 1

Select a backend type:

  1) SSH
  2) Exec (local)

Select number:

これはテストするサーバーで指定してやらないといけないようなのだけれど、kitchen loginして手動でserverspec-initするのは、test-kitchenの仮想マシンについて意識しなくていいスタイルに反する・・・。

これはテストコードの頭にset :backend, :execという書き方で指定してやれば解決できるようです。SSHを指定したい場合はset :backend, :sshですが、test-kitchenの場合はおそらく仮想マシンにログインしてからrake spec?しているようなのでうまくいかない。execが正解。

serverspecのテストコード
require 'serverspec'
set :backend, :exec

describe command("getenforce") do
    its(:stdout) { should match 'Disabled' }
end

これで出力から無駄なものがなくなりました。めでたしめでたし。

$ kitchen verify
-----> Starting Kitchen (v1.3.1)
-----> Verifying <default-ubuntu-1410>...
       Removing /tmp/busser/suites/serverspec
       Uploading /tmp/busser/suites/serverspec/base_spec.rb (mode=0644)
-----> Running serverspec test suite
       /opt/chef/embedded/bin/ruby -I/tmp/busser/suites/serverspec -I/tmp/busser/gems/gems/rspec-support-3.2.2/lib:/tmp/busser/gems/gems/rspec-core-3.2.2/lib /opt/chef/embedded/bin/rspec --pattern /tmp/busser/suites/serverspec/\*\*/\*_spec.rb --color --format documentation --default-path /tmp/busser/suites/serverspec

       Command "getenforce"
         stdout
           should match "Disabled"

       Finished in 0.07994 seconds (files took 0.28063 seconds to load)
       1 example, 0 failures

       Finished verifying <default-ubuntu-1410> (0m1.58s).
-----> Verifying <default-centos-66>...
       Removing /tmp/busser/suites/serverspec
       Uploading /tmp/busser/suites/serverspec/base_spec.rb (mode=0644)
-----> Running serverspec test suite
       /opt/chef/embedded/bin/ruby -I/tmp/busser/suites/serverspec -I/tmp/busser/gems/gems/rspec-support-3.2.2/lib:/tmp/busser/gems/gems/rspec-core-3.2.2/lib /opt/chef/embedded/bin/rspec --pattern /tmp/busser/suites/serverspec/\*\*/\*_spec.rb --color --format documentation --default-path /tmp/busser/suites/serverspec

       Command "getenforce"
         stdout
           should match "Disabled"

       Finished in 0.02523 seconds (files took 0.26327 seconds to load)
       1 example, 0 failures

       Finished verifying <default-centos-66> (0m1.52s).
-----> Kitchen is finished. (0m4.35s)
4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?