From b47ad7fde2cd095dbdb04c06d15e0992609609b9 Mon Sep 17 00:00:00 2001 From: Avinash Ganesh Date: Wed, 8 Feb 2023 16:34:10 +0530 Subject: [PATCH] Make 'qmgr' logs as default (#401) * Required updates * Update docker_api_test.go --- cmd/runmqserver/logging.go | 11 ++++++++--- cmd/runmqserver/logging_test.go | 4 ++-- test/docker/docker_api_test.go | 7 +------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/runmqserver/logging.go b/cmd/runmqserver/logging.go index 8577585..1cf8d80 100644 --- a/cmd/runmqserver/logging.go +++ b/cmd/runmqserver/logging.go @@ -371,7 +371,7 @@ func getMQLogConsoleSource() string { func isLogConsoleSourceValid() bool { mqLogSource := getMQLogConsoleSource() retValue := false - //If nothing is set, we will mirror all, so valid + //If nothing is set, we will mirror qmgr, so valid if mqLogSource == "" { return true } @@ -396,9 +396,14 @@ func isLogConsoleSourceValid() bool { func checkLogSourceForMirroring(source string) bool { logsrcs := getMQLogConsoleSource() - //Nothing set, this is when we mirror all + //Nothing set, this is when we mirror qmgr if logsrcs == "" { - return true + if source == "qmgr" { + return true + } else { + return false + } + } //Split the csv environment value so that we get an accurate comparison instead of a contains() check diff --git a/cmd/runmqserver/logging_test.go b/cmd/runmqserver/logging_test.go index 5760510..22bc140 100644 --- a/cmd/runmqserver/logging_test.go +++ b/cmd/runmqserver/logging_test.go @@ -67,7 +67,7 @@ var mqLogSourcesTests = []struct { {2, "qmgr", true, true, false}, {3, "web,qmgr", true, true, true}, {4, "web", true, false, true}, - {5, " ", true, true, true}, + {5, " ", true, true, false}, {6, "QMGR,WEB", true, true, true}, {7, "qmgr, ", true, true, false}, {8, "qmgr , web", true, true, true}, @@ -77,7 +77,7 @@ var mqLogSourcesTests = []struct { {12, "fake,dummy,web", false, false, true}, {13, "true", false, false, false}, {14, "false", false, false, false}, - {15, "", true, true, true}, + {15, "", true, true, false}, } func TestLoggingConsoleSourceInputs(t *testing.T) { diff --git a/test/docker/docker_api_test.go b/test/docker/docker_api_test.go index b13f0ba..e2575fe 100644 --- a/test/docker/docker_api_test.go +++ b/test/docker/docker_api_test.go @@ -1520,11 +1520,6 @@ func TestLoggingConsoleSource(t *testing.T) { t.Errorf("%v", errJson) } - jsonLogs, errJson = waitForMessageInLog(t, cli, id, "CWWKF0011I") - if errJson != nil { - t.Errorf("%v", errJson) - } - isMessageFound := scanForExcludedEntries(jsonLogs) if isMessageFound == true { @@ -1669,7 +1664,7 @@ func TestLoggingWithQmgrAndExcludeId(t *testing.T) { t.Fatalf("Expected all log lines to be valid JSON. But got error %v ", err) } - if strings.Contains(jsonLogs, "AMQ7230I") || strings.Contains(jsonLogs, "CWWKF0011I") { + if strings.Contains(jsonLogs, "AMQ7230I") || strings.Contains(jsonLogs, "CWWKF0011I") { t.Errorf("Expected to exclude messageId by default; but messageId \"%v\" is present", jsonLogs) }