From c54a1fd9d41b919ecd0dc24214c3c30ac059391f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Wed, 19 Oct 2022 18:19:50 +0100 Subject: [PATCH] fix tls test --- integration-tests/tls_test.go | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/integration-tests/tls_test.go b/integration-tests/tls_test.go index 70f6a33a..51dbaac8 100644 --- a/integration-tests/tls_test.go +++ b/integration-tests/tls_test.go @@ -1057,19 +1057,36 @@ func testProxyClientTls(t *testing.T, ccmSetup *setup.CcmTestSetup, logMessages := buffer.String() - if !proxyTlsConfig.errExpected || proxyTlsConfig.errMsgExpected == "" { // if we have an errmsg to check, ignore warnings - for _, errWarnExpected := range proxyTlsConfig.errWarningsExpected { - require.True(t, strings.Contains(logMessages, errWarnExpected), "%v not found", errWarnExpected) + warnCheckFail := false + warnCheckDone := false + for _, errWarnExpected := range proxyTlsConfig.errWarningsExpected { + warnCheckDone = true + if !strings.Contains(logMessages, errWarnExpected) { + t.Logf("%v not found in %v", errWarnExpected, logMessages) + warnCheckFail = true } } if proxyTlsConfig.errExpected { require.NotNil(t, err, "Did not get expected error %s", proxyTlsConfig.errMsgExpected) + errCheckFail := false + errCheckDone := false if proxyTlsConfig.errMsgExpected != "" { - require.True(t, strings.Contains(err.Error(), proxyTlsConfig.errMsgExpected), - "%v not found in %v", proxyTlsConfig.errMsgExpected, err.Error()) + errCheckDone = true + if !strings.Contains(err.Error(), proxyTlsConfig.errMsgExpected) { + errCheckFail = true + t.Logf("%v not found in %v", err.Error(), proxyTlsConfig.errMsgExpected) + } + } + if errCheckDone && warnCheckDone { + require.True(t, !errCheckFail || !warnCheckFail) // only 1 check needs to pass in this scenario + } else if errCheckDone { + require.False(t, errCheckFail) + } else if warnCheckDone { + require.False(t, warnCheckFail) } } else { + require.False(t, warnCheckFail) require.Nil(t, err, "testClient setup failed: %v", err) // create schema on clusters through the proxy sendRequest(cqlConn, "CREATE KEYSPACE IF NOT EXISTS testks "+