yggdrasil 0.0.5 → 0.0.6
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.
- data/README.md +1 -1
- data/lib/yggdrasil.rb +97 -113
- data/lib/yggdrasil/add.rb +1 -1
- data/lib/yggdrasil/check.rb +65 -0
- data/lib/yggdrasil/cleanup.rb +2 -2
- data/lib/yggdrasil/commit.rb +19 -5
- data/lib/yggdrasil/diff.rb +2 -3
- data/lib/yggdrasil/help.rb +87 -27
- data/lib/yggdrasil/init.rb +56 -20
- data/lib/yggdrasil/list.rb +2 -3
- data/lib/yggdrasil/log.rb +2 -2
- data/lib/yggdrasil/revert.rb +4 -4
- data/lib/yggdrasil/status.rb +2 -2
- data/lib/yggdrasil/update.rb +7 -5
- data/lib/yggdrasil/version.rb +3 -4
- data/lib/yggdrasil_common.rb +102 -0
- data/lib/yggdrasil_server.rb +77 -0
- data/lib/yggdrasil_server/get_repo.rb +6 -0
- data/lib/yggdrasil_server/get_ro_id_pw.rb +9 -0
- data/lib/yggdrasil_server/init_server.rb +62 -0
- data/lib/yggdrasil_server/put_result.rb +16 -0
- data/lib/yggdrasil_server/results.rb +30 -0
- data/spec/check_spec.rb +145 -0
- data/spec/commit_spec.rb +18 -2
- data/spec/help_spec.rb +83 -6
- data/spec/init_server_spec.rb +82 -0
- data/spec/init_spec.rb +46 -1
- data/spec/list_spec.rb +5 -1
- data/spec/results_spec.rb +66 -0
- data/spec/server_spec.rb +158 -0
- metadata +21 -5
data/spec/commit_spec.rb
CHANGED
@@ -52,6 +52,22 @@ describe Yggdrasil, "commit" do
|
|
52
52
|
res.should == "hoge\nhoge\n"
|
53
53
|
end
|
54
54
|
|
55
|
+
it 'should commit with multi line comment' do
|
56
|
+
puts "---- should commit with multi line comment"
|
57
|
+
puts "-- modify"
|
58
|
+
`echo foo >> /tmp/yggdrasil-test/B`
|
59
|
+
|
60
|
+
puts "-- commit"
|
61
|
+
Yggdrasil.command %w{commit / --username hoge --password foo},
|
62
|
+
"Y\ntest commit\\\nmodify B\n"
|
63
|
+
|
64
|
+
puts "\n-- check commit message"
|
65
|
+
res = `svn log -r HEAD --xml file:///tmp/yggdrasil-test/svn-repo/mng-repo/host-name`
|
66
|
+
puts res
|
67
|
+
res =~ /<msg>(.*)<\/msg>/m
|
68
|
+
$1.should == "test commit\nmodify B"
|
69
|
+
end
|
70
|
+
|
55
71
|
it 'should accept password interactive' do
|
56
72
|
puts "---- should accept password interactive"
|
57
73
|
`echo A >> /tmp/yggdrasil-test/A`
|
@@ -77,7 +93,7 @@ describe Yggdrasil, "commit" do
|
|
77
93
|
puts "\n-- check committed file 'tmp/yggdrasil-test/B'"
|
78
94
|
res = `svn cat file:///tmp/yggdrasil-test/svn-repo/mng-repo/host-name/tmp/yggdrasil-test/B`
|
79
95
|
puts res
|
80
|
-
res.should == "foo\nB\n"
|
96
|
+
res.should == "foo\nfoo\nB\n"
|
81
97
|
end
|
82
98
|
|
83
99
|
it 'should not commit deleted file' do
|
@@ -108,7 +124,7 @@ describe Yggdrasil, "commit" do
|
|
108
124
|
end
|
109
125
|
|
110
126
|
it 'should commit all files at once' do
|
111
|
-
puts "---- should
|
127
|
+
puts "---- should commit all files at once"
|
112
128
|
|
113
129
|
`echo HOGE >> /tmp/yggdrasil-test/A`
|
114
130
|
`rm -f /tmp/yggdrasil-test/B`
|
data/spec/help_spec.rb
CHANGED
@@ -10,19 +10,23 @@ Type '#{File.basename($0)} help <subcommand>' for help on a specific subcommand.
|
|
10
10
|
|
11
11
|
Available subcommands:
|
12
12
|
add
|
13
|
+
check (c)
|
13
14
|
cleanup
|
14
15
|
commit (ci)
|
15
16
|
diff (di)
|
16
17
|
help (?, h)
|
17
18
|
init
|
19
|
+
init-server
|
18
20
|
list (ls)
|
19
21
|
log
|
20
|
-
|
22
|
+
results
|
21
23
|
revert
|
24
|
+
server
|
25
|
+
status (stat, st)
|
22
26
|
update
|
23
27
|
version
|
24
28
|
|
25
|
-
Yggdrasil is a
|
29
|
+
Yggdrasil is a subversion wrapper to manage server configurations and conditions.
|
26
30
|
You should type 'yggdrasil init' at first.
|
27
31
|
|
28
32
|
EOS
|
@@ -56,7 +60,7 @@ EOS
|
|
56
60
|
err = catch_err do
|
57
61
|
lambda{Yggdrasil.command(%w{hoge})}.should raise_error(SystemExit)
|
58
62
|
end
|
59
|
-
err.should == "
|
63
|
+
err.should == "Unknown subcommand: 'hoge'\n"
|
60
64
|
end
|
61
65
|
|
62
66
|
help_help = <<"EOS"
|
@@ -97,9 +101,16 @@ init: Check environment and initialize configuration.
|
|
97
101
|
usage: #{File.basename($0)} init [OPTIONS...]
|
98
102
|
|
99
103
|
Valid options:
|
100
|
-
--repo ARG : specify svn repository
|
104
|
+
--repo ARG : specify svn repository URL
|
105
|
+
ARG could be any of the following:
|
106
|
+
file:///* : local repository
|
107
|
+
svn://* : svn access repository
|
108
|
+
http(s)://* : http access repository
|
109
|
+
private : make local repository in ~/.yggdrasil
|
101
110
|
--username ARG : specify a username ARG
|
102
111
|
--password ARG : specify a password ARG
|
112
|
+
--server ARG : specify a server address and port
|
113
|
+
e.g. 192.168.1.35:4000
|
103
114
|
|
104
115
|
EOS
|
105
116
|
end
|
@@ -230,7 +241,7 @@ EOS
|
|
230
241
|
out = catch_out{Yggdrasil.command %w{help update}}
|
231
242
|
out.should == <<"EOS"
|
232
243
|
update (up): Bring changes from the repository into the local files.
|
233
|
-
usage: #{File.basename($0)} update [PATH...]
|
244
|
+
usage: #{File.basename($0)} update [OPTIONS...] [PATH...]
|
234
245
|
|
235
246
|
Valid options:
|
236
247
|
--username ARG : specify a username ARG
|
@@ -253,13 +264,79 @@ EOS
|
|
253
264
|
out = catch_out{Yggdrasil.command %w{help revert}}
|
254
265
|
out.should == <<"EOS"
|
255
266
|
revert: Restore pristine working copy file (undo most local edits).
|
256
|
-
usage: #{File.basename($0)} revert [PATH...]
|
267
|
+
usage: #{File.basename($0)} revert [OPTIONS...] [PATH...]
|
268
|
+
|
269
|
+
Valid options:
|
270
|
+
--username ARG : specify a username ARG
|
271
|
+
--password ARG : specify a password ARG
|
272
|
+
--non-interactive : do no interactive prompting
|
273
|
+
|
274
|
+
EOS
|
275
|
+
end
|
276
|
+
|
277
|
+
it 'should show help of check' do
|
278
|
+
puts '---- should show help of check'
|
279
|
+
out = catch_out{Yggdrasil.command %w{help check}}
|
280
|
+
out.should == <<"EOS"
|
281
|
+
check (c): check updating of managed files and the execution output of a commands.
|
282
|
+
usage: #{File.basename($0)} check [OPTIONS...]
|
283
|
+
|
284
|
+
This subcommand execute the executable files in ~/.yggdrasil/checker/, and
|
285
|
+
the outputs are checked difference to repository with other managed files.
|
286
|
+
For example, mount status, number of specific process and etc. can be checked
|
287
|
+
by setting up executable files in ~/.yggdrasil/checker/
|
288
|
+
|
289
|
+
if the server is registered, the yggdrasil server receive and record the results.
|
257
290
|
|
258
291
|
Valid options:
|
259
292
|
--username ARG : specify a username ARG
|
260
293
|
--password ARG : specify a password ARG
|
261
294
|
--non-interactive : do no interactive prompting
|
262
295
|
|
296
|
+
EOS
|
297
|
+
end
|
298
|
+
|
299
|
+
it 'should show help of init-server' do
|
300
|
+
puts '---- should show help of init-server'
|
301
|
+
out = catch_out{Yggdrasil.command %w{help init-server}}
|
302
|
+
out.should == <<"EOS"
|
303
|
+
init-server: setup server configuration.
|
304
|
+
usage: #{File.basename($0)} init-server [OPTIONS...]
|
305
|
+
|
306
|
+
Valid options:
|
307
|
+
--port ARG : specify a TCP port number ARG
|
308
|
+
--repo ARG : URL of subversion repository
|
309
|
+
ARG could be include {HOST} and it replace by client hostname
|
310
|
+
e.g. svn://192.168.3.5/servers/{HOST}/ygg
|
311
|
+
--ro-username ARG : specify a username ARG for read only
|
312
|
+
--ro-password ARG : specify a password ARG for read only
|
313
|
+
|
314
|
+
EOS
|
315
|
+
end
|
316
|
+
|
317
|
+
it 'should show help of server' do
|
318
|
+
puts '---- should show help of server'
|
319
|
+
out = catch_out{Yggdrasil.command %w{help server}}
|
320
|
+
out.should == <<"EOS"
|
321
|
+
server: receive tcp connection in order to unify the setup and to record check results.
|
322
|
+
usage: #{File.basename($0)} server [OPTIONS...]
|
323
|
+
|
324
|
+
Valid options:
|
325
|
+
--daemon : daemon mode
|
326
|
+
|
327
|
+
EOS
|
328
|
+
end
|
329
|
+
|
330
|
+
it 'should show help of results' do
|
331
|
+
puts '---- should show help of results'
|
332
|
+
out = catch_out{Yggdrasil.command %w{help results}}
|
333
|
+
out.should == <<"EOS"
|
334
|
+
results: display the result of yggdrasil check command.
|
335
|
+
usage: #{File.basename($0)} results [OPTIONS...]
|
336
|
+
|
337
|
+
Valid options:
|
338
|
+
--limit ARG : minutes from the final report, to judge the host not be alive
|
339
|
+
|
263
340
|
EOS
|
264
341
|
end
|
265
342
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Yggdrasil, "init-server" do
|
4
|
+
it '-------- init-server' do
|
5
|
+
puts '-------- init-server'
|
6
|
+
prepare_environment
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should error: "Not enough arguments provided"' do
|
10
|
+
`rm -rf /tmp/yggdrasil-test/.yggdrasil`
|
11
|
+
puts '---- should error: "Not enough arguments provided"'
|
12
|
+
err = catch_err do
|
13
|
+
lambda{Yggdrasil.command(%w{init-server --repo})}.should raise_error(SystemExit)
|
14
|
+
end
|
15
|
+
err.should == "#{File.basename($0)} error: Not enough arguments provided: --repo\n\n"
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should make server_config (all interactive)' do
|
19
|
+
`rm -rf /tmp/yggdrasil-test/.yggdrasil`
|
20
|
+
puts '---- should make server_config (all interactive)"'
|
21
|
+
Yggdrasil.command %w{init-server},
|
22
|
+
"4000\n"+ # tcp port
|
23
|
+
"svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/\n"+ #svn repository
|
24
|
+
"hoge\n"+ # read only username
|
25
|
+
"foo\n" #read only password
|
26
|
+
|
27
|
+
File.exists?("/tmp/yggdrasil-test/.yggdrasil/server_config").should be_true
|
28
|
+
`cat /tmp/yggdrasil-test/.yggdrasil/server_config`.should == <<"EOS"
|
29
|
+
port=4000
|
30
|
+
repo=svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}
|
31
|
+
ro_username=hoge
|
32
|
+
ro_password=foo
|
33
|
+
EOS
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should make server_config (all argument)' do
|
37
|
+
`rm -rf /tmp/yggdrasil-test/.yggdrasil`
|
38
|
+
puts '---- should make server_config (all interactive)"'
|
39
|
+
Yggdrasil.command %w{init-server} +
|
40
|
+
%w{--port 4000} +
|
41
|
+
%w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/} +
|
42
|
+
%w{--ro-username hoge} +
|
43
|
+
%w{--ro-password foo}
|
44
|
+
|
45
|
+
File.exists?("/tmp/yggdrasil-test/.yggdrasil/server_config").should be_true
|
46
|
+
`cat /tmp/yggdrasil-test/.yggdrasil/server_config`.should == <<"EOS"
|
47
|
+
port=4000
|
48
|
+
repo=svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}
|
49
|
+
ro_username=hoge
|
50
|
+
ro_password=foo
|
51
|
+
EOS
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should make server_config (no ro-username)' do
|
55
|
+
`rm -rf /tmp/yggdrasil-test/.yggdrasil`
|
56
|
+
puts '---- should make server_config (all interactive)"'
|
57
|
+
Yggdrasil.command %w{init-server} +
|
58
|
+
%w{--port 4000} +
|
59
|
+
%w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/},
|
60
|
+
"\n" # prompt for input read only username
|
61
|
+
|
62
|
+
File.exists?("/tmp/yggdrasil-test/.yggdrasil/server_config").should be_true
|
63
|
+
`cat /tmp/yggdrasil-test/.yggdrasil/server_config`.should == <<"EOS"
|
64
|
+
port=4000
|
65
|
+
repo=svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}
|
66
|
+
EOS
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should error if argument have only password' do
|
70
|
+
`rm -rf /tmp/yggdrasil-test/.yggdrasil`
|
71
|
+
puts '---- should error if argument have only password'
|
72
|
+
|
73
|
+
err = catch_err do
|
74
|
+
args = %w{init-server} +
|
75
|
+
%w{--port 4000} +
|
76
|
+
%w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/} +
|
77
|
+
%w{--ro-password foo}
|
78
|
+
lambda{Yggdrasil.command(args)}.should raise_error(SystemExit)
|
79
|
+
end
|
80
|
+
err.should == "#{File.basename($0)} error: --ro-password option need --ro-username, too.\n\n"
|
81
|
+
end
|
82
|
+
end
|
data/spec/init_spec.rb
CHANGED
@@ -72,6 +72,17 @@ describe Yggdrasil, "init" do
|
|
72
72
|
"Y\n"
|
73
73
|
end
|
74
74
|
|
75
|
+
it 'should success: create config file (private)' do
|
76
|
+
puts '---- should success: create config file (private)'
|
77
|
+
`rm -rf /tmp/yggdrasil-test/.yggdrasil`
|
78
|
+
`rm -rf /tmp/yggdrasil-test/svn-repo`
|
79
|
+
|
80
|
+
Yggdrasil.command %w{init --debug} +
|
81
|
+
%w{--repo private}
|
82
|
+
|
83
|
+
File.exist?("/tmp/yggdrasil-test/.yggdrasil/config").should be_true
|
84
|
+
end
|
85
|
+
|
75
86
|
it 'should success: create config file (interactive)' do
|
76
87
|
puts '---- should success: create config file (interactive)'
|
77
88
|
`pkill svnserve`
|
@@ -102,11 +113,45 @@ EOS
|
|
102
113
|
end
|
103
114
|
out.should == \
|
104
115
|
"Input svn repo URL: "\
|
105
|
-
"SVN access
|
116
|
+
"check SVN access...\n"\
|
106
117
|
"Input svn username: "\
|
107
118
|
"Input svn password: \n"\
|
108
119
|
"SVN access OK: svn://localhost/tmp/yggdrasil-test/svn-repo\n"\
|
109
120
|
"not exist directory(s): mng-repo/host-name\n"\
|
110
121
|
"make directory(s)? [Yn]: "
|
111
122
|
end
|
123
|
+
|
124
|
+
it 'should make checker example at init' do
|
125
|
+
puts "\n---- should make checker example at init"
|
126
|
+
dir = "/tmp/yggdrasil-test/.yggdrasil/checker"
|
127
|
+
File.directory?(dir).should be_true
|
128
|
+
|
129
|
+
example_checker = dir + "/gem_list"
|
130
|
+
File.executable?(example_checker).should be_true
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'should success init subcommand with server option' do
|
134
|
+
puts '---- should success init subcommand with server option'
|
135
|
+
prepare_environment
|
136
|
+
|
137
|
+
Yggdrasil.command %w{init-server} +
|
138
|
+
%w{--port 4000} +
|
139
|
+
%w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/} +
|
140
|
+
%w{--ro-username hoge} +
|
141
|
+
%w{--ro-password foo}
|
142
|
+
fork do
|
143
|
+
Yggdrasil.command %w{server --debug}
|
144
|
+
end
|
145
|
+
|
146
|
+
sleep 1
|
147
|
+
Yggdrasil.command %w{init --debug --server localhost:4000},
|
148
|
+
"Y\nhoge\nfoo\n"
|
149
|
+
|
150
|
+
File.exist?("/tmp/yggdrasil-test/.yggdrasil/config").should be_true
|
151
|
+
|
152
|
+
sock = TCPSocket.open("localhost", 4000)
|
153
|
+
sock.puts("quit")
|
154
|
+
sock.close
|
155
|
+
Process.waitall
|
156
|
+
end
|
112
157
|
end
|
data/spec/list_spec.rb
CHANGED
@@ -38,8 +38,12 @@ describe Yggdrasil, "list" do
|
|
38
38
|
|
39
39
|
it 'should show list (with options)' do
|
40
40
|
puts '---- should show list (with options)'
|
41
|
-
out = catch_out{Yggdrasil.command(%w{list -R --revision 2
|
41
|
+
out = catch_out{Yggdrasil.command(%w{list -R --revision 2 /tmp} +
|
42
42
|
%w{--username hoge --password foo})}
|
43
43
|
out.should == "yggdrasil-test/\nyggdrasil-test/A\nyggdrasil-test/B\n"
|
44
|
+
|
45
|
+
out = catch_out{Yggdrasil.command(%w{list --revision 2 --recursive /tmp} +
|
46
|
+
%w{--username hoge --password foo})}
|
47
|
+
out.should == "yggdrasil-test/\nyggdrasil-test/A\nyggdrasil-test/B\n"
|
44
48
|
end
|
45
49
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Yggdrasil, "results" do
|
4
|
+
before(:all) do
|
5
|
+
puts '-------- results'
|
6
|
+
prepare_environment
|
7
|
+
|
8
|
+
sock = 0
|
9
|
+
begin
|
10
|
+
sock = TCPSocket.open("localhost", 4000)
|
11
|
+
rescue
|
12
|
+
puts "OK. no server"
|
13
|
+
else
|
14
|
+
puts "NG. zombie server. try quit"
|
15
|
+
sock.puts("quit")
|
16
|
+
sock.close
|
17
|
+
end
|
18
|
+
|
19
|
+
Yggdrasil.command %w{init-server} +
|
20
|
+
%w{--port 4000} +
|
21
|
+
%w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/}+
|
22
|
+
%w{--ro-username hoge --ro-password foo},
|
23
|
+
"\n\n"
|
24
|
+
fork do
|
25
|
+
Yggdrasil.command %w{server --debug}
|
26
|
+
end
|
27
|
+
sleep 1
|
28
|
+
Yggdrasil.command %w{init --debug --server localhost:4000} +
|
29
|
+
%w{--username hoge --password foo},
|
30
|
+
"Y\nhoge\nfoo\n"
|
31
|
+
`rm -f /tmp/yggdrasil-test/.yggdrasil/checker/gem_list`
|
32
|
+
Yggdrasil.command %w{check}
|
33
|
+
sleep 1
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should show results' do
|
37
|
+
puts '---- should show results'
|
38
|
+
|
39
|
+
`echo hoge > /tmp/yggdrasil-test/.yggdrasil/results/hoge-old`
|
40
|
+
File.utime Time.local(2001, 5, 22, 23, 59, 59),
|
41
|
+
Time.local(2001, 5, 1, 0, 0, 0),
|
42
|
+
"/tmp/yggdrasil-test/.yggdrasil/results/hoge-old"
|
43
|
+
|
44
|
+
out = catch_out do
|
45
|
+
Yggdrasil.command %w{results --limit 30}
|
46
|
+
end
|
47
|
+
|
48
|
+
out.should == <<"EOS"
|
49
|
+
######## hoge-old TOO OLD: 2001-05-01 00:00:00 +0900
|
50
|
+
######## centos6_127.0.0.1 Mismatch:
|
51
|
+
A 0 tmp/yggdrasil-test
|
52
|
+
A 0 tmp/yggdrasil-test/.yggdrasil
|
53
|
+
A 0 tmp/yggdrasil-test/.yggdrasil/checker_result
|
54
|
+
A 0 tmp
|
55
|
+
|
56
|
+
EOS
|
57
|
+
end
|
58
|
+
|
59
|
+
after(:all) do
|
60
|
+
sleep 1
|
61
|
+
sock = TCPSocket.open("localhost", 4000)
|
62
|
+
sock.puts("quit")
|
63
|
+
sock.close
|
64
|
+
Process.waitall
|
65
|
+
end
|
66
|
+
end
|
data/spec/server_spec.rb
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require 'timeout'
|
3
|
+
require 'socket'
|
4
|
+
|
5
|
+
describe Yggdrasil, "server" do
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
puts '-------- server'
|
9
|
+
prepare_environment
|
10
|
+
Yggdrasil.command %w{init-server} +
|
11
|
+
%w{--port 4000} +
|
12
|
+
%w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/} +
|
13
|
+
%w{--ro-username hoge} +
|
14
|
+
%w{--ro-password foo}
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should quit server on debug mode" do
|
18
|
+
puts "---- should quit server on debug mode"
|
19
|
+
|
20
|
+
fork do
|
21
|
+
# client behavior
|
22
|
+
sleep 1
|
23
|
+
sock = TCPSocket.open("localhost", 4000)
|
24
|
+
sock.puts("quit")
|
25
|
+
sock.close
|
26
|
+
exit
|
27
|
+
end
|
28
|
+
|
29
|
+
timeout 5 do
|
30
|
+
Yggdrasil.command %w{server --debug}
|
31
|
+
end
|
32
|
+
|
33
|
+
Process.waitall
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should response repository URL" do
|
37
|
+
puts "---- should response repository URL"
|
38
|
+
|
39
|
+
fork do
|
40
|
+
sleep 1
|
41
|
+
sock = TCPSocket.open("localhost", 4000)
|
42
|
+
sock.puts("get_repo")
|
43
|
+
rcv = sock.gets
|
44
|
+
rcv.should_not be_nil
|
45
|
+
rcv.chomp!
|
46
|
+
rcv.should == "svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}"
|
47
|
+
sock.close
|
48
|
+
|
49
|
+
sock = TCPSocket.open("localhost", 4000)
|
50
|
+
sock.puts("quit")
|
51
|
+
sock.close
|
52
|
+
exit
|
53
|
+
end
|
54
|
+
|
55
|
+
timeout 5 do
|
56
|
+
Yggdrasil.command %w{server --debug}
|
57
|
+
end
|
58
|
+
|
59
|
+
Process.waitall
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should response get_ro_id_pw" do
|
63
|
+
puts "---- should response get_ro_id_pw"
|
64
|
+
|
65
|
+
fork do
|
66
|
+
sleep 1
|
67
|
+
sock = TCPSocket.open("localhost", 4000)
|
68
|
+
sock.puts("get_ro_id_pw")
|
69
|
+
username = sock.gets
|
70
|
+
username.should_not be_nil
|
71
|
+
username.chomp.should == "hoge"
|
72
|
+
|
73
|
+
password = sock.gets
|
74
|
+
password.should_not be_nil
|
75
|
+
password.chomp.should == "foo"
|
76
|
+
sock.close
|
77
|
+
|
78
|
+
sock = TCPSocket.open("localhost", 4000)
|
79
|
+
sock.puts("quit")
|
80
|
+
sock.close
|
81
|
+
exit
|
82
|
+
end
|
83
|
+
|
84
|
+
timeout 5 do
|
85
|
+
Yggdrasil.command %w{server --debug}
|
86
|
+
end
|
87
|
+
|
88
|
+
Process.waitall
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should write file of check result to results directory" do
|
92
|
+
puts "---- should write file of check result to results directory"
|
93
|
+
|
94
|
+
fork do
|
95
|
+
sleep 1
|
96
|
+
sock = TCPSocket.open("localhost", 4000)
|
97
|
+
sock.puts("put_result HOSTNAME")
|
98
|
+
sock.puts <<"EOS"
|
99
|
+
CHECK RESULTS................1
|
100
|
+
CHECK RESULTS................2
|
101
|
+
EOS
|
102
|
+
sock.close
|
103
|
+
|
104
|
+
sock = TCPSocket.open("localhost", 4000)
|
105
|
+
sock.puts("quit")
|
106
|
+
sock.close
|
107
|
+
exit
|
108
|
+
end
|
109
|
+
|
110
|
+
timeout 5 do
|
111
|
+
Yggdrasil.command %w{server --debug}
|
112
|
+
end
|
113
|
+
|
114
|
+
File.exist?("/tmp/yggdrasil-test/.yggdrasil/results/HOSTNAME_127.0.0.1").should be_true
|
115
|
+
`cat /tmp/yggdrasil-test/.yggdrasil/results/HOSTNAME_127.0.0.1`.should == <<"EOS"
|
116
|
+
CHECK RESULTS................1
|
117
|
+
CHECK RESULTS................2
|
118
|
+
EOS
|
119
|
+
|
120
|
+
Process.waitall
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should not response get_ro_id_pw" do
|
124
|
+
puts "---- should not response get_ro_id_pw"
|
125
|
+
prepare_environment
|
126
|
+
Yggdrasil.command %w{init-server} +
|
127
|
+
%w{--port 4000} +
|
128
|
+
%w{--repo svn://localhost/tmp/yggdrasil-test/svn-repo/servers/{HOST}/},
|
129
|
+
"\n\n"
|
130
|
+
|
131
|
+
fork do
|
132
|
+
sleep 1
|
133
|
+
sock = TCPSocket.open("localhost", 4000)
|
134
|
+
sock.puts("\n")
|
135
|
+
no_res = sock.gets
|
136
|
+
no_res.should be_nil
|
137
|
+
sock.close
|
138
|
+
|
139
|
+
sleep 1
|
140
|
+
sock = TCPSocket.open("localhost", 4000)
|
141
|
+
sock.puts("get_ro_id_pw")
|
142
|
+
username = sock.gets
|
143
|
+
username.should be_nil
|
144
|
+
sock.close
|
145
|
+
|
146
|
+
sock = TCPSocket.open("localhost", 4000)
|
147
|
+
sock.puts("quit")
|
148
|
+
sock.close
|
149
|
+
exit
|
150
|
+
end
|
151
|
+
|
152
|
+
timeout 5 do
|
153
|
+
Yggdrasil.command %w{server --debug}
|
154
|
+
end
|
155
|
+
|
156
|
+
Process.waitall
|
157
|
+
end
|
158
|
+
end
|