kanrisuru 0.9.2 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CONTRIBUTING.md +9 -9
- data/.github/ISSUE_TEMPLATE/bug_report.md +7 -8
- data/.rspec +1 -1
- data/CHANGELOG.md +125 -96
- data/CODE_OF_CONDUCT.md +10 -10
- data/README.md +19 -90
- data/kanrisuru.gemspec +2 -1
- data/lib/kanrisuru/command.rb +7 -0
- data/lib/kanrisuru/core/archive.rb +13 -36
- data/lib/kanrisuru/core/disk.rb +0 -3
- data/lib/kanrisuru/core/dmi.rb +1 -1
- data/lib/kanrisuru/core/file.rb +4 -11
- data/lib/kanrisuru/core/find.rb +6 -11
- data/lib/kanrisuru/core/mount.rb +14 -15
- data/lib/kanrisuru/core/socket.rb +2 -1
- data/lib/kanrisuru/core/stream.rb +1 -2
- data/lib/kanrisuru/core/zypper.rb +6 -23
- data/lib/kanrisuru/os_package/collection.rb +58 -0
- data/lib/kanrisuru/os_package/define.rb +34 -0
- data/lib/kanrisuru/os_package/include.rb +163 -0
- data/lib/kanrisuru/os_package.rb +3 -245
- data/lib/kanrisuru/remote/cpu.rb +5 -1
- data/lib/kanrisuru/remote/env.rb +8 -0
- data/lib/kanrisuru/remote/fstab.rb +5 -5
- data/lib/kanrisuru/result.rb +5 -4
- data/lib/kanrisuru/util.rb +1 -1
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/apt_spec.rb +22 -30
- data/spec/functional/core/archive_spec.rb +170 -0
- data/spec/functional/core/find_spec.rb +94 -113
- data/spec/functional/core/mount_spec.rb +121 -0
- data/spec/functional/core/socket_spec.rb +23 -28
- data/spec/functional/core/stream_spec.rb +12 -12
- data/spec/functional/core/transfer_spec.rb +108 -131
- data/spec/functional/core/yum_spec.rb +58 -83
- data/spec/functional/remote/cluster_spec.rb +11 -2
- data/spec/functional/remote/cpu_spec.rb +104 -0
- data/spec/functional/remote/env_spec.rb +48 -0
- data/spec/helper/stub_network.rb +49 -14
- data/spec/helper/test_hosts.rb +11 -1
- data/spec/integration/core/apt_spec.rb +2 -3
- data/spec/integration/core/archive_spec.rb +8 -13
- data/spec/integration/core/disk_spec.rb +2 -3
- data/spec/integration/core/dmi_spec.rb +2 -3
- data/spec/integration/core/file_spec.rb +4 -14
- data/spec/integration/core/find_spec.rb +3 -3
- data/spec/integration/core/group_spec.rb +2 -3
- data/spec/integration/core/ip_spec.rb +2 -3
- data/spec/integration/core/path_spec.rb +2 -3
- data/spec/integration/core/socket_spec.rb +2 -4
- data/spec/integration/core/stat_spec.rb +2 -3
- data/spec/integration/core/stream_spec.rb +6 -9
- data/spec/integration/core/system_spec.rb +2 -4
- data/spec/integration/core/transfer_spec.rb +4 -9
- data/spec/integration/core/user_spec.rb +2 -4
- data/spec/integration/core/yum_spec.rb +2 -3
- data/spec/integration/core/zypper_spec.rb +5 -6
- data/spec/{functional → integration}/os_package_spec.rb +0 -0
- data/spec/integration/remote/cpu_spec.rb +2 -3
- data/spec/integration/remote/env_spec.rb +2 -3
- data/spec/integration/remote/fstab_spec.rb +2 -3
- data/spec/integration/remote/host_spec.rb +2 -3
- data/spec/integration/remote/memory_spec.rb +2 -2
- data/spec/integration/remote/os_spec.rb +2 -3
- data/spec/integration/remote/remote_file_spec.rb +9 -15
- data/spec/spec_helper.rb +12 -3
- data/spec/unit/command_spec.rb +49 -0
- data/spec/unit/core/find_spec.rb +1 -1
- data/spec/unit/core/yum_spec.rb +1 -1
- data/spec/unit/mode_spec.rb +33 -2
- data/spec/unit/remote/cluster_spec.rb +3 -1
- data/spec/unit/remote/cpu_spec.rb +1 -2
- data/spec/unit/remote/env_spec.rb +17 -0
- data/spec/unit/util_spec.rb +13 -0
- metadata +28 -5
@@ -14,7 +14,7 @@ RSpec.describe Kanrisuru::Core::Stat do
|
|
14
14
|
let(:host) do
|
15
15
|
Kanrisuru::Remote::Host.new(
|
16
16
|
host: 'localhost',
|
17
|
-
username: 'ubuntu',
|
17
|
+
username: 'ubuntu',
|
18
18
|
keys: ['id_rsa']
|
19
19
|
)
|
20
20
|
end
|
@@ -23,165 +23,142 @@ RSpec.describe Kanrisuru::Core::Stat do
|
|
23
23
|
url = 'https://rubygems.org'
|
24
24
|
|
25
25
|
expect_command(host.wget(url),
|
26
|
-
|
27
|
-
)
|
26
|
+
"wget #{url}")
|
28
27
|
|
29
28
|
## Output options
|
30
|
-
expect_command(host.wget(url,
|
31
|
-
|
32
|
-
|
33
|
-
)
|
29
|
+
expect_command(host.wget(url,
|
30
|
+
quiet: true, verbose: false, log_file: '/var/log/wget.log'),
|
31
|
+
"wget --quiet --no-verbose --output-file /var/log/wget.log #{url}")
|
34
32
|
|
35
|
-
expect_command(host.wget(url,
|
36
|
-
|
37
|
-
|
38
|
-
)
|
33
|
+
expect_command(host.wget(url,
|
34
|
+
verbose: true, append_log_file: '/var/log/wget.log'),
|
35
|
+
"wget --verbose --append-output /var/log/wget.log #{url}")
|
39
36
|
|
40
37
|
## Download options
|
41
38
|
expect_command(host.wget(url,
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
"wget --bind-address 0.0.0.0 --tries 3 --output-document /home/ubuntu/index.html --no-clobber --timeout 30 --dns-timeout 60 --connect-timeout 60 --read-timeout 15 --limit-rate 120k --wait 5 --waitretry 15 --random-wait --no-proxy --no-dns-cache https://rubygems.org"
|
58
|
-
)
|
39
|
+
bind_address: '0.0.0.0',
|
40
|
+
retries: 3,
|
41
|
+
output_document: '/home/ubuntu/index.html',
|
42
|
+
no_clobber: true,
|
43
|
+
timeout: 30,
|
44
|
+
dns_timeout: 60,
|
45
|
+
connect_timeout: 60,
|
46
|
+
read_timeout: 15,
|
47
|
+
limit_rate: '120k',
|
48
|
+
wait: 5,
|
49
|
+
waitretry: 15,
|
50
|
+
random_wait: true,
|
51
|
+
no_proxy: true,
|
52
|
+
no_dns_cache: true),
|
53
|
+
'wget --bind-address 0.0.0.0 --tries 3 --output-document /home/ubuntu/index.html --no-clobber --timeout 30 --dns-timeout 60 --connect-timeout 60 --read-timeout 15 --limit-rate 120k --wait 5 --waitretry 15 --random-wait --no-proxy --no-dns-cache https://rubygems.org')
|
59
54
|
|
60
55
|
## Other Options
|
61
56
|
expect_command(host.wget(url,
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
"wget --quota inf --restrict-file-names unix,ascii,lowercase,uppercase --inet4-only --retry-connrefused --user admin --password admin --no-iri #{url}"
|
71
|
-
)
|
57
|
+
quota: 'inf',
|
58
|
+
family: 'inet',
|
59
|
+
restrict_file_names: %w[unix ascii lowercase uppercase],
|
60
|
+
retry_connrefused: true,
|
61
|
+
user: 'admin',
|
62
|
+
password: 'admin',
|
63
|
+
no_iri: true),
|
64
|
+
"wget --quota inf --restrict-file-names unix,ascii,lowercase,uppercase --inet4-only --retry-connrefused --user admin --password admin --no-iri #{url}")
|
72
65
|
|
73
66
|
## Directories
|
74
67
|
expect_command(host.wget(url,
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
"wget --no-directories --no-host-directories --cut-dirs 3 --directory-prefix ~/downloads/ #{url}"
|
81
|
-
)
|
68
|
+
no_directories: true,
|
69
|
+
no_host_directories: true,
|
70
|
+
cut_dirs: 3,
|
71
|
+
directory_prefix: '~/downloads/'),
|
72
|
+
"wget --no-directories --no-host-directories --cut-dirs 3 --directory-prefix ~/downloads/ #{url}")
|
82
73
|
|
83
74
|
## HTTP
|
84
75
|
expect_command(host.wget(url,
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
"wget --default-page index.html --adjust-extension --http-user admin --http-password admin --load-cookies ~/cookies.txt --save-cookies ~/cookies.txt --no-cache --keep-session-cookies --ignore-length --max-redirect 5 --proxy-user admin --proxy-password 12345678 --header 'Accept-Language: hr' --header 'Authorization: Bearer 1234' #{url}"
|
103
|
-
)
|
76
|
+
default_page: 'index.html',
|
77
|
+
adjust_extension: true,
|
78
|
+
http_user: 'admin',
|
79
|
+
http_password: 'admin',
|
80
|
+
load_cookies: '~/cookies.txt',
|
81
|
+
save_cookies: '~/cookies.txt',
|
82
|
+
no_cache: true,
|
83
|
+
keep_session_cookies: true,
|
84
|
+
ignore_length: true,
|
85
|
+
headers: {
|
86
|
+
'Accept-Language' => 'hr',
|
87
|
+
'Authorization' => 'Bearer 1234'
|
88
|
+
},
|
89
|
+
max_redirect: 5,
|
90
|
+
proxy_user: 'admin',
|
91
|
+
proxy_password: '12345678'),
|
92
|
+
"wget --default-page index.html --adjust-extension --http-user admin --http-password admin --load-cookies ~/cookies.txt --save-cookies ~/cookies.txt --no-cache --keep-session-cookies --ignore-length --max-redirect 5 --proxy-user admin --proxy-password 12345678 --header 'Accept-Language: hr' --header 'Authorization: Bearer 1234' #{url}")
|
104
93
|
|
105
94
|
expect_command(host.wget(url,
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
expect {
|
95
|
+
post_data: {
|
96
|
+
url: 'https://example.com?param=123'
|
97
|
+
},
|
98
|
+
content_disposition: true,
|
99
|
+
secure_protocol: 'SSLv3',
|
100
|
+
no_check_certificate: true),
|
101
|
+
"wget --post-data url=https%3A%2F%2Fexample.com%3Fparam%3D123 --content-disposition --secure-protocol SSLv3 --no-check-certificate #{url}")
|
102
|
+
|
103
|
+
expect do
|
117
104
|
host.wget(url, secure_protocol: 'SSL')
|
118
|
-
|
105
|
+
end.to raise_error(ArgumentError)
|
119
106
|
|
120
107
|
expect_command(host.wget(url,
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
"wget --certificate ~/cert.pem --certificate-type PEM --private-key ~/key.pem --private-key-type PEM --ca-certificate ~/ca.pem --random-file ~/random #{url}"
|
129
|
-
)
|
108
|
+
certificate: '~/cert.pem',
|
109
|
+
certificate_type: 'PEM',
|
110
|
+
private_key: '~/key.pem',
|
111
|
+
private_key_type: 'PEM',
|
112
|
+
ca_certificate: '~/ca.pem',
|
113
|
+
random_file: '~/random'),
|
114
|
+
"wget --certificate ~/cert.pem --certificate-type PEM --private-key ~/key.pem --private-key-type PEM --ca-certificate ~/ca.pem --random-file ~/random #{url}")
|
130
115
|
|
131
116
|
expect_command(host.wget(url,
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
"wget --certificate ~/cert.pem --certificate-type PEM --private-key ~/key.pem --private-key-type PEM --ca-certificate ~/ca.pem --random-file ~/random #{url}"
|
140
|
-
)
|
117
|
+
certificate: '~/cert.pem',
|
118
|
+
certificate_type: 'PEM',
|
119
|
+
private_key: '~/key.pem',
|
120
|
+
private_key_type: 'PEM',
|
121
|
+
ca_certificate: '~/ca.pem',
|
122
|
+
random_file: '~/random'),
|
123
|
+
"wget --certificate ~/cert.pem --certificate-type PEM --private-key ~/key.pem --private-key-type PEM --ca-certificate ~/ca.pem --random-file ~/random #{url}")
|
141
124
|
|
142
125
|
## FTP
|
143
|
-
expect_command(host.wget(url,
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
"wget --ftp-user admin --ftp-password 12345678 --no-remove-listing --no-glob --no-passive-ftp --retr-symlinks #{url}"
|
152
|
-
)
|
126
|
+
expect_command(host.wget(url,
|
127
|
+
ftp_user: 'admin',
|
128
|
+
ftp_password: '12345678',
|
129
|
+
no_remove_listing: true,
|
130
|
+
no_glob: true,
|
131
|
+
no_passive_ftp: true,
|
132
|
+
retr_symlinks: true),
|
133
|
+
"wget --ftp-user admin --ftp-password 12345678 --no-remove-listing --no-glob --no-passive-ftp --retr-symlinks #{url}")
|
153
134
|
|
154
135
|
## Recursive Retrieval
|
155
136
|
expect_command(host.wget(url,
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
"wget --recursive --level 10 --delete-after --convert-links --backup-converted --mirror --page-requisites --strict-comments #{url}"
|
166
|
-
)
|
137
|
+
recursive: true,
|
138
|
+
depth: 10,
|
139
|
+
delete_after: true,
|
140
|
+
convert_links: true,
|
141
|
+
backup_converted: true,
|
142
|
+
mirror: true,
|
143
|
+
page_requisites: true,
|
144
|
+
strict_comments: true),
|
145
|
+
"wget --recursive --level 10 --delete-after --convert-links --backup-converted --mirror --page-requisites --strict-comments #{url}")
|
167
146
|
|
168
147
|
## Recursive Accept/Reject
|
169
148
|
expect_command(host.wget(url,
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
"wget --accept .txt,.html --reject .csv --domains example.com --exclude-domains hackernews.com --follow-tags a,div,span --ignore-tags area,link --include-directories /gems --exclude-directories /releases --follow-ftp --ignore-case --span-hosts --relative --no-parent #{url}"
|
185
|
-
)
|
149
|
+
accept_list: ['.txt', '.html'],
|
150
|
+
reject_list: ['.csv'],
|
151
|
+
domain_list: ['example.com'],
|
152
|
+
exclude_domain_list: ['hackernews.com'],
|
153
|
+
follow_tags: %w[a div span],
|
154
|
+
ignore_tags: %w[area link],
|
155
|
+
include_directories: ['/gems'],
|
156
|
+
exclude_directories: ['/releases'],
|
157
|
+
follow_ftp: true,
|
158
|
+
ignore_case: true,
|
159
|
+
span_hosts: true,
|
160
|
+
relative: true,
|
161
|
+
no_parent: true),
|
162
|
+
"wget --accept .txt,.html --reject .csv --domains example.com --exclude-domains hackernews.com --follow-tags a,div,span --ignore-tags area,link --include-directories /gems --exclude-directories /releases --follow-ftp --ignore-case --span-hosts --relative --no-parent #{url}")
|
186
163
|
end
|
187
164
|
end
|
@@ -20,117 +20,94 @@ RSpec.describe Kanrisuru::Core::Yum do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'prepares yum install command' do
|
23
|
-
expect_command(host.yum('install', packages: 'nginx'),
|
24
|
-
|
25
|
-
)
|
23
|
+
expect_command(host.yum('install', packages: 'nginx'),
|
24
|
+
'yum install -y nginx')
|
26
25
|
|
27
|
-
expect_command(host.yum('install', packages: [
|
28
|
-
|
29
|
-
)
|
26
|
+
expect_command(host.yum('install', packages: %w[nginx apache2]),
|
27
|
+
'yum install -y nginx apache2')
|
30
28
|
end
|
31
29
|
|
32
30
|
it 'prepares yum localinstall command' do
|
33
|
-
expect_command(host.yum('localinstall', repos: 'foo.rpm'),
|
34
|
-
|
35
|
-
)
|
31
|
+
expect_command(host.yum('localinstall', repos: 'foo.rpm'),
|
32
|
+
'yum localinstall -y foo.rpm')
|
36
33
|
|
37
|
-
expect_command(host.yum('localinstall',
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
'yum localinstall --disablerepo=* -y foo.rpm bar.rpm baz.rpm'
|
42
|
-
)
|
34
|
+
expect_command(host.yum('localinstall',
|
35
|
+
repos: ['foo.rpm', 'bar.rpm', 'baz.rpm'],
|
36
|
+
disable_repo: '*'),
|
37
|
+
'yum localinstall --disablerepo=* -y foo.rpm bar.rpm baz.rpm')
|
43
38
|
end
|
44
39
|
|
45
40
|
it 'prepares yum list command' do
|
46
|
-
expect_command(host.yum('list'),
|
47
|
-
|
48
|
-
)
|
41
|
+
expect_command(host.yum('list'),
|
42
|
+
"yum list | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'")
|
49
43
|
|
50
44
|
expect_command(host.yum('list', all: true, query: 'ruby*'),
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
),
|
62
|
-
"yum list --disablerepo=* available updates installed extras obsoletes | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'"
|
63
|
-
)
|
45
|
+
"yum list all ruby* | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'")
|
46
|
+
|
47
|
+
expect_command(host.yum('list',
|
48
|
+
available: true,
|
49
|
+
updates: true,
|
50
|
+
installed: true,
|
51
|
+
extras: true,
|
52
|
+
obsoletes: true,
|
53
|
+
disable_repo: '*'),
|
54
|
+
"yum list --disablerepo=* available updates installed extras obsoletes | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'")
|
64
55
|
end
|
65
56
|
|
66
57
|
it 'prepares yum search command' do
|
67
|
-
expect_command(host.yum('search',
|
68
|
-
|
69
|
-
|
70
|
-
"yum search redis | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'"
|
71
|
-
)
|
58
|
+
expect_command(host.yum('search',
|
59
|
+
packages: 'redis'),
|
60
|
+
"yum search redis | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'")
|
72
61
|
|
73
62
|
expect_command(host.yum('search',
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
"yum search all package1 package2 package3 | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'"
|
78
|
-
)
|
63
|
+
packages: %w[package1 package2 package3],
|
64
|
+
all: true),
|
65
|
+
"yum search all package1 package2 package3 | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'")
|
79
66
|
end
|
80
67
|
|
81
68
|
it 'prepares yum info command' do
|
82
|
-
expect_command(host.yum('info',
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
installed: true
|
91
|
-
),
|
92
|
-
"yum info --quiet installed package1 package2 package3"
|
93
|
-
)
|
69
|
+
expect_command(host.yum('info',
|
70
|
+
packages: 'redis'),
|
71
|
+
'yum info --quiet redis')
|
72
|
+
|
73
|
+
expect_command(host.yum('info',
|
74
|
+
packages: %w[package1 package2 package3],
|
75
|
+
installed: true),
|
76
|
+
'yum info --quiet installed package1 package2 package3')
|
94
77
|
end
|
95
78
|
|
96
79
|
it 'prepares yum repolist command' do
|
97
80
|
expect_command(host.yum('repolist'),
|
98
|
-
|
99
|
-
)
|
81
|
+
'yum repolist --verbose')
|
100
82
|
|
101
83
|
expect_command(host.yum('repolist', repos: 'repo1'),
|
102
|
-
|
103
|
-
)
|
84
|
+
'yum repolist --verbose repo1')
|
104
85
|
|
105
|
-
expect_command(host.yum('repolist', repos: [
|
106
|
-
|
107
|
-
)
|
86
|
+
expect_command(host.yum('repolist', repos: %w[repo1 repo2 repo3]),
|
87
|
+
'yum repolist --verbose repo1 repo2 repo3')
|
108
88
|
end
|
109
89
|
|
110
90
|
it 'prepares yum clean command' do
|
111
91
|
expect_command(host.yum('clean'), 'yum clean')
|
112
92
|
expect_command(host.yum('clean', all: true), 'yum clean all')
|
113
|
-
expect_command(host.yum('clean',
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
)
|
123
|
-
end
|
93
|
+
expect_command(host.yum('clean',
|
94
|
+
dbcache: true,
|
95
|
+
expire_cache: true,
|
96
|
+
metadata: true,
|
97
|
+
packages: true,
|
98
|
+
headers: true,
|
99
|
+
rpmdb: true),
|
100
|
+
'yum clean dbcache expire-cache metadata packages headers rpmdb')
|
101
|
+
end
|
124
102
|
|
125
103
|
it 'prepares yum remove command' do
|
126
|
-
expect_command(host.yum('remove', packages: 'gcc'), 'yum remove -y gcc')
|
127
|
-
expect_command(host.yum('remove', packages: [
|
128
|
-
|
129
|
-
)
|
104
|
+
expect_command(host.yum('remove', packages: 'gcc'), 'yum remove -y gcc')
|
105
|
+
expect_command(host.yum('remove', packages: %w[p1 p2 p3]),
|
106
|
+
'yum remove -y p1 p2 p3')
|
130
107
|
|
131
|
-
expect
|
108
|
+
expect do
|
132
109
|
host.yum('remove', packages: 'yum')
|
133
|
-
|
110
|
+
end.to raise_error(ArgumentError)
|
134
111
|
end
|
135
112
|
|
136
113
|
it 'prepares yum autoremove command' do
|
@@ -139,13 +116,12 @@ RSpec.describe Kanrisuru::Core::Yum do
|
|
139
116
|
|
140
117
|
it 'prepares yum erase command' do
|
141
118
|
expect_command(host.yum('erase', packages: 'gcc'), 'yum erase -y gcc')
|
142
|
-
expect_command(host.yum('erase', packages: [
|
143
|
-
|
144
|
-
)
|
119
|
+
expect_command(host.yum('erase', packages: %w[p1 p2 p3]),
|
120
|
+
'yum erase -y p1 p2 p3')
|
145
121
|
|
146
|
-
expect
|
122
|
+
expect do
|
147
123
|
host.yum('erase', packages: 'yum')
|
148
|
-
|
124
|
+
end.to raise_error(ArgumentError)
|
149
125
|
end
|
150
126
|
|
151
127
|
it 'prepares yum update command' do
|
@@ -155,5 +131,4 @@ RSpec.describe Kanrisuru::Core::Yum do
|
|
155
131
|
it 'prepares yum upgrade command' do
|
156
132
|
expect_command(host.yum('upgrade'), 'yum upgrade -y')
|
157
133
|
end
|
158
|
-
|
159
134
|
end
|
@@ -28,7 +28,7 @@ RSpec.describe Kanrisuru::Remote::Cluster do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'adds host to a cluster' do
|
31
|
-
cluster =
|
31
|
+
cluster = described_class.new(host1)
|
32
32
|
expect(cluster.hosts.length).to eq(1)
|
33
33
|
expect(cluster.count).to eq(1)
|
34
34
|
expect(cluster[host1.host]).to eq(host1)
|
@@ -42,8 +42,17 @@ RSpec.describe Kanrisuru::Remote::Cluster do
|
|
42
42
|
expect(cluster.hosts).to include(host2)
|
43
43
|
end
|
44
44
|
|
45
|
+
it 'fails to add host to a cluster' do
|
46
|
+
cluster = described_class.new
|
47
|
+
expect { cluster << 1 }.to raise_error(ArgumentError)
|
48
|
+
expect { cluster << 'hello' }.to raise_error(ArgumentError)
|
49
|
+
expect { cluster << ['host'] }.to raise_error(ArgumentError)
|
50
|
+
|
51
|
+
expect(cluster.count).to eq(0)
|
52
|
+
end
|
53
|
+
|
45
54
|
it 'removes a host from a cluster' do
|
46
|
-
cluster =
|
55
|
+
cluster = described_class.new(host1, host2)
|
47
56
|
expect(cluster.count).to eq(2)
|
48
57
|
|
49
58
|
cluster.delete(host2)
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Kanrisuru::Remote::Cpu do
|
6
|
+
before(:all) do
|
7
|
+
StubNetwork.stub!
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:all) do
|
11
|
+
StubNetwork.unstub!
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'with metal' do
|
15
|
+
let(:host) do
|
16
|
+
Kanrisuru::Remote::Host.new(
|
17
|
+
host: 'metal-host',
|
18
|
+
username: 'ubuntu',
|
19
|
+
keys: ['id_rsa']
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
before do
|
24
|
+
StubNetwork.stub_command!(:lscpu) do |_args|
|
25
|
+
struct = Kanrisuru::Core::System::CPUArchitecture.new
|
26
|
+
struct.architecture = 'x86_64'
|
27
|
+
struct.cores = 48
|
28
|
+
struct.byte_order = 'Little Endian'
|
29
|
+
struct.address_sizes = ['46 bits physical', '48 bits virtual']
|
30
|
+
struct.operation_modes = %w[32-bit 64-bit]
|
31
|
+
struct.online_cpus = 0
|
32
|
+
struct.threads_per_core = 2
|
33
|
+
struct.cores_per_socket = 12
|
34
|
+
struct.sockets = 2
|
35
|
+
struct.numa_mode = nil
|
36
|
+
struct.vendor_id = 'GenuineIntel'
|
37
|
+
struct.cpu_family = 6
|
38
|
+
struct.model = 63
|
39
|
+
struct.model_name = 'Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz'
|
40
|
+
struct.stepping = 2
|
41
|
+
struct.cpu_mhz = 1200.16
|
42
|
+
struct.cpu_max_mhz = 3300.0
|
43
|
+
struct.cpu_min_mhz = 1200.0
|
44
|
+
struct.bogo_mips = nil
|
45
|
+
struct.virtualization = 'VT-x'
|
46
|
+
struct.hypervisor_vendor = nil
|
47
|
+
struct.virtualization_type = nil
|
48
|
+
struct.l1d_cache = '768 KiB'
|
49
|
+
struct.l1i_cache = '768 KiB'
|
50
|
+
struct.l2_cache = '6 MiB'
|
51
|
+
struct.l3_cache = '60 MiB'
|
52
|
+
struct.numa_nodes = 2
|
53
|
+
struct.vulnerabilities = [
|
54
|
+
Kanrisuru::Core::System::CPUArchitectureVulnerability.new('Itlb multihit',
|
55
|
+
'KVM: Mitigation: Split huge pages'),
|
56
|
+
Kanrisuru::Core::System::CPUArchitectureVulnerability.new('L1tf',
|
57
|
+
'Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable'),
|
58
|
+
Kanrisuru::Core::System::CPUArchitectureVulnerability.new('Mds',
|
59
|
+
'Mitigation; Clear CPU buffers; SMT vulnerable'),
|
60
|
+
Kanrisuru::Core::System::CPUArchitectureVulnerability.new('Meltdown', 'Mitigation; PTI'),
|
61
|
+
Kanrisuru::Core::System::CPUArchitectureVulnerability.new('Spec store bypass',
|
62
|
+
'Mitigation; Speculative Store Bypass disabled via prctl and seccomp'),
|
63
|
+
Kanrisuru::Core::System::CPUArchitectureVulnerability.new('Spectre v1',
|
64
|
+
'Mitigation; usercopy/swapgs barriers and __user pointer sanitization'),
|
65
|
+
Kanrisuru::Core::System::CPUArchitectureVulnerability.new('Spectre v2',
|
66
|
+
'Mitigation; Full generic retpoline, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling'),
|
67
|
+
Kanrisuru::Core::System::CPUArchitectureVulnerability.new('Srbds', 'Not affected'),
|
68
|
+
Kanrisuru::Core::System::CPUArchitectureVulnerability.new('Tsx async abort', 'Not affected')
|
69
|
+
]
|
70
|
+
struct.flags = %w[fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
|
71
|
+
mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb invpcid_single pti intel_ppin ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm xsaveopt cqm_llc cqm_occup_llc dtherm ida arat pln pts md_clear flush_l1d]
|
72
|
+
struct
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
after do
|
77
|
+
StubNetwork.unstub_command!(:lscpu)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'gets host cpu attributes' do
|
81
|
+
expect(host.cpu.architecture).to eq('x86_64')
|
82
|
+
expect(host.cpu.cores).to eq(48)
|
83
|
+
expect(host.cpu.byte_order).to eq('Little Endian')
|
84
|
+
expect(host.cpu.address_sizes).to eq(['46 bits physical', '48 bits virtual'])
|
85
|
+
expect(host.cpu.threads_per_core).to eq(2)
|
86
|
+
expect(host.cpu.cores_per_socket).to eq(12)
|
87
|
+
expect(host.cpu.sockets).to eq(2)
|
88
|
+
expect(host.cpu.vendor_id).to eq('GenuineIntel')
|
89
|
+
expect(host.cpu.cpu_family).to eq(6)
|
90
|
+
expect(host.cpu.model).to eq(63)
|
91
|
+
expect(host.cpu.model_name).to eq('Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz')
|
92
|
+
expect(host.cpu.cpu_mhz).to eq(1200.16)
|
93
|
+
expect(host.cpu.cpu_max_mhz).to eq(3300.0)
|
94
|
+
expect(host.cpu.cpu_min_mhz).to eq(1200.0)
|
95
|
+
expect(host.cpu.hypervisor).to be_nil
|
96
|
+
expect(host.cpu.virtualization_type).to be_nil
|
97
|
+
# expect(host.cpu.l1d_cache).to eq("768 KiB")
|
98
|
+
# expect(host.cpu.l1i_cache).to eq("768 KiB")
|
99
|
+
# expect(host.cpu.l2_cache).to eq("6 MiB")
|
100
|
+
# expect(host.cpu.l3_cache).to eq("60 MiB")
|
101
|
+
expect(host.cpu.numa_nodes).to eq(2)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|