train 1.5.11 → 1.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/train/transports/winrm.rb +16 -4
- data/lib/train/version.rb +1 -1
- metadata +3 -165
- data/.rubocop.yml +0 -77
- data/CHANGELOG.md +0 -900
- data/Gemfile +0 -41
- data/README.md +0 -212
- data/Rakefile +0 -73
- data/test/fixtures/plugins/train-test-fixture/LICENSE +0 -201
- data/test/fixtures/plugins/train-test-fixture/README.md +0 -5
- data/test/fixtures/plugins/train-test-fixture/lib/train-test-fixture/connection.rb +0 -35
- data/test/fixtures/plugins/train-test-fixture/lib/train-test-fixture/platform.rb +0 -18
- data/test/fixtures/plugins/train-test-fixture/lib/train-test-fixture/transport.rb +0 -14
- data/test/fixtures/plugins/train-test-fixture/lib/train-test-fixture/version.rb +0 -5
- data/test/fixtures/plugins/train-test-fixture/lib/train-test-fixture.rb +0 -4
- data/test/fixtures/plugins/train-test-fixture/pkg/train-test-fixture-0.1.0.gem +0 -0
- data/test/fixtures/plugins/train-test-fixture/train-test-fixture.gemspec +0 -35
- data/test/integration/.kitchen.yml +0 -43
- data/test/integration/Berksfile +0 -3
- data/test/integration/bootstrap.sh +0 -22
- data/test/integration/chefignore +0 -1
- data/test/integration/cookbooks/test/metadata.rb +0 -1
- data/test/integration/cookbooks/test/recipes/default.rb +0 -100
- data/test/integration/cookbooks/test/recipes/prep_files.rb +0 -56
- data/test/integration/docker_run.rb +0 -153
- data/test/integration/docker_test.rb +0 -24
- data/test/integration/docker_test_container.rb +0 -24
- data/test/integration/helper.rb +0 -61
- data/test/integration/sudo/customcommand.rb +0 -15
- data/test/integration/sudo/nopasswd.rb +0 -16
- data/test/integration/sudo/passwd.rb +0 -21
- data/test/integration/sudo/reqtty.rb +0 -17
- data/test/integration/sudo/run_as.rb +0 -12
- data/test/integration/test-travis-centos.yml +0 -6
- data/test/integration/test-travis-debian.yml +0 -6
- data/test/integration/test-travis-fedora.yml +0 -8
- data/test/integration/test-travis-oel.yml +0 -6
- data/test/integration/test-travis-ubuntu.yml +0 -8
- data/test/integration/test_local.rb +0 -19
- data/test/integration/test_ssh.rb +0 -39
- data/test/integration/tests/path_block_device_test.rb +0 -74
- data/test/integration/tests/path_character_device_test.rb +0 -74
- data/test/integration/tests/path_file_test.rb +0 -99
- data/test/integration/tests/path_folder_test.rb +0 -90
- data/test/integration/tests/path_missing_test.rb +0 -76
- data/test/integration/tests/path_pipe_test.rb +0 -62
- data/test/integration/tests/path_symlink_test.rb +0 -95
- data/test/integration/tests/run_command_test.rb +0 -35
- data/test/unit/extras/command_wrapper_test.rb +0 -110
- data/test/unit/extras/stat_test.rb +0 -210
- data/test/unit/file/local/unix_test.rb +0 -224
- data/test/unit/file/local/windows_test.rb +0 -101
- data/test/unit/file/local_test.rb +0 -121
- data/test/unit/file/remote/aix_test.rb +0 -81
- data/test/unit/file/remote/linux_test.rb +0 -221
- data/test/unit/file/remote/qnx_test.rb +0 -80
- data/test/unit/file/remote/unix_test.rb +0 -119
- data/test/unit/file/remote/windows_test.rb +0 -72
- data/test/unit/file/remote_test.rb +0 -62
- data/test/unit/file_test.rb +0 -129
- data/test/unit/helper.rb +0 -7
- data/test/unit/platforms/detect/os_common_test.rb +0 -85
- data/test/unit/platforms/detect/os_linux_test.rb +0 -132
- data/test/unit/platforms/detect/os_windows_test.rb +0 -107
- data/test/unit/platforms/detect/scanner_test.rb +0 -61
- data/test/unit/platforms/detect/uuid_test.rb +0 -133
- data/test/unit/platforms/family_test.rb +0 -32
- data/test/unit/platforms/os_detect_test.rb +0 -249
- data/test/unit/platforms/platform_test.rb +0 -405
- data/test/unit/platforms/platforms_test.rb +0 -52
- data/test/unit/plugins/connection_test.rb +0 -219
- data/test/unit/plugins/transport_test.rb +0 -111
- data/test/unit/plugins_test.rb +0 -22
- data/test/unit/train_test.rb +0 -247
- data/test/unit/transports/aws_test.rb +0 -120
- data/test/unit/transports/azure_test.rb +0 -145
- data/test/unit/transports/cisco_ios_connection.rb +0 -92
- data/test/unit/transports/gcp_test.rb +0 -266
- data/test/unit/transports/helpers/azure/file_credentials_test.rb +0 -129
- data/test/unit/transports/local_test.rb +0 -183
- data/test/unit/transports/mock_test.rb +0 -150
- data/test/unit/transports/ssh_test.rb +0 -330
- data/test/unit/transports/vmware_test.rb +0 -159
- data/test/unit/version_test.rb +0 -8
- data/test/windows/local_test.rb +0 -243
- data/test/windows/winrm_test.rb +0 -187
- data/train.gemspec +0 -45
@@ -1,133 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
require 'train/transports/mock'
|
5
|
-
require 'securerandom'
|
6
|
-
|
7
|
-
class TestFile
|
8
|
-
def initialize(string)
|
9
|
-
@string = string
|
10
|
-
end
|
11
|
-
|
12
|
-
def exist?
|
13
|
-
true
|
14
|
-
end
|
15
|
-
|
16
|
-
def size
|
17
|
-
@string.length
|
18
|
-
end
|
19
|
-
|
20
|
-
def content
|
21
|
-
@string
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe 'uuid' do
|
26
|
-
def mock_platform(name, commands = {}, files = {}, plat_options = {})
|
27
|
-
Train::Platforms.list[name] = nil
|
28
|
-
mock = Train::Transports::Mock::Connection.new
|
29
|
-
commands.each do |command, data|
|
30
|
-
mock.mock_command(command, data)
|
31
|
-
end
|
32
|
-
|
33
|
-
file_objects = {}
|
34
|
-
files.each do |path, content|
|
35
|
-
file_objects[path] = TestFile.new(content)
|
36
|
-
end
|
37
|
-
|
38
|
-
mock.files = file_objects
|
39
|
-
mock.force_platform!(name, plat_options)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'finds a linux uuid from chef entity_uuid' do
|
43
|
-
files = { '/var/chef/cache/data_collector_metadata.json' => '{"node_uuid":"d400073f-0920-41aa-8dd3-2ea59b18f5ce"}' }
|
44
|
-
plat = mock_platform('linux', {}, files)
|
45
|
-
plat.uuid.must_equal 'd400073f-0920-41aa-8dd3-2ea59b18f5ce'
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'finds a windows uuid from chef entity_uuid' do
|
49
|
-
ENV['SYSTEMDRIVE'] = 'C:'
|
50
|
-
files = { 'C:\chef\cache\data_collector_metadata.json' => '{"node_uuid":"d400073f-0920-41aa-8dd3-2ea59b18f5ce"}' }
|
51
|
-
plat = mock_platform('windows', {}, files)
|
52
|
-
plat.uuid.must_equal 'd400073f-0920-41aa-8dd3-2ea59b18f5ce'
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'finds a linux uuid from /etc/chef/chef_guid' do
|
56
|
-
files = { '/etc/chef/chef_guid' => '5e430326-b5aa-56f8-975f-c3ca1c21df91' }
|
57
|
-
plat = mock_platform('linux', {}, files)
|
58
|
-
plat.uuid.must_equal '5e430326-b5aa-56f8-975f-c3ca1c21df91'
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'finds a linux uuid from /home/testuser/.chef/chef_guid' do
|
62
|
-
ENV['HOME'] = '/home/testuser'
|
63
|
-
files = { '/home/testuser/.chef/chef_guid' => '5e430326-b5aa-56f8-975f-c3ca1c21df91' }
|
64
|
-
plat = mock_platform('linux', {}, files)
|
65
|
-
plat.uuid.must_equal '5e430326-b5aa-56f8-975f-c3ca1c21df91'
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'finds a linux uuid from /etc/machine-id' do
|
69
|
-
files = { '/etc/machine-id' => '123141dsfadf' }
|
70
|
-
plat = mock_platform('linux', {}, files)
|
71
|
-
plat.uuid.must_equal '5e430326-b5aa-56f8-975f-c3ca1c21df91'
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'finds a linux uuid from /var/lib/dbus/machine-id' do
|
75
|
-
files = {
|
76
|
-
'/etc/machine-id' => '',
|
77
|
-
'/var/lib/dbus/machine-id' => '123141dsfadf',
|
78
|
-
}
|
79
|
-
plat = mock_platform('linux', {}, files)
|
80
|
-
plat.uuid.must_equal '5e430326-b5aa-56f8-975f-c3ca1c21df91'
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'finds a linux uuid from /etc/machine-id' do
|
84
|
-
files = { '/etc/machine-id' => '123141dsfadf' }
|
85
|
-
plat = mock_platform('linux', {}, files)
|
86
|
-
plat.uuid.must_equal '5e430326-b5aa-56f8-975f-c3ca1c21df91'
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'finds a windows uuid from wmic' do
|
90
|
-
commands = { 'wmic csproduct get UUID' => "UUID\r\nd400073f-0920-41aa-8dd3-2ea59b18f5ce\r\n" }
|
91
|
-
plat = mock_platform('windows', commands)
|
92
|
-
plat.uuid.must_equal 'd400073f-0920-41aa-8dd3-2ea59b18f5ce'
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'finds a windows uuid from registry' do
|
96
|
-
commands = { '(Get-ItemProperty "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography" -Name "MachineGuid")."MachineGuid"' => "d400073f-0920-41aa-8dd3-2ea59b18f5ce\r\n" }
|
97
|
-
plat = mock_platform('windows', commands)
|
98
|
-
plat.uuid.must_equal 'd400073f-0920-41aa-8dd3-2ea59b18f5ce'
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'finds a windows uuid from C:\chef\chef_guid' do
|
102
|
-
ENV['SYSTEMDRIVE'] = 'C:'
|
103
|
-
files = { 'C:\chef\chef_guid' => '5e430326-b5aa-56f8-975f-c3ca1c21df91' }
|
104
|
-
plat = mock_platform('windows', {}, files)
|
105
|
-
plat.uuid.must_equal '5e430326-b5aa-56f8-975f-c3ca1c21df91'
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'finds a windows uuid from C:\Users\test\.chef\chef_guid' do
|
109
|
-
ENV['HOMEDRIVE'] = 'C:\\'
|
110
|
-
ENV['HOMEPATH'] = 'Users\test'
|
111
|
-
files = { 'C:\Users\test\.chef\chef_guid' => '5e430326-b5aa-56f8-975f-c3ca1c21df91' }
|
112
|
-
plat = mock_platform('windows', {}, files)
|
113
|
-
plat.uuid.must_equal '5e430326-b5aa-56f8-975f-c3ca1c21df91'
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'generates a uuid from a string' do
|
117
|
-
plat = mock_platform('linux')
|
118
|
-
uuid = Train::Platforms::Detect::UUID.new(plat)
|
119
|
-
uuid.uuid_from_string('123141dsfadf').must_equal '5e430326-b5aa-56f8-975f-c3ca1c21df91'
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'finds a aws uuid' do
|
123
|
-
plat = mock_platform('aws')
|
124
|
-
plat.backend.stubs(:unique_identifier).returns('158551926027')
|
125
|
-
plat.uuid.must_equal '1d74ce61-ac15-5c48-9ee3-5aa8207ac37f'
|
126
|
-
end
|
127
|
-
|
128
|
-
it 'finds an azure uuid' do
|
129
|
-
plat = mock_platform('azure')
|
130
|
-
plat.backend.stubs(:unique_identifier).returns('1d74ce61-ac15-5c48-9ee3-5aa8207ac37f')
|
131
|
-
plat.uuid.must_equal '2c2e4fa9-7287-5dee-85a3-6527face7b7b'
|
132
|
-
end
|
133
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
describe 'platform family' do
|
6
|
-
def mock_family(x)
|
7
|
-
Train::Platforms.families[x] = nil if x == 'mock'
|
8
|
-
Train::Platforms.family(x)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'set family title' do
|
12
|
-
plat = mock_family('mock')
|
13
|
-
plat.title.must_equal('Mock Family')
|
14
|
-
plat.title('The Best Mock Family')
|
15
|
-
plat.title.must_equal('The Best Mock Family')
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'set family in a family' do
|
19
|
-
plat = mock_family('family1')
|
20
|
-
plat.in_family('family2')
|
21
|
-
plat.families.keys[0].name.must_equal('family2')
|
22
|
-
|
23
|
-
plat = mock_family('family2')
|
24
|
-
plat.children.keys[0].name.must_equal('family1')
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'set family in a family with condition' do
|
28
|
-
plat = Train::Platforms.family('family4', arch: '= x68_64').in_family('family5')
|
29
|
-
plat.families.keys[0].name.must_equal('family5')
|
30
|
-
plat.families.values[0].must_equal({ arch: '= x68_64' })
|
31
|
-
end
|
32
|
-
end
|
@@ -1,249 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'helper'
|
3
|
-
require 'train/transports/mock'
|
4
|
-
|
5
|
-
class OsDetectLinuxTester
|
6
|
-
include Train::Platforms::Detect::Helpers::OSCommon
|
7
|
-
end
|
8
|
-
|
9
|
-
describe 'os_detect' do
|
10
|
-
let(:detector) { OsDetectLinuxTester.new }
|
11
|
-
|
12
|
-
def scan_with_files(uname, files)
|
13
|
-
mock = Train::Transports::Mock::Connection.new
|
14
|
-
mock.mock_command('uname -s', uname)
|
15
|
-
mock.mock_command('uname -r', 'test-release')
|
16
|
-
files.each do |path, data|
|
17
|
-
mock.mock_command("test -f #{path}")
|
18
|
-
mock.mock_command("test -f #{path} && cat #{path}", data)
|
19
|
-
end
|
20
|
-
Train::Platforms::Detect.scan(mock)
|
21
|
-
end
|
22
|
-
|
23
|
-
## Detect all linux distros
|
24
|
-
describe '/etc/enterprise-release' do
|
25
|
-
it 'sets the correct family/release for oracle' do
|
26
|
-
path = '/etc/enterprise-release'
|
27
|
-
platform = scan_with_files('linux', { path => 'release 7' })
|
28
|
-
|
29
|
-
platform[:name].must_equal('oracle')
|
30
|
-
platform[:family].must_equal('redhat')
|
31
|
-
platform[:release].must_equal('7')
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '/etc/redhat-release' do
|
36
|
-
describe 'and /etc/os-release' do
|
37
|
-
it 'sets the correct family, name, and release on centos' do
|
38
|
-
files = {
|
39
|
-
'/etc/redhat-release' => "CentOS Linux release 7.2.1511 (Core) \n",
|
40
|
-
'/etc/os-release' => "NAME=\"CentOS Linux\"\nVERSION=\"7 (Core)\"\nID=\"centos\"\nID_LIKE=\"rhel fedora\"\n",
|
41
|
-
}
|
42
|
-
platform = scan_with_files('linux', files)
|
43
|
-
platform[:name].must_equal('centos')
|
44
|
-
platform[:family].must_equal('redhat')
|
45
|
-
platform[:release].must_equal('7.2.1511')
|
46
|
-
end
|
47
|
-
it 'sets the correct family, name, and release on scientific linux' do
|
48
|
-
files = {
|
49
|
-
'/etc/redhat-release' => "Scientific Linux release 7.4 (Nitrogen)\n",
|
50
|
-
'/etc/os-release' => "NAME=\"Scientific Linux\"\nVERSION=\"7.4 (Nitrogen)\"\nID=\"rhel\"\nID_LIKE=\"scientific centos fedora\"\nVERSION_ID=\"7.4\"\nPRETTY_NAME=\"Scientific Linux 7.4 (Nitrogen)\"\nANSI_COLOR=\"0;31\"\nCPE_NAME=\"cpe:/o:scientificlinux:scientificlinux:7.4:GA\"\nHOME_URL=\"http://www.scientificlinux.org//\"\nBUG_REPORT_URL=\"mailto:scientific-linux-devel@listserv.fnal.gov\"\n\nREDHAT_BUGZILLA_PRODUCT=\"Scientific Linux 7\"\nREDHAT_BUGZILLA_PRODUCT_VERSION=7.4\nREDHAT_SUPPORT_PRODUCT=\"Scientific Linux\"\nREDHAT_SUPPORT_PRODUCT_VERSION=\"7.4\"\n",
|
51
|
-
}
|
52
|
-
platform = scan_with_files('linux', files)
|
53
|
-
platform[:name].must_equal('scientific')
|
54
|
-
platform[:family].must_equal('redhat')
|
55
|
-
platform[:release].must_equal('7.4')
|
56
|
-
end
|
57
|
-
it 'sets the correct family, name, and release on CloudLinux' do
|
58
|
-
files = {
|
59
|
-
'/etc/redhat-release' => "CloudLinux release 7.4 (Georgy Grechko)\n",
|
60
|
-
'/etc/os-release' => "NAME=\"CloudLinux\"\nVERSION=\"7.4 (Georgy Grechko)\"\nID=\"cloudlinux\"\nID_LIKE=\"rhel fedora centos\"\nVERSION_ID=\"7.4\"\nPRETTY_NAME=\"CloudLinux 7.4 (Georgy Grechko)\"\nANSI_COLOR=\"0;31\"\nCPE_NAME=\"cpe:/o:cloudlinux:cloudlinux:7.4:GA:server\"\nHOME_URL=\"https://www.cloudlinux.com//\"\nBUG_REPORT_URL=\"https://www.cloudlinux.com/support\"\n",
|
61
|
-
}
|
62
|
-
platform = scan_with_files('linux', files)
|
63
|
-
platform[:name].must_equal('cloudlinux')
|
64
|
-
platform[:family].must_equal('redhat')
|
65
|
-
platform[:release].must_equal('7.4')
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe 'darwin' do
|
71
|
-
describe 'mac_os_x' do
|
72
|
-
it 'sets the correct family, name, and release on os_x' do
|
73
|
-
files = {
|
74
|
-
'/System/Library/CoreServices/SystemVersion.plist' => '<string>Mac OS X</string>',
|
75
|
-
}
|
76
|
-
platform = scan_with_files('darwin', files)
|
77
|
-
platform[:name].must_equal('mac_os_x')
|
78
|
-
platform[:family].must_equal('darwin')
|
79
|
-
platform[:release].must_equal('test-release')
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe 'generic darwin' do
|
84
|
-
it 'sets the correct family, name, and release on darwin' do
|
85
|
-
files = {
|
86
|
-
'/usr/bin/sw_vers' => "ProductVersion: 17.0.1\nBuildVersion: alpha.x1",
|
87
|
-
}
|
88
|
-
platform = scan_with_files('darwin', files)
|
89
|
-
platform[:name].must_equal('darwin')
|
90
|
-
platform[:family].must_equal('darwin')
|
91
|
-
platform[:release].must_equal('17.0.1')
|
92
|
-
platform[:build].must_equal('alpha.x1')
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe '/etc/debian_version' do
|
98
|
-
def debian_scan(id, version)
|
99
|
-
lsb_release = "DISTRIB_ID=#{id}\nDISTRIB_RELEASE=#{version}"
|
100
|
-
files = {
|
101
|
-
'/etc/lsb-release' => lsb_release,
|
102
|
-
'/etc/debian_version' => '11',
|
103
|
-
}
|
104
|
-
scan_with_files('linux', files)
|
105
|
-
end
|
106
|
-
|
107
|
-
describe 'ubuntu' do
|
108
|
-
it 'sets the correct family/release for ubuntu' do
|
109
|
-
platform = debian_scan('ubuntu', '16.04')
|
110
|
-
|
111
|
-
platform[:name].must_equal('ubuntu')
|
112
|
-
platform[:family].must_equal('debian')
|
113
|
-
platform[:release].must_equal('16.04')
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
describe 'linuxmint' do
|
118
|
-
it 'sets the correct family/release for linuxmint' do
|
119
|
-
platform = debian_scan('linuxmint', '12')
|
120
|
-
|
121
|
-
platform[:name].must_equal('linuxmint')
|
122
|
-
platform[:family].must_equal('debian')
|
123
|
-
platform[:release].must_equal('12')
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
describe 'raspbian' do
|
128
|
-
it 'sets the correct family/release for raspbian ' do
|
129
|
-
files = {
|
130
|
-
'/usr/bin/raspi-config' => 'data',
|
131
|
-
'/etc/debian_version' => '13.6',
|
132
|
-
}
|
133
|
-
platform = scan_with_files('linux', files)
|
134
|
-
|
135
|
-
platform[:name].must_equal('raspbian')
|
136
|
-
platform[:family].must_equal('debian')
|
137
|
-
platform[:release].must_equal('13.6')
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
describe 'everything else' do
|
142
|
-
it 'sets the correct family/release for debian ' do
|
143
|
-
platform = debian_scan('some_debian', '12.99')
|
144
|
-
|
145
|
-
platform[:name].must_equal('debian')
|
146
|
-
platform[:family].must_equal('debian')
|
147
|
-
platform[:release].must_equal('11')
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
describe '/etc/coreos/update.conf' do
|
153
|
-
it 'sets the correct family/release for coreos' do
|
154
|
-
lsb_release = "DISTRIB_ID=Container Linux by CoreOS\nDISTRIB_RELEASE=27.9"
|
155
|
-
files = {
|
156
|
-
'/etc/lsb-release' => lsb_release,
|
157
|
-
'/etc/coreos/update.conf' => 'data',
|
158
|
-
}
|
159
|
-
platform = scan_with_files('linux', files)
|
160
|
-
|
161
|
-
platform[:name].must_equal('coreos')
|
162
|
-
platform[:family].must_equal('linux')
|
163
|
-
platform[:release].must_equal('27.9')
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
describe '/etc/os-release' do
|
168
|
-
describe 'when not on a wrlinux build' do
|
169
|
-
it 'fail back to genaric linux' do
|
170
|
-
os_release = "ID_LIKE=cisco-unkwown\nVERSION=unknown"
|
171
|
-
files = {
|
172
|
-
'/etc/os-release' => os_release,
|
173
|
-
}
|
174
|
-
platform = scan_with_files('linux', files)
|
175
|
-
|
176
|
-
platform[:name].must_equal('linux')
|
177
|
-
platform[:family].must_equal('linux')
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
describe 'when on a wrlinux build' do
|
182
|
-
it 'sets the correct family/release for wrlinux' do
|
183
|
-
os_release = "ID_LIKE=cisco-wrlinux\nVERSION=cisco123"
|
184
|
-
files = {
|
185
|
-
'/etc/os-release' => os_release,
|
186
|
-
}
|
187
|
-
platform = scan_with_files('linux', files)
|
188
|
-
|
189
|
-
platform[:name].must_equal('wrlinux')
|
190
|
-
platform[:family].must_equal('redhat')
|
191
|
-
platform[:release].must_equal('cisco123')
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
describe 'qnx' do
|
197
|
-
it 'sets the correct info for qnx platform' do
|
198
|
-
platform = scan_with_files('qnx', {})
|
199
|
-
|
200
|
-
platform[:name].must_equal('qnx')
|
201
|
-
platform[:family].must_equal('qnx')
|
202
|
-
platform[:release].must_equal('test-release')
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
describe 'cisco' do
|
207
|
-
it 'recognizes Cisco IOS12' do
|
208
|
-
mock = Train::Transports::Mock::Connection.new
|
209
|
-
mock.mock_command('show version', "Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE")
|
210
|
-
platform = Train::Platforms::Detect.scan(mock)
|
211
|
-
|
212
|
-
platform[:name].must_equal('cisco_ios')
|
213
|
-
platform[:family].must_equal('cisco')
|
214
|
-
platform[:release].must_equal('12.2')
|
215
|
-
end
|
216
|
-
|
217
|
-
it 'recognizes Cisco IOS XE' do
|
218
|
-
mock = Train::Transports::Mock::Connection.new
|
219
|
-
mock.mock_command('show version', "Cisco IOS Software, IOS-XE Software, Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 03.03.03SE RELEASE SOFTWARE (fc2)")
|
220
|
-
platform = Train::Platforms::Detect.scan(mock)
|
221
|
-
|
222
|
-
platform[:name].must_equal('cisco_ios_xe')
|
223
|
-
platform[:family].must_equal('cisco')
|
224
|
-
platform[:release].must_equal('03.03.03SE')
|
225
|
-
end
|
226
|
-
|
227
|
-
it 'recognizes Cisco Nexus' do
|
228
|
-
mock = Train::Transports::Mock::Connection.new
|
229
|
-
mock.mock_command('show version', "Cisco Nexus Operating System (NX-OS) Software\n system: version 5.2(1)N1(8b)\n")
|
230
|
-
platform = Train::Platforms::Detect.scan(mock)
|
231
|
-
|
232
|
-
platform[:name].must_equal('cisco_nexus')
|
233
|
-
platform[:family].must_equal('cisco')
|
234
|
-
platform[:release].must_equal('5.2')
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
describe 'brocade' do
|
239
|
-
it 'recognizes Brocade FOS-based SAN switches' do
|
240
|
-
mock = Train::Transports::Mock::Connection.new
|
241
|
-
mock.mock_command('version', "Kernel: 2.6.14.2\nFabric OS: v7.4.2a\nMade on: Thu Jun 29 19:22:14 2017\nFlash: Sat Sep 9 17:30:42 2017\nBootProm: 1.0.11")
|
242
|
-
platform = Train::Platforms::Detect.scan(mock)
|
243
|
-
|
244
|
-
platform[:name].must_equal('brocade_fos')
|
245
|
-
platform[:family].must_equal('brocade')
|
246
|
-
platform[:release].must_equal('7.4.2a')
|
247
|
-
end
|
248
|
-
end
|
249
|
-
end
|