forked from logstash-plugins/logstash-input-beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
66 lines (55 loc) · 2.26 KB
/
Rakefile
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
# encoding: utf-8
OS_PLATFORM = RbConfig::CONFIG["host_os"]
VENDOR_PATH = File.expand_path(File.join(File.dirname(__FILE__), "vendor"))
if OS_PLATFORM == "linux"
FILEBEAT_URL = "https://beats-nightlies.s3.amazonaws.com/filebeat/filebeat-5.0.0-nightlylatest-#{RbConfig::CONFIG["host_cpu"]}.tar.gz"
elsif OS_PLATFORM == "darwin"
FILEBEAT_URL = "https://beats-nightlies.s3.amazonaws.com/filebeat/filebeat-5.0.0-nightlylatest-darwin.tgz"
end
LSF_URL = "https://download.elastic.co/logstash-forwarder/binaries/logstash-forwarder_#{OS_PLATFORM}_amd64"
require "fileutils"
@files=[]
task :default do
system("rake -T")
end
require "logstash/devutils/rake"
namespace :test do
namespace :integration do
task :setup do
Rake::Task["test:integration:setup:filebeat"].invoke
Rake::Task["test:integration:setup:lsf"].invoke
end
namespace :setup do
desc "Download lastest stable version of Logstash-forwarder"
task :lsf do
destination = File.join(VENDOR_PATH, "logstash-forwarder")
FileUtils.rm_rf(destination)
FileUtils.mkdir_p(destination)
download_destination = File.join(destination, "logstash-forwarder")
puts "Logstash-forwarder: downloading from #{LSF_URL} to #{download_destination}"
download(LSF_URL, download_destination)
File.chmod(0755, download_destination)
end
desc "Download nigthly filebeat for integration testing"
task :filebeat do
FileUtils.mkdir_p(VENDOR_PATH)
download_destination = File.join(VENDOR_PATH, "filebeat.tar.gz")
destination = File.join(VENDOR_PATH, "filebeat")
FileUtils.rm_rf(download_destination)
FileUtils.rm_rf(destination)
FileUtils.rm_rf(File.join(VENDOR_PATH, "filebeat.tar"))
puts "Filebeat: downloading from #{FILEBEAT_URL} to #{download_destination}"
download(FILEBEAT_URL, download_destination)
untar_all(download_destination, File.join(VENDOR_PATH, "filebeat")) { |e| e }
end
end
end
end
# Uncompress all the file from the archive this only work with
# one level directory structure and its fine for LSF and filebeat packaging.
def untar_all(file, destination)
untar(file) do |entry|
out = entry.full_name.split("/").last
File.join(destination, out)
end
end