-
Notifications
You must be signed in to change notification settings - Fork 761
/
Copy pathsnmpwalk.rake
68 lines (58 loc) · 1.87 KB
/
snmpwalk.rake
1
2
3
4
5
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
56
57
58
59
60
61
62
63
64
65
66
67
68
require 'ci/common'
def snmpwalk_version
ENV['FLAVOR_VERSION'] || 'latest'
end
def snmpwalk_rootdir
"#{ENV['INTEGRATIONS_DIR']}/snmpwalk_#{snmpwalk_version}"
end
def resources_path
base = ENV['TRAVIS_BUILD_DIR'] || ENV['CI_BUILD_DIR']
base.to_s + '/snmpwalk/ci/resources'
end
namespace :ci do
namespace :snmpwalk do |flavor|
task before_install: ['ci:common:before_install']
task install: ['ci:common:install'] do
use_venv = in_venv
install_requirements('snmpwalk/requirements.txt',
"--cache-dir #{ENV['PIP_CACHE']}",
"#{ENV['VOLATILE_DIR']}/ci.log", use_venv)
sh %(docker run -d -v #{resources_path}:/etc/snmp/ \
--name dd-test-snmpwalk -p 11111:161/udp \
polinux/snmpd -c /etc/snmp/snmpd.conf)
sleep_for 5
end
task before_script: ['ci:common:before_script']
task script: ['ci:common:script'] do
this_provides = [
'snmpwalk'
]
Rake::Task['ci:common:run_tests'].invoke(this_provides)
end
task before_cache: ['ci:common:before_cache']
task cleanup: ['ci:common:cleanup'] do
sh %(docker stop dd-test-snmpwalk)
sh %(docker rm dd-test-snmpwalk)
end
task :execute do
exception = nil
begin
%w[before_install install before_script].each do |u|
Rake::Task["#{flavor.scope.path}:#{u}"].invoke
end
Rake::Task["#{flavor.scope.path}:script"].invoke
Rake::Task["#{flavor.scope.path}:before_cache"].invoke
rescue => e
exception = e
puts "Failed task: #{e.class} #{e.message}".red
end
if ENV['SKIP_CLEANUP']
puts 'Skipping cleanup, disposable environments are great'.yellow
else
puts 'Cleaning up'
Rake::Task["#{flavor.scope.path}:cleanup"].invoke
end
raise exception if exception
end
end
end