1
+ require "docker"
2
+ require "serverspec"
3
+
4
+ ELK_VERSION = "5.0.1"
5
+ ELASTICSEARCH_VERSION = ELK_VERSION
6
+ LOGSTASH_VERSION = ELK_VERSION
7
+ KIBANA_VERSION = ELK_VERSION
8
+
9
+ describe "Dockerfile" do
10
+ before ( :all ) do
11
+ image = Docker ::Image . build_from_dir ( '.' )
12
+
13
+ set :os , family : :debian
14
+ set :backend , :docker
15
+ set :docker_image , image . id
16
+ end
17
+
18
+
19
+ ## Check OS and version
20
+
21
+ it "installs the right version of Ubuntu" do
22
+ expect ( os_version ) . to include ( "Ubuntu 16" )
23
+ end
24
+
25
+ def os_version
26
+ command ( "lsb_release -a" ) . stdout
27
+ end
28
+
29
+
30
+ ## Check that ELK stack is installed
31
+
32
+ describe file ( '/opt/elasticsearch/bin/elasticsearch' ) do
33
+ it { should be_file }
34
+ end
35
+
36
+ describe file ( '/opt/logstash/bin/logstash' ) do
37
+ it { should be_file }
38
+ end
39
+
40
+ describe file ( '/opt/kibana/bin/kibana' ) do
41
+ it { should be_file }
42
+ end
43
+
44
+
45
+ ## Check ELK stack versions
46
+
47
+ it "installs the right version of Elasticsearch" do
48
+ expect ( elasticsearch_version ) . to include ( "Version: #{ ELASTICSEARCH_VERSION } " )
49
+ end
50
+
51
+ it "installs the right version of Logstash" do
52
+ expect ( logstash_version ) . to include ( LOGSTASH_VERSION )
53
+ end
54
+
55
+ it "installs the right version of Kibana" do
56
+ expect ( kibana_version ) . to include ( KIBANA_VERSION )
57
+ end
58
+
59
+ def elasticsearch_version
60
+ #command("curl -XGET 'localhost:9200/?filter_path=version.number&flat_settings=true'").stdout
61
+ command ( "/opt/elasticsearch/bin/elasticsearch --version" ) . stdout
62
+ end
63
+
64
+ def logstash_version
65
+ command ( "/opt/logstash/bin/logstash --version" ) . stdout
66
+ end
67
+
68
+ def kibana_version
69
+ command ( "/opt/kibana/bin/kibana --version" ) . stdout
70
+ end
71
+ end
0 commit comments