You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by pv...@apache.org on 2020/08/25 15:20:49 UTC
[nifi-registry] branch main updated: NIFIREG-413 Add test
DataSourceFactory for Postgress 11 and upgrade Flyway
This is an automated email from the ASF dual-hosted git repository.
pvillard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-registry.git
The following commit(s) were added to refs/heads/main by this push:
new 3a4f0ef NIFIREG-413 Add test DataSourceFactory for Postgress 11 and upgrade Flyway
3a4f0ef is described below
commit 3a4f0ef6e23399219e9e16bec5a9edda03da28f6
Author: Bryan Bende <bb...@apache.org>
AuthorDate: Mon Aug 24 14:55:44 2020 -0400
NIFIREG-413 Add test DataSourceFactory for Postgress 11 and upgrade Flyway
Signed-off-by: Pierre Villard <pi...@gmail.com>
This closes #297.
---
.../registry/db/Postgres11DataSourceFactory.java | 54 ++++++++++++++++++++++
nifi-registry-core/pom.xml | 13 ++++++
pom.xml | 18 ++++----
3 files changed, 76 insertions(+), 9 deletions(-)
diff --git a/nifi-registry-core/nifi-registry-test/src/main/java/org/apache/nifi/registry/db/Postgres11DataSourceFactory.java b/nifi-registry-core/nifi-registry-test/src/main/java/org/apache/nifi/registry/db/Postgres11DataSourceFactory.java
new file mode 100644
index 0000000..ff66240
--- /dev/null
+++ b/nifi-registry-core/nifi-registry-test/src/main/java/org/apache/nifi/registry/db/Postgres11DataSourceFactory.java
@@ -0,0 +1,54 @@
+package org.apache.nifi.registry.db;/*
+ * 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.
+ */
+
+import org.postgresql.ds.PGSimpleDataSource;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import org.testcontainers.containers.PostgreSQLContainer;
+import org.testcontainers.delegate.DatabaseDelegate;
+import org.testcontainers.jdbc.JdbcDatabaseDelegate;
+
+import javax.annotation.PostConstruct;
+import javax.script.ScriptException;
+import javax.sql.DataSource;
+import java.sql.SQLException;
+
+@Configuration
+@Profile("postgres-11")
+public class Postgres11DataSourceFactory extends TestDataSourceFactory {
+
+ private static final PostgreSQLContainer POSTGRESQL_CONTAINER = new PostgreSQLContainer("postgres:11");
+
+ static {
+ POSTGRESQL_CONTAINER.start();
+ }
+
+ @Override
+ protected DataSource createDataSource() {
+ PGSimpleDataSource dataSource = new PGSimpleDataSource();
+ dataSource.setUrl(POSTGRESQL_CONTAINER.getJdbcUrl());
+ dataSource.setUser(POSTGRESQL_CONTAINER.getUsername());
+ dataSource.setPassword(POSTGRESQL_CONTAINER.getPassword());
+ return dataSource;
+ }
+
+ @PostConstruct
+ public void initDatabase() throws SQLException, ScriptException {
+ DatabaseDelegate databaseDelegate = new JdbcDatabaseDelegate(POSTGRESQL_CONTAINER, "");
+ databaseDelegate.execute("DROP DATABASE test; CREATE DATABASE test;", "", 0, false, true);
+ }
+}
\ No newline at end of file
diff --git a/nifi-registry-core/pom.xml b/nifi-registry-core/pom.xml
index 8513ffd..4301aa1 100644
--- a/nifi-registry-core/pom.xml
+++ b/nifi-registry-core/pom.xml
@@ -220,6 +220,19 @@
</systemPropertyVariables>
</configuration>
</execution>
+ <execution>
+ <id>postgres11-test</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <systemPropertyVariables>
+ <spring.profiles.active>postgres-11</spring.profiles.active>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
</executions>
</plugin>
</plugins>
diff --git a/pom.xml b/pom.xml
index 0aefdfc..3a25b4c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -99,8 +99,8 @@
<jackson.version>2.10.3</jackson.version>
<spring.boot.version>2.2.6.RELEASE</spring.boot.version>
<spring.security.version>5.1.9.RELEASE</spring.security.version>
- <flyway.version>5.2.4</flyway.version>
- <flyway.tests.version>5.1.0</flyway.tests.version>
+ <flyway.version>6.0.8</flyway.version>
+ <flyway.tests.version>6.0.0</flyway.tests.version>
<swagger.ui.version>3.12.0</swagger.ui.version>
<testcontainers.version>1.11.2</testcontainers.version>
<h2.version>1.4.199</h2.version>
@@ -112,7 +112,7 @@
<repositories>
<repository>
<id>central</id>
- <!-- This should be at top, it makes maven try the central repo
+ <!-- This should be at top, it makes maven try the central repo
first and then others and hence faster dep resolution -->
<name>Maven Repository</name>
<url>https://repo1.maven.org/maven2</url>
@@ -622,11 +622,11 @@
<profiles>
<profile>
- <!-- Checks style and licensing requirements. This is a good idea to run
- for contributions and for the release process. While it would be nice to
- run always these plugins can considerably slow the build and have proven
- to create unstable builds in our multi-module project and when building using
- multiple threads. The stability issues seen with Checkstyle in multi-module
+ <!-- Checks style and licensing requirements. This is a good idea to run
+ for contributions and for the release process. While it would be nice to
+ run always these plugins can considerably slow the build and have proven
+ to create unstable builds in our multi-module project and when building using
+ multiple threads. The stability issues seen with Checkstyle in multi-module
builds include false-positives and false negatives. -->
<id>contrib-check</id>
<build>
@@ -681,7 +681,7 @@
</build>
</profile>
<profile>
- <!-- This profile will disable DocLint which performs strict
+ <!-- This profile will disable DocLint which performs strict
JavaDoc processing which was introduced in JDK 8, which is required to build nifi-registry.
These are technically errors in the JavaDoc, which we need to eventually address.
However, without this, artifact generation currently fails. -->