From d1b2c6dd14f711034681928f595e6a03d7a4a08b Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Mon, 20 Mar 2023 00:54:04 -0700 Subject: [PATCH] fix postgres tests --- .../config/PostgresConfiguration.java | 2 +- .../config/PostgresIndexConditions.java | 41 ------------------- .../postgres/dao/PostgresIndexDAOTest.java | 7 ++++ .../postgres/PostgresGrpcEndToEndTest.java | 3 ++ 4 files changed, 11 insertions(+), 42 deletions(-) delete mode 100644 persistence/postgres-persistence/src/main/java/com/netflix/conductor/postgres/config/PostgresIndexConditions.java diff --git a/persistence/postgres-persistence/src/main/java/com/netflix/conductor/postgres/config/PostgresConfiguration.java b/persistence/postgres-persistence/src/main/java/com/netflix/conductor/postgres/config/PostgresConfiguration.java index f59b4fde3..49add2904 100644 --- a/persistence/postgres-persistence/src/main/java/com/netflix/conductor/postgres/config/PostgresConfiguration.java +++ b/persistence/postgres-persistence/src/main/java/com/netflix/conductor/postgres/config/PostgresConfiguration.java @@ -90,7 +90,7 @@ public PostgresQueueDAO postgresQueueDAO( @Bean @DependsOn({"flywayForPrimaryDb"}) - @Conditional(PostgresIndexConditions.PostgresIndexingEnabled.class) + @ConditionalOnProperty(name = "conductor.indexing.type", havingValue = "postgres") public PostgresIndexDAO postgresIndexDAO( @Qualifier("postgresRetryTemplate") RetryTemplate retryTemplate, ObjectMapper objectMapper) { diff --git a/persistence/postgres-persistence/src/main/java/com/netflix/conductor/postgres/config/PostgresIndexConditions.java b/persistence/postgres-persistence/src/main/java/com/netflix/conductor/postgres/config/PostgresIndexConditions.java deleted file mode 100644 index a423525d4..000000000 --- a/persistence/postgres-persistence/src/main/java/com/netflix/conductor/postgres/config/PostgresIndexConditions.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - *

- * Licensed 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 com.netflix.conductor.postgres.config; - -import org.springframework.boot.autoconfigure.condition.AllNestedConditions; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; - -public class PostgresIndexConditions { - - private PostgresIndexConditions() {} - - public static class PostgresIndexingEnabled extends AllNestedConditions { - - PostgresIndexingEnabled() { - super(ConfigurationPhase.PARSE_CONFIGURATION); - } - - @SuppressWarnings("unused") - @ConditionalOnProperty( - name = "conductor.indexing.enabled", - havingValue = "true", - matchIfMissing = true) - static class enabledIndexing {} - - @SuppressWarnings("unused") - @ConditionalOnProperty( - name = "conductor.indexing.type", - havingValue = "postgres", - matchIfMissing = true) - static class enabledPostgresIndexing {} - } -} diff --git a/persistence/postgres-persistence/src/test/java/com/netflix/conductor/postgres/dao/PostgresIndexDAOTest.java b/persistence/postgres-persistence/src/test/java/com/netflix/conductor/postgres/dao/PostgresIndexDAOTest.java index e8f5ffcf2..7fad7820d 100644 --- a/persistence/postgres-persistence/src/test/java/com/netflix/conductor/postgres/dao/PostgresIndexDAOTest.java +++ b/persistence/postgres-persistence/src/test/java/com/netflix/conductor/postgres/dao/PostgresIndexDAOTest.java @@ -30,6 +30,7 @@ import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import com.netflix.conductor.common.config.TestObjectMapperConfiguration; @@ -53,6 +54,12 @@ FlywayAutoConfiguration.class }) @RunWith(SpringRunner.class) +@TestPropertySource( + properties = { + "conductor.app.asyncIndexingEnabled=false", + "conductor.elasticsearch.version=0", + "conductor.indexing.type=postgres" + }) @SpringBootTest public class PostgresIndexDAOTest { diff --git a/persistence/postgres-persistence/src/test/java/com/netflix/conductor/test/integration/grpc/postgres/PostgresGrpcEndToEndTest.java b/persistence/postgres-persistence/src/test/java/com/netflix/conductor/test/integration/grpc/postgres/PostgresGrpcEndToEndTest.java index b9e45a66a..53cc2333e 100644 --- a/persistence/postgres-persistence/src/test/java/com/netflix/conductor/test/integration/grpc/postgres/PostgresGrpcEndToEndTest.java +++ b/persistence/postgres-persistence/src/test/java/com/netflix/conductor/test/integration/grpc/postgres/PostgresGrpcEndToEndTest.java @@ -26,7 +26,10 @@ @TestPropertySource( properties = { "conductor.db.type=postgres", + "conductor.app.asyncIndexingEnabled=false", + "conductor.elasticsearch.version=6", "conductor.grpc-server.port=8098", + "conductor.indexing.type=elasticsearch", "spring.datasource.url=jdbc:tc:postgresql:11.15-alpine:///conductor", // "tc" prefix // starts the // Postgres container