From d81bab4390c5d3d0d970e00422b0176af6db190c Mon Sep 17 00:00:00 2001 From: Alexandre Dutra Date: Tue, 21 Oct 2025 17:52:11 +0200 Subject: [PATCH] Move TestPolarisEventListener to test fixtures --- .../config/ProductionReadinessChecks.java | 14 ---------- .../QuarkusTestPolarisEventListener.java | 27 +++++++++++++++++++ .../listeners/TestPolarisEventListener.java | 6 +---- 3 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 runtime/service/src/test/java/org/apache/polaris/service/events/listeners/QuarkusTestPolarisEventListener.java rename runtime/service/src/{main => testFixtures}/java/org/apache/polaris/service/events/listeners/TestPolarisEventListener.java (98%) diff --git a/runtime/service/src/main/java/org/apache/polaris/service/config/ProductionReadinessChecks.java b/runtime/service/src/main/java/org/apache/polaris/service/config/ProductionReadinessChecks.java index 51a1e1008f..c1a03a7ab4 100644 --- a/runtime/service/src/main/java/org/apache/polaris/service/config/ProductionReadinessChecks.java +++ b/runtime/service/src/main/java/org/apache/polaris/service/config/ProductionReadinessChecks.java @@ -44,8 +44,6 @@ import org.apache.polaris.service.context.RealmContextResolver; import org.apache.polaris.service.context.TestRealmContextResolver; import org.apache.polaris.service.credentials.connection.AuthType; -import org.apache.polaris.service.events.listeners.PolarisEventListener; -import org.apache.polaris.service.events.listeners.TestPolarisEventListener; import org.apache.polaris.service.metrics.MetricsConfiguration; import org.apache.polaris.service.persistence.InMemoryPolarisMetaStoreManagerFactory; import org.eclipse.microprofile.config.Config; @@ -222,18 +220,6 @@ public ProductionReadinessCheck checkRealmResolver(Config config, RealmContextRe return ProductionReadinessCheck.OK; } - @Produces - public ProductionReadinessCheck checkPolarisEventListener( - PolarisEventListener polarisEventListener) { - if (polarisEventListener instanceof TestPolarisEventListener) { - return ProductionReadinessCheck.of( - Error.of( - "TestPolarisEventListener is intended for tests only.", - "polaris.event-listener.type")); - } - return ProductionReadinessCheck.OK; - } - private static String authRealmSegment(String realm) { return realm.equals(AuthenticationConfiguration.DEFAULT_REALM_KEY) ? "" : realm + "."; } diff --git a/runtime/service/src/test/java/org/apache/polaris/service/events/listeners/QuarkusTestPolarisEventListener.java b/runtime/service/src/test/java/org/apache/polaris/service/events/listeners/QuarkusTestPolarisEventListener.java new file mode 100644 index 0000000000..8cf6b89dd9 --- /dev/null +++ b/runtime/service/src/test/java/org/apache/polaris/service/events/listeners/QuarkusTestPolarisEventListener.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.events.listeners; + +import io.smallrye.common.annotation.Identifier; +import jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +@Identifier("test") +public class QuarkusTestPolarisEventListener extends TestPolarisEventListener {} diff --git a/runtime/service/src/main/java/org/apache/polaris/service/events/listeners/TestPolarisEventListener.java b/runtime/service/src/testFixtures/java/org/apache/polaris/service/events/listeners/TestPolarisEventListener.java similarity index 98% rename from runtime/service/src/main/java/org/apache/polaris/service/events/listeners/TestPolarisEventListener.java rename to runtime/service/src/testFixtures/java/org/apache/polaris/service/events/listeners/TestPolarisEventListener.java index 2bf5009674..a10abcbb1c 100644 --- a/runtime/service/src/main/java/org/apache/polaris/service/events/listeners/TestPolarisEventListener.java +++ b/runtime/service/src/testFixtures/java/org/apache/polaris/service/events/listeners/TestPolarisEventListener.java @@ -18,8 +18,6 @@ */ package org.apache.polaris.service.events.listeners; -import io.smallrye.common.annotation.Identifier; -import jakarta.enterprise.context.ApplicationScoped; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.polaris.service.events.AfterAttemptTaskEvent; @@ -33,9 +31,7 @@ import org.apache.polaris.service.events.PrincipalRolesServiceEvents; import org.apache.polaris.service.events.PrincipalsServiceEvents; -/** Event listener that stores all emitted events forever. Not recommended for use in production. */ -@ApplicationScoped -@Identifier("test") +/** Test event listener that stores all emitted events forever. */ public class TestPolarisEventListener implements PolarisEventListener { private final Map, PolarisEvent> latestEvents = new ConcurrentHashMap<>();