Skip to content

Commit a0b1f8e

Browse files
committed
Take up code review suggestions
1. Remove rogue character from test file causing interpreter failure 2. Split out helpers for docker compose orchestration 3. Only send a single message instead of infinite through to ES
1 parent 1630ca2 commit a0b1f8e

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

x-pack/distributions/internal/observabilitySRE/qa/acceptance/docker/logstash/pipeline/logstash-to-elasticsearch-weak.conf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
input {
22
generator {
3-
# Generate this message indefinitely to give ES container time to come online
4-
count => -1
5-
lines => ["FIPS weak protocol test heartbeat"]
3+
lines => ["FIPS weak protocol test message"]
64
}
75
}
86

x-pack/distributions/internal/observabilitySRE/qa/acceptance/docker/logstash/pipeline/logstash-to-elasticsearch.conf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
input {
22
generator {
3-
# Generate this message indefinitely to give ES container time to come online
4-
count => -1
5-
lines => ["FIPS compliance test heartbeat"]
3+
lines => ["FIPS compliance test message"]
64
}
75
}
86

x-pack/distributions/internal/observabilitySRE/qa/acceptance/spec/acceptance_tests_spec.rb

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def es_request(path, body = nil)
1414
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
1515

1616
request = body ? Net::HTTP::Post.new(uri.request_uri) : Net::HTTP::Get.new(uri.request_uri)
17-
request.basic_auth(es_user, es_password)q
17+
request.basic_auth(es_user, es_password)
1818
request["Content-Type"] = "application/json"
1919
request.body = body if body
2020

@@ -59,14 +59,25 @@ def wait_for_elasticsearch(max_retries = 120)
5959
raise "System not ready after #{max_retries} seconds" unless ready
6060
end
6161

62+
def docker_compose_invoke(subcommand, env={})
63+
env_str = env.map{ |k,v| "#{k.to_s.upcase}=#{Shellwords.escape(v)} "}.join
64+
work_dir = Pathname.new("#{__dir__}/../docker").cleanpath
65+
command = "#{env_str}docker-compose --project-directory=#{Shellwords.escape(work_dir)} #{subcommand}"
66+
system(command) or fail "Failed to invoke Docker Compose with command `#{command}`"
67+
end
68+
69+
def docker_compose_up(env={}) = docker_compose_invoke("up --detach", env)
70+
71+
def docker_compose_down(env={}) = docker_compose_invoke("down --volumes", env)
72+
6273
context "when running with FIPS-compliant configuration" do
6374
before(:all) do
64-
system("cd #{__dir__}/../docker && docker-compose up -d") or fail "Failed to start Docker Compose environment"
75+
docker_compose_up
6576
wait_for_elasticsearch
6677
end
6778

6879
after(:all) do
69-
system("cd #{__dir__}/../docker && docker-compose down -v")
80+
docker_compose_down
7081
end
7182

7283
it "data flows from Logstash to Elasticsearch using FIPS-approved SSL" do
@@ -89,12 +100,12 @@ def wait_for_elasticsearch(max_retries = 120)
89100

90101
context "when running with non-FIPS compliant configuration" do
91102
before(:all) do
92-
system("cd #{__dir__}/../docker && LOGSTASH_PIPELINE=logstash-to-elasticsearch-weak.conf docker-compose up -d") or fail "Failed to start Docker Compose with weak SSL"
103+
docker_compose_up({"LOGSTASH_PIPELINE" => "logstash-to-elasticsearch-weak.conf"})
93104
wait_for_elasticsearch
94105
end
95106

96107
after(:all) do
97-
system("cd #{__dir__}/../docker && docker-compose down -v")
108+
docker_compose_down
98109
end
99110

100111
it "prevents data flow when using TLSv1.1 which is not FIPS-compliant" do

0 commit comments

Comments
 (0)