traquitana 0.1.2 → 0.1.3
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Gemfile.lock +8 -8
- data/README.md +4 -3
- data/bin/traq +26 -26
- data/gem-public_cert.pem +22 -22
- data/lib/bar.rb +1 -1
- data/lib/cleaner.rb +2 -2
- data/lib/config.rb +8 -7
- data/lib/deployer.rb +15 -8
- data/lib/packager.rb +18 -12
- data/lib/selector.rb +1 -1
- data/lib/ssh.rb +1 -1
- data/lib/traquitana.rb +1 -1
- data/lib/traquitana/version.rb +1 -1
- data/spec/bar_spec.rb +48 -41
- data/spec/cleaner_spec.rb +17 -16
- data/spec/config/Gemfile +1 -0
- data/spec/config/Rakefile +11 -0
- data/spec/config_spec.rb +106 -101
- data/spec/deploy_spec.rb +13 -10
- data/spec/network_spec.rb +55 -52
- data/spec/packager_spec.rb +40 -40
- data/spec/selector_spec.rb +9 -9
- data/traquitana.gemspec +11 -11
- metadata +33 -37
- metadata.gz.sig +0 -0
- data/lib/migrator.rb +0 -25
- data/spec/migrator_spec.rb +0 -75
data/spec/cleaner_spec.rb
CHANGED
@@ -1,22 +1,23 @@
|
|
1
|
-
require
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'minitest/focus'
|
2
3
|
require "#{File.expand_path(File.dirname(__FILE__))}/../lib/traquitana.rb"
|
3
4
|
|
4
5
|
describe Traquitana::Cleaner do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
before do
|
7
|
+
@cleaner = Traquitana::Cleaner.new
|
8
|
+
@config = Traquitana::Config.instance
|
9
|
+
@config.load
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
it 'should have a run method' do
|
13
|
+
expect(@cleaner).must_respond_to :run
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
it 'should run cleaner on remote host' do
|
17
|
+
network = MiniTest::Mock.new
|
18
|
+
network.expect(:execute, nil, [["find #{@config.directory}/traq -type f -iname '*.zip' -o -iname '*.list' | sort | head -n-2 | xargs rm $1"]])
|
19
|
+
@cleaner.network = network
|
20
|
+
@cleaner.run
|
21
|
+
network.verify
|
22
|
+
end
|
22
23
|
end
|
data/spec/config/Gemfile
CHANGED
data/spec/config/Rakefile
CHANGED
data/spec/config_spec.rb
CHANGED
@@ -1,109 +1,114 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'yaml'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'minitest/focus'
|
4
5
|
require "#{File.expand_path(File.dirname(__FILE__))}/../lib/traquitana.rb"
|
5
6
|
|
6
7
|
describe Traquitana::Config do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
8
|
+
before do
|
9
|
+
@config = Traquitana::Config.instance
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'paths' do
|
13
|
+
it 'should have a filename getter method' do
|
14
|
+
expect(@config).must_respond_to :filename
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have a filename called traq.yml if file name is not set' do
|
18
|
+
expect(File.basename(@config.filename)).must_equal('traq.yml')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have a filename setter method' do
|
22
|
+
expect(@config).must_respond_to :filename=
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should have a custom filename if filename is set' do
|
26
|
+
old = @config.filename
|
27
|
+
custom = 'config/custom.yml'
|
28
|
+
|
29
|
+
@config.filename = custom
|
30
|
+
expect(@config.filename).must_equal custom
|
31
|
+
@config.filename = old
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should have a default file method' do
|
35
|
+
expect(@config).must_respond_to :default
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should have a valid directory' do
|
39
|
+
expect(@config.directory).wont_be_nil
|
40
|
+
expect(@config.directory.size > 0).must_equal true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'configs' do
|
45
|
+
it 'should respond to configuration dynamic methods' do
|
46
|
+
expect(@config.banana).must_equal ''
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should respond with the correct value' do
|
50
|
+
@config.load
|
51
|
+
expect(@config.user).must_equal 'taq'
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should have basic information on the default file' do
|
55
|
+
contents = YAML.load(File.read(@config.default))
|
56
|
+
expect(contents['directory']).wont_be_nil
|
57
|
+
expect(contents['server']).wont_be_nil
|
58
|
+
expect(contents['list']).wont_be_nil
|
59
|
+
expect(contents['host']).wont_be_nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe 'setup' do
|
64
|
+
it 'should have a method named setup' do
|
65
|
+
expect(@config).must_respond_to :setup
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should do nothing if the configuration file exists' do
|
69
|
+
expect(@config.setup).must_equal false
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should write the configuration file if it doesnt exists' do
|
73
|
+
contents = File.read(@config.filename)
|
74
|
+
File.unlink(@config.filename)
|
75
|
+
|
76
|
+
expect(File.exists?(@config.filename)).must_equal false
|
77
|
+
expect(@config.setup).must_equal true
|
78
|
+
expect(File.exists?(@config.filename)).must_equal true
|
79
|
+
|
80
|
+
File.open(@config.filename, 'w') do |file|
|
81
|
+
file << contents
|
79
82
|
end
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe 'targets' do
|
87
|
+
it 'should have a target readable attribute' do
|
88
|
+
expect(@config).must_respond_to :target
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'should have a target writable attribute' do
|
92
|
+
expect(@config).must_respond_to :target=
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should load custom target config' do
|
96
|
+
begin
|
97
|
+
@config.filename = 'config/custom.yml'
|
98
|
+
@config.target = 'custom'
|
99
|
+
@config.load
|
100
|
+
expect(@config.directory).must_equal '/tmp/traq_test_custom'
|
101
|
+
ensure
|
102
|
+
reset_config
|
85
103
|
end
|
104
|
+
end
|
105
|
+
end
|
86
106
|
|
87
|
-
|
88
|
-
@config.must_respond_to :target=
|
89
|
-
end
|
107
|
+
private
|
90
108
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
@config.directory.must_equal "/tmp/traq_test_custom"
|
97
|
-
ensure
|
98
|
-
reset_config
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
private
|
104
|
-
def reset_config
|
105
|
-
@config.filename = "config/traq.yml"
|
106
|
-
@config.target = nil
|
107
|
-
@config.load
|
108
|
-
end
|
109
|
+
def reset_config
|
110
|
+
@config.filename = 'config/traq.yml'
|
111
|
+
@config.target = nil
|
112
|
+
@config.load
|
113
|
+
end
|
109
114
|
end
|
data/spec/deploy_spec.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'minitest/autorun'
|
4
6
|
require "#{File.expand_path(File.dirname(__FILE__))}/../lib/traquitana.rb"
|
5
7
|
|
6
8
|
describe Traquitana::Deployer do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
before do
|
10
|
+
FileUtils.cd("#{__dir__}/config")
|
11
|
+
@config = Traquitana::Config.instance
|
12
|
+
@deploy = Traquitana::Deployer.new(verbose: true)
|
13
|
+
end
|
11
14
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
it 'deploys' do
|
16
|
+
@deploy.run
|
17
|
+
end
|
15
18
|
end
|
data/spec/network_spec.rb
CHANGED
@@ -1,56 +1,59 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'digest/md5'
|
2
|
+
require 'minitest/autorun'
|
3
3
|
require "#{File.expand_path(File.dirname(__FILE__))}/../lib/traquitana.rb"
|
4
4
|
|
5
5
|
describe Traquitana::SSH do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
6
|
+
before do
|
7
|
+
@config = Traquitana::Config.instance
|
8
|
+
@network = Traquitana::SSH.new(@config.host, @config.user)
|
9
|
+
@send = "#{File.expand_path(File.dirname(__FILE__))}/config/network_test.txt"
|
10
|
+
@md5 = Digest::MD5.hexdigest(File.read(@send))
|
11
|
+
|
12
|
+
Dir.mkdir(@config.directory) if !File.exists?(@config.directory)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'configs' do
|
16
|
+
it 'should have a host attribute' do
|
17
|
+
expect(@network).must_respond_to :host
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should have an user attribute' do
|
21
|
+
expect(@network).must_respond_to :user
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should have an options attribute' do
|
25
|
+
expect(@network).must_respond_to :options
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'operations' do
|
30
|
+
it 'should have a send method' do
|
31
|
+
expect(@network).must_respond_to :send_files
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should send a file to the remote host' do
|
35
|
+
check = "#{@config.directory}/#{File.basename(@send)}"
|
36
|
+
File.unlink(check) if File.exists?(check)
|
37
|
+
|
38
|
+
@network.send_files([[@send, "#{@config.directory}/#{File.basename(@send)}"]], Traquitana::Bar.new)
|
39
|
+
|
40
|
+
expect(File.exists?(check)).must_equal true
|
41
|
+
expect(Digest::MD5.hexdigest(File.read(check))).must_equal @md5
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should have a execute method' do
|
45
|
+
expect(@network).must_respond_to :execute
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should execute a command on the remote host' do
|
49
|
+
remote_dir = "#{@config.directory}/remote_dir"
|
50
|
+
FileUtils.rmdir(remote_dir) if File.exists?(remote_dir)
|
51
|
+
|
52
|
+
@network.execute(["mkdir #{@config.directory}/remote_dir"])
|
53
|
+
expect(File.exists?(remote_dir)).must_equal true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "uploading" do
|
58
|
+
end
|
56
59
|
end
|
data/spec/packager_spec.rb
CHANGED
@@ -1,44 +1,44 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'fileutils'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'minitest/focus'
|
3
4
|
require "#{File.expand_path(File.dirname(__FILE__))}/../lib/traquitana.rb"
|
4
5
|
|
5
6
|
describe Traquitana::Packager do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
7
|
+
before do
|
8
|
+
@packager = Traquitana::Packager.new(File.expand_path(File.dirname(__FILE__)) + '/config/')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should have an id method' do
|
12
|
+
expect(@packager).must_respond_to :id
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should return an id' do
|
16
|
+
expect(@packager.id).wont_be_nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should have a list file method' do
|
20
|
+
expect(@packager).must_respond_to :list_file
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should return the correct list file name' do
|
24
|
+
expect(@packager.list_file).must_equal @packager.id + '.list'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should have a zip file method' do
|
28
|
+
expect(@packager).must_respond_to :zip_file
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should return the correct zip file name' do
|
32
|
+
expect(@packager.zip_file).must_equal @packager.id + '.zip'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should have a pack method' do
|
36
|
+
expect(@packager).must_respond_to :pack
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should return the list and package file' do
|
40
|
+
list, package = @packager.pack
|
41
|
+
expect(list).wont_be_nil
|
42
|
+
expect(package).wont_be_nil
|
43
|
+
end
|
43
44
|
end
|
44
|
-
|