From b0c9ab7d61819cfdcafdeb96affc2969b18c9759 Mon Sep 17 00:00:00 2001
From: John McDonnell <jmcdonnell@gitlab.com>
Date: Thu, 27 Jun 2024 15:55:55 +0100
Subject: [PATCH] E2E: Add logging of environment certs for mtls scenario

https://gitlab.com/gitlab-org/gitlab/-/issues/431474 notes that some
failures can occur in the MTLS scenario due to TLS error when gitaly
tries to access the /internal/allowed endpoints. In order to debug
this, let's first verify what certs are actually present on disk to
determine if the flakiness is arising from the test environment config
or from an application config perspective.
---
 .../features/api/12_systems/gitaly/gitaly_mtls_spec.rb | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/qa/qa/specs/features/api/12_systems/gitaly/gitaly_mtls_spec.rb b/qa/qa/specs/features/api/12_systems/gitaly/gitaly_mtls_spec.rb
index 54979faad2e60..005b7fddf4fee 100644
--- a/qa/qa/specs/features/api/12_systems/gitaly/gitaly_mtls_spec.rb
+++ b/qa/qa/specs/features/api/12_systems/gitaly/gitaly_mtls_spec.rb
@@ -7,6 +7,16 @@ module QA
       let(:first_added_commit_message) { 'commit over git' }
       let(:second_added_commit_message) { 'commit over api' }
 
+      before do
+        # Debug environment certs to attempt to address some flakiness as per
+        # https://gitlab.com/gitlab-org/gitlab/-/issues/431474#note_1891541780
+        QA::Service::Shellout.shell("docker exec gitlab bash -c 'ls -al /etc/gitlab/trusted-certs'")
+        QA::Service::Shellout.shell("docker exec gitlab bash -c 'ls -al /etc/gitlab/ssl'")
+
+        QA::Service::Shellout.shell("docker exec gitaly bash -c 'ls -al /etc/gitlab/trusted-certs'")
+        QA::Service::Shellout.shell("docker exec gitaly bash -c 'ls -al /etc/gitlab/ssl'")
+      end
+
       it 'pushes to gitaly', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347677' do
         project = Resource::Project.fabricate! do |project|
           project.name = "mTLS"
-- 
GitLab