This is an automated email from the ASF dual-hosted git repository.

frankgh pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra-sidecar.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 059f992d CASSSIDECAR-336: Fix logging regression in Sidecar after 
CASSSIDECAR-176 (#253)
059f992d is described below

commit 059f992dfe422758cc80535a744a9ba6d852dc89
Author: Francisco Guerrero <[email protected]>
AuthorDate: Thu Aug 21 11:55:44 2025 -0700

    CASSSIDECAR-336: Fix logging regression in Sidecar after CASSSIDECAR-176 
(#253)
    
    Patch by Francisco Guerrero; reviewed by Bernardo Botella, Yifan Cai for 
CASSSIDECAR-336
---
 CHANGES.txt                                        |  1 +
 server/build.gradle                                |  4 -
 .../sidecar/CassandraSidecarDaemonTest.java        | 90 ++++++++++++++++++++--
 3 files changed, 85 insertions(+), 10 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 3227e36f..798114f1 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,6 @@
 0.2.0
 -----
+ * Fix logging regression in Sidecar after CASSSIDECAR-176 (CASSSIDECAR-336)
  * Do not log whole exception when schema is not found (CASSSIDECAR-250)
  * Add comprehensive OpenAPI documentation (CASSSIDECAR-176)
  * Fix type used for reading member_of column in SystemAuthDatabaseAccessor 
(CASSSIDECAR-333)
diff --git a/server/build.gradle b/server/build.gradle
index f7cad2c5..410fa7fd 100644
--- a/server/build.gradle
+++ b/server/build.gradle
@@ -143,10 +143,6 @@ dependencies {
     // OpenAPI support
     
implementation("org.eclipse.microprofile.openapi:microprofile-openapi-api:${project.microprofileOpenApiVersion}")
     
implementation("jakarta.ws.rs:jakarta.ws.rs-api:${project.jakartaWsRsVersion}")
-    implementation("io.swagger.core.v3:swagger-core:${project.swaggerVersion}")
-    
implementation("io.swagger.core.v3:swagger-annotations:${project.swaggerVersion}")
-    
implementation("io.swagger.core.v3:swagger-models:${project.swaggerVersion}")
-    
implementation("io.swagger.core.v3:swagger-jaxrs2:${project.swaggerVersion}")
 
     testImplementation 
"org.junit.jupiter:junit-jupiter-api:${project.junitVersion}"
     testImplementation 
"org.junit.jupiter:junit-jupiter-params:${project.junitVersion}"
diff --git 
a/server/src/test/java/org/apache/cassandra/sidecar/CassandraSidecarDaemonTest.java
 
b/server/src/test/java/org/apache/cassandra/sidecar/CassandraSidecarDaemonTest.java
index bda9c9a0..714bc5f1 100644
--- 
a/server/src/test/java/org/apache/cassandra/sidecar/CassandraSidecarDaemonTest.java
+++ 
b/server/src/test/java/org/apache/cassandra/sidecar/CassandraSidecarDaemonTest.java
@@ -18,6 +18,7 @@
 
 package org.apache.cassandra.sidecar;
 
+import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -25,12 +26,13 @@ import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
 
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.junit.jupiter.api.io.TempDir;
 
 import io.vertx.core.Vertx;
 import io.vertx.ext.web.client.HttpResponse;
@@ -49,14 +51,42 @@ import static 
org.assertj.core.api.Assertions.assertThatIllegalArgumentException
  */
 class CassandraSidecarDaemonTest
 {
-    private static final Logger LOGGER = 
LoggerFactory.getLogger(CassandraSidecarDaemonTest.class);
-
     static final String[] NO_ARGS = {};
 
+    @TempDir
+    static Path testDir;
+
+    @BeforeAll
+    static void configureLogging() throws IOException
+    {
+        Path confDirectory = testDir.resolve("conf");
+        Path logbackConfigFile = testDir.resolve("conf/logback.xml");
+        Path logDirectory = testDir.resolve("logs");
+        Files.createDirectories(confDirectory);
+        Files.createDirectories(logDirectory);
+
+        Path sourceLogbackConfigFile = Paths.get("../conf/logback.xml");
+        assertThat(sourceLogbackConfigFile).exists();
+        Files.copy(sourceLogbackConfigFile, logbackConfigFile);
+
+        System.setProperty("sidecar.logdir", logDirectory.toString());
+        System.setProperty("logback.configurationFile", 
logbackConfigFile.toString());
+        System.setProperty("vertx.logger-delegate-factory-class-name", 
"io.vertx.core.logging.SLF4JLogDelegateFactory");
+    }
+
+    @AfterAll
+    static void clearLoggingProperties()
+    {
+        System.clearProperty("sidecar.logdir");
+        System.clearProperty("logback.configurationFile");
+        System.clearProperty("vertx.logger-delegate-factory-class-name");
+    }
+
     @BeforeEach
     void setup()
     {
         System.clearProperty("sidecar.config");
+        clearLogDirectory();
     }
 
     @Test
@@ -141,7 +171,6 @@ class CassandraSidecarDaemonTest
         }
         finally
         {
-            LOGGER.debug("Tearing down");
             maybeStopCassandraSidecar();
             Files.deleteIfExists(targetFile);
 
@@ -156,6 +185,39 @@ class CassandraSidecarDaemonTest
         }
     }
 
+    @Test
+    void testLogbackConfiguration()
+    {
+        Path path = Paths.get("../conf/sidecar.yaml");
+        assertThat(path).exists();
+
+        System.setProperty("sidecar.config", path.toUri().toString());
+        Vertx vertx = Vertx.vertx();
+        WebClient client = WebClient.create(vertx);
+        try
+        {
+            CassandraSidecarDaemon.main(NO_ARGS);
+
+            loopAssert(10, () -> {
+                HttpResponse<String> response = getBlocking(client.get(9043, 
"localhost", "/api/v1/__health")
+                                                                  
.as(BodyCodec.string())
+                                                                  .send(),
+                                                            2, 
TimeUnit.SECONDS,
+                                                            "Query for sidecar 
health");
+                assertThat(response.statusCode()).isEqualTo(OK.code());
+                assertThat(response.body()).isEqualTo("{\"status\":\"OK\"}");
+            });
+
+            
assertThat(testDir.resolve("logs/debug.log")).exists().isNotEmptyFile();
+            
assertThat(testDir.resolve("logs/system.log")).exists().isNotEmptyFile();
+        }
+        finally
+        {
+            maybeStopCassandraSidecar();
+            TestResourceReaper.create().with(vertx).with(client).close();
+        }
+    }
+
     static void maybeStopCassandraSidecar()
     {
         Server runningApplication = CassandraSidecarDaemon.runningApplication;
@@ -183,4 +245,20 @@ class CassandraSidecarDaemonTest
         Files.createDirectories(parentDirectory);
         return createdParents;
     }
+
+    void clearLogDirectory()
+    {
+        Path logsDirectory = testDir.resolve("logs");
+        if (Files.exists(logsDirectory))
+        {
+            try (Stream<Path> logFiles = Files.walk(logsDirectory))
+            {
+                logFiles.map(Path::toFile).forEach(File::delete);
+            }
+            catch (Exception e)
+            {
+                throw new RuntimeException("Unable to clear all files in the 
log directory", e);
+            }
+        }
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to