You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ab...@apache.org on 2020/03/17 17:21:10 UTC

[nifi-registry] 14/43: NIFIREG-337 Add automated testing for Postgres 10.x

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

aboda pushed a commit to branch NIFIREG-371-RC1
in repository https://gitbox.apache.org/repos/asf/nifi-registry.git

commit 219b57c27be77d900364236d6aa6e6e11ed72c8f
Author: Bryan Bende <bb...@apache.org>
AuthorDate: Thu Oct 17 13:24:29 2019 -0400

    NIFIREG-337 Add automated testing for Postgres 10.x
---
 README.md                                          |  3 +-
 .../src/main/asciidoc/administration-guide.adoc    |  2 +-
 .../registry/db/Postgres10DataSourceFactory.java   | 55 ++++++++++++++++++++++
 nifi-registry-core/pom.xml                         | 13 +++++
 4 files changed, 71 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 4999a69..3e97e83 100644
--- a/README.md
+++ b/README.md
@@ -77,7 +77,8 @@ Assuming Docker is running on the system where the build is running, then the fo
 | --------------- | ------------- |
 | All supported   | `mvn verify -Ptest-all-dbs` |
 | H2 (default)    | `mvn verify` |
-| PostgreSQL      | `mvn verify -Dspring.profiles.active=postgres` | 
+| PostgreSQL 9.x  | `mvn verify -Dspring.profiles.active=postgres` | 
+| PostgreSQL 10.x | `mvn verify -Dspring.profiles.active=postgres-10` | 
 | MySQL 5.6       | `mvn verify -Pcontrib-check -Dspring.profiles.active=mysql-56` |
 | MySQL 5.7       | `mvn verify -Pcontrib-check -Dspring.profiles.active=mysql-57` |
 | MySQL 8         | `mvn verify -Pcontrib-check -Dspring.profiles.active=mysql-8`  |
diff --git a/nifi-registry-core/nifi-registry-docs/src/main/asciidoc/administration-guide.adoc b/nifi-registry-core/nifi-registry-docs/src/main/asciidoc/administration-guide.adoc
index 0c6a5dd..90b80d5 100644
--- a/nifi-registry-core/nifi-registry-docs/src/main/asciidoc/administration-guide.adoc
+++ b/nifi-registry-core/nifi-registry-docs/src/main/asciidoc/administration-guide.adoc
@@ -1128,7 +1128,7 @@ providing 2 total locations, including `nifi.registry.extension.dir.1`.
 
 The metadata database maintains the knowledge of which buckets exist, which versioned items belong to which buckets, as well as the version history for each item.
 
-Currently, NiFi Registry supports using H2, Postgres 9.x, and MySQL (5.6, 5.7, 8.0) for the relational database engine.
+Currently, NiFi Registry supports using H2, Postgres (9.x, 10.x), and MySQL (5.6, 5.7, 8.0) for the relational database engine.
 
 NOTE: NiFi Registry 0.1.0 only supports H2.
 
diff --git a/nifi-registry-core/nifi-registry-test/src/main/java/org/apache/nifi/registry/db/Postgres10DataSourceFactory.java b/nifi-registry-core/nifi-registry-test/src/main/java/org/apache/nifi/registry/db/Postgres10DataSourceFactory.java
new file mode 100644
index 0000000..23d2f1d
--- /dev/null
+++ b/nifi-registry-core/nifi-registry-test/src/main/java/org/apache/nifi/registry/db/Postgres10DataSourceFactory.java
@@ -0,0 +1,55 @@
+/*
+ * 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.nifi.registry.db;
+
+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-10")
+public class Postgres10DataSourceFactory extends TestDataSourceFactory {
+
+    private static final PostgreSQLContainer POSTGRESQL_CONTAINER = new PostgreSQLContainer("postgres:10");
+
+    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);
+    }
+}
diff --git a/nifi-registry-core/pom.xml b/nifi-registry-core/pom.xml
index b69059e..559eac6 100644
--- a/nifi-registry-core/pom.xml
+++ b/nifi-registry-core/pom.xml
@@ -207,6 +207,19 @@
                                     </systemPropertyVariables>
                                 </configuration>
                             </execution>
+                            <execution>
+                                <id>postgres10-test</id>
+                                <phase>verify</phase>
+                                <goals>
+                                    <goal>integration-test</goal>
+                                    <goal>verify</goal>
+                                </goals>
+                                <configuration>
+                                    <systemPropertyVariables>
+                                        <spring.profiles.active>postgres-10</spring.profiles.active>
+                                    </systemPropertyVariables>
+                                </configuration>
+                            </execution>
                         </executions>
                     </plugin>
                 </plugins>