Removed unused modules

This commit is contained in:
Randall Hauch 2016-03-17 16:13:24 -05:00
parent eea175a5aa
commit fa4ae33ba2
12 changed files with 0 additions and 691 deletions

View File

@ -1,58 +0,0 @@
<?xml version="1.0"?>
<!--
~ Copyright 2014 Red Hat, Inc. and/or its affiliates.
~
~ Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>io.debezium</groupId>
<artifactId>debezium-parent</artifactId>
<version>0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>debezium-connector-jdbc</artifactId>
<name>Debezium Connector for Generic JDBC</name>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<!-- Apply the properties set in the POM to the resource files -->
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<includes>
<include>**/build.properties</include>
</includes>
</resource>
</resources>
</build>
</project>

View File

@ -1,148 +0,0 @@
/*
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.injest.jdbc.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
import java.util.function.Consumer;
import java.util.function.Function;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TestDatabase {
private final static Logger LOGGER = LoggerFactory.getLogger(TestDatabase.class);
public static String hostname() {
return hostname(null);
}
public static String hostname(String defaultValue) {
return System.getProperty("database.hostname", defaultValue);
}
public static String port() {
return port(null);
}
public static String port(String defaultValue) {
return System.getProperty("database.port", defaultValue);
}
public static String username() {
return username(null);
}
public static String username(String defaultValue) {
return System.getProperty("database.username", defaultValue);
}
public static String password() {
return password(null);
}
public static String password(String defaultValue) {
return System.getProperty("database.password", defaultValue);
}
public static Connection connect(String urlPattern) throws SQLException {
return connect(urlPattern,null);
}
public static Connection connect(String urlPattern, Consumer<Properties> setProperties) throws SQLException {
return connect(env -> {
return urlPattern.replaceAll("\\$\\{hostname\\}", hostname("localhost"))
.replaceAll("\\$\\{port\\}", port())
.replaceAll("\\$\\{username\\}", username("")) // removes if there is no username
.replaceAll("\\$\\{password\\}", password("")); // removes if there is no password
} , setProperties);
}
public static Connection connect(Function<Environment, String> urlBuilder) throws SQLException {
return connect(urlBuilder,null);
}
public static Connection connect(Function<Environment, String> urlBuilder, Consumer<Properties> setProperties) throws SQLException {
Environment env = new Environment() {
@Override
public String hostname(String defaultValue) {
return TestDatabase.hostname(defaultValue);
}
@Override
public String password(String defaultValue) {
return TestDatabase.password(defaultValue);
}
@Override
public String port(String defaultValue) {
return TestDatabase.port(defaultValue);
}
@Override
public String username(String defaultValue) {
return TestDatabase.username(defaultValue);
}
};
String url = urlBuilder.apply(env);
Properties props = new Properties();
String username = username();
if (username != null) {
props.setProperty("user", username);
}
String password = password();
if (password != null) {
props.setProperty("password", password);
}
if (setProperties != null) {
setProperties.accept(props);
}
Connection conn = DriverManager.getConnection(url, props);
LOGGER.info("Connected to {} with {}",url, props);
return conn;
}
public static interface Environment {
default String username() {
return username(null);
}
default String password() {
return password(null);
}
default String hostname() {
return hostname(null);
}
default String port() {
return port(null);
}
String username(String defaultValue);
String password(String defaultValue);
String hostname(String defaultValue);
String port(String defaultValue);
default String property(String name) {
return System.getProperty(name);
}
default String property(String name, String defaultValue) {
return System.getProperty(name, defaultValue);
}
}
public TestDatabase() {
}
}

View File

@ -1,49 +0,0 @@
## Ingesting PostgreSQL
## Unit and integration tests
This module contains both unit tests and integration tests.
A *unit test* is a JUnit test class named `*Test.java` or `Test*.java` that never requires or uses external services, though it can use the file system and can run any components within the same JVM process. They should run very quickly, be independent of each other, and clean up after itself.
An *integration test* is a JUnit test class named `*IT.java` or `IT*.java` that uses one or more PostgreSQL databases running in a custom Docker container automatically started before the integration tests are run and automatically stopped and removed after all of the integration tests complete (regardless of whether they suceed or fail). All databases used in the integration tests are defined and populated using `*.sql` files and `*.sh` scripts in the `src/test/docker` directory, which are copied into the Docker image and run (in lexicographical order) by PostgreSQL upon startup. Multiple test methods within a single integration test class can reuse the same database, but generally each integration test class should use its own dedicated database(s).
Running `mvn install` will compile all code and run the unit tests. If there are any problems, such as failing unit tests, the build will stop immediately. Otherwise, the build will create the module's artifacts, create the Docker image with PostgreSQL, start the Docker container, run the integration tests, and stop the container even if there are integration test failures. If there are no problems, the build will end by installing the artifacts into the local Maven repository.
You should always default to using `mvn install`, especially prior to committing changes to Git. However, there are a few situations where you may want to run a different Maven command.
### Running some tests
If you are trying to get the test methods in a single integration test class to pass and would rather not run *all* of the integration tests, you can instruct Maven to just run that one integration test class and to skip all of the others. For example, use the following command to run the tests in the `ConnectionIT.java` class:
$ mvn -Dit.test=ConnectionIT install
Of course, wildcards also work:
$ mvn -Dit.test=Connect*IT install
### Debugging tests
Normally, the PostgreSQL Docker container is stopped and removed after the integration tests are run. One way to debug tests is to configure the build to wait for a remote debugging client, but then you also have to set up your IDE to connect. It's often far easier to debug a single test directly from within your IDE. To do that, you want to start the PostgreSQL Docker container and keep it running:
$ mvn docker:start
Then use your IDE to run one or more unit tests, optionally debugging them as needed. Just be sure that the unit tests clean up their database before (and after) each test.
To stop the container, simply use Docker to stop and remove the PostgreSQL Docker container named `database`:
$ docker stop database
$ docker rm database
### Analyzing the database
Sometimes you may want to inspect the state of the database(s) after one or more integration tests are run. The `mvn install` command runs the tests but shuts down and removes the container after the tests complete. To keep the container running after the tests complete, use this Maven command:
$ mvn integration-test
This instructs Maven to run the normal Maven lifecycle through `integration-test`, and to stop before the `post-integration-test` phase when the Docker container is normally shut down and removed. Be aware that you will need to manually stop and remove the container before running the build again, and to make this more convenient we give the PostgreSQL container the alias `database`:
$ docker stop database
$ docker rm database

View File

@ -1,255 +0,0 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>io.debezium</groupId>
<artifactId>debezium-parent</artifactId>
<version>0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>debezium-connector-postgres</artifactId>
<name>Debezium Connector for PostgreSQL</name>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-core</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>connect-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<!-- Testing -->
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-core</artifactId>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-embedded</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-embedded</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
</dependency>
</dependencies>
<properties>
<!--
Specify the properties that will be used for setting up the integration tests' Docker container.
Note that the `dockerhost.ip` property is computed from the IP address of DOCKER_HOST, which will
work on all platforms. We'll set some of these as system properties during integration testing.
-->
<database.port>5432</database.port>
<database.user>postgres</database.user>
<database.password>postgres</database.password>
<!--
By default, we should use the default Docker image. This propery is changed with different profiles.
-->
<docker.image>postgres:${version.postgresql.server}</docker.image>
<docker.skip>false</docker.skip>
</properties>
<build>
<plugins>
<!-- Build a Docker image of our PostgreSQL installation, and run it as a container for our integration tests -->
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<watchInterval>500</watchInterval>
<logDate>default</logDate>
<verbose>true</verbose>
<autoPull>always</autoPull>
<images>
<image>
<name>postgres:${version.postgresql.server}</name>
<alias>database</alias>
<run>
<namingStrategy>alias</namingStrategy>
<volumes>
<bind>
<volume>${project.basedir}/src/test/docker/init:/docker-entrypoint-initdb.d</volume>
<volume>${project.build.directory}/data:/var/lib/postgresql/data</volume>
</bind>
</volumes>
<env>
<POSTGRES_USER>${database.user}</POSTGRES_USER>
<POSTGRES_PASSWORD>${database.password}</POSTGRES_PASSWORD>
</env>
<ports>
<port>${database.port}:5432</port>
</ports>
<log>
<prefix>postgres</prefix>
<enabled>true</enabled>
<color>yellow</color>
</log>
<wait>
<log>PostgreSQL init process complete; ready for start up.</log>
<time>30000</time> <!-- 30 seconds max -->
</wait>
</run>
</image>
</images>
</configuration>
<!--
Connect this plugin to the maven lifecycle around the integration-test phase:
start the container in pre-integration-test and stop it in post-integration-test.
-->
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>build</goal>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<!--
Unlike surefire, the failsafe plugin ensures 'post-integration-test' phase always runs, even
when there are failed integration tests. We rely upon this to always shut down the Docker container
after the integration tests (defined as '*IT.java') are run.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<skipTests>${skipITs}</skipTests>
<enableAssertions>true</enableAssertions>
<systemPropertyVariables>
<!-- Make these available to the tests via system properties -->
<database.hostname>${docker.host.address}</database.hostname>
<database.port>${database.port}</database.port>
<database.user>${database.user}</database.user>
<database.password>${database.password}</database.password>
<skipLongRunningTests>${skipLongRunningTests}</skipLongRunningTests>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
<resources>
<!-- Apply the properties set in the POM to the resource files -->
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<includes>
<include>*</include>
<include>**/*</include>
</includes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
<includes>
<include>*</include>
<include>**/*</include>
</includes>
</testResource>
</testResources>
</build>
<!--
Define several useful profiles
-->
<profiles>
<profile>
<id>assembly</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>default</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${project.artifactId}-${project.version}</finalName>
<attach>true</attach> <!-- we want attach & deploy these to Maven -->
<descriptorRefs>
<descriptorRef>connector-distribution</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Do not perform any Docker-related functionality
To use, specify "-DskipITs" on the Maven command line.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<profile>
<id>skip-integration-tests</id>
<activation>
<activeByDefault>false</activeByDefault>
<property>
<name>skipITs</name>
</property>
</activation>
<properties>
<docker.skip>true</docker.skip>
</properties>
</profile>
</profiles>
</project>

View File

@ -1,15 +0,0 @@
FROM postgres:9.4
MAINTAINER Debezium Community
#
# Add our scripts to the Docker entry point initialization directory
#
COPY init/* /docker-entrypoint-initdb.d/
#
# Changes to the PostgreSQL configuration are made via the `00-alter-conf.sql` file.
#
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["postgres"]

View File

@ -1,4 +0,0 @@
-- Change the system configuration
ALTER SYSTEM SET max_replication_slots = 10;
ALTER SYSTEM SET wal_level = 'logical';

View File

@ -1 +0,0 @@
CREATE DATABASE emptydb;

View File

@ -1,2 +0,0 @@
#!/bin/sh
echo "Hello, test!"

View File

@ -1,27 +0,0 @@
/*
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.connector.postgres;
import java.sql.SQLException;
import org.junit.Test;
public class ConnectionIT {
@Test
public void shouldConnectToDefaulDatabase() throws SQLException {
try (PostgresConnection conn = PostgresConnection.forTestDatabase("postgres");) {
conn.connect();
}
}
@Test
public void shouldConnectToEmptyDatabase() throws SQLException {
try (PostgresConnection conn = PostgresConnection.forTestDatabase("emptydb");) {
conn.connect();
}
}
}

View File

@ -1,60 +0,0 @@
/*
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.connector.postgres;
import io.debezium.config.Configuration;
import io.debezium.jdbc.JdbcConfiguration;
import io.debezium.jdbc.JdbcConnection;
/**
* A utility for integration test cases to connect the PostgreSQL server running in the Docker container created by this
* module's build.
*
* @author Randall Hauch
*/
public class PostgresConnection extends JdbcConnection {
/**
* Obtain a connection instance to the named test database.
*
* @param databaseName the name of the test database
* @return the PostgresConnection instance; never null
*/
public static PostgresConnection forTestDatabase(String databaseName) {
return new PostgresConnection(JdbcConfiguration.copy(Configuration.fromSystemProperties("database."))
.withDatabase(databaseName)
.build());
}
protected static void addDefaults(Configuration.Builder builder) {
builder.withDefault(JdbcConfiguration.HOSTNAME, "localhost")
.withDefault(JdbcConfiguration.PORT, 5432)
.withDefault(JdbcConfiguration.USER, "postgres")
.withDefault(JdbcConfiguration.PASSWORD, "postgres");
}
protected static ConnectionFactory FACTORY = JdbcConnection.patternBasedFactory("jdbc:postgresql://${hostname}:${port}/${dbname}");
/**
* Create a new instance with the given configuration and connection factory.
*
* @param config the configuration; may not be null
*/
public PostgresConnection(Configuration config) {
super(config, FACTORY);
}
/**
* Create a new instance with the given configuration and connection factory, and specify the operations that should be
* run against each newly-established connection.
*
* @param config the configuration; may not be null
* @param initialOperations the initial operations that should be run on each new connection; may be null
*/
public PostgresConnection(Configuration config, Operations initialOperations) {
super(config, FACTORY, initialOperations);
}
}

View File

@ -1,11 +0,0 @@
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %-5p %m (%c)%n
# Root logger option
log4j.rootLogger=INFO, stdout
# Set up the default logging to be INFO level, then override specific units
log4j.logger.io.debezium=INFO

View File

@ -1,61 +0,0 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>io.debezium</groupId>
<artifactId>debezium-parent</artifactId>
<version>0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>debezium-kafka-connect</artifactId>
<name>Debezium Ingest using Kafka Connect</name>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>connect-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>connect-runtime</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>connect-json</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>connect-file</artifactId>
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<!-- Apply the properties set in the POM to the resource files -->
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<includes>
<include>**/build.properties</include>
</includes>
</resource>
</resources>
</build>
</project>