CF AT for jdbc | log

This commit is contained in:
Soby Chacko
2019-02-08 18:48:58 -05:00
parent 2a1d749e90
commit 3cdd4d67aa
4 changed files with 334 additions and 182 deletions

View File

@@ -0,0 +1,15 @@
---
applications:
- name: jdbc-log-sink-rabbit
host: jdbc-log-sink-rabbit
memory: 2G
disk_quota: 2G
instances: 1
path: /tmp/log-sink-rabbit.jar
env:
LOGGING_FILE: jdbclogsinkrabbit.log
MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE: logfile,health,info
SPRING_CLOUD_STREAMAPP_SECURITY_ENABLED: false
SPRING_CLOUD_STREAM_BINDINGS_INPUT_DESTINATION: fromjdbcsource
services:
- scst-rabbit

View File

@@ -0,0 +1,19 @@
---
applications:
- name: jdbc-source-rabbit
host: jdbc-source-rabbit
memory: 2G
disk_quota: 2G
instances: 1
path: /tmp/jdbc-source-rabbit.jar
env:
LOGGING_FILE: jdbcsourcerabbit.log
MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE: logfile,health,info
SPRING_CLOUD_STREAMAPP_SECURITY_ENABLED: false
SPRING_CLOUD_STREAM_BINDINGS_OUTPUT_DESTINATION: fromjdbcsource
JDBC_QUERY: 'select id, name, tag from test order by id'
SPRING_DATASOURCE_INITIALIZATION-MODE: ALWAYS
SPRING_DATASOURCE_SCHEMA: https://raw.githubusercontent.com/spring-cloud/spring-cloud-stream-acceptance-tests/master/db-scripts/sample-schema.sql
services:
- scst-rabbit
- scst-mysql

View File

@@ -16,6 +16,36 @@ popd () {
command popd "$@" > /dev/null
}
function prepare_jdbc_log_with_rabbit_binder() {
wget -O /tmp/jdbc-source-rabbit.jar http://repo.spring.io/snapshot/org/springframework/cloud/stream/app/jdbc-source-rabbit/2.1.0.BUILD-SNAPSHOT/jdbc-source-rabbit-2.1.0.BUILD-SNAPSHOT.jar
wget -O /tmp/log-sink-rabbit.jar http://repo.spring.io/snapshot/org/springframework/cloud/stream/app/log-sink-rabbit/2.1.0.BUILD-SNAPSHOT/log-sink-rabbit-2.1.0.BUILD-SNAPSHOT.jar
if [ $6 == "skip-ssl-validation" ]
then
cf login -a $1 --skip-ssl-validation -u $2 -p $3 -o $4 -s $5
else
cf login -a $1 -u $2 -p $3 -o $4 -s $5
fi
cf push -f ./cf-manifests/jdbc-source-manifest.yml
cf app jdbc-source-rabbit > /tmp/jdbc-source-route.txt
JDBC_SOURCE_ROUTE=`grep routes /tmp/jdbc-source-route.txt | awk '{ print $2 }'`
FULL_JDBC_SOURCE_ROUTE=http://$JDBC_SOURCE_ROUTE
cf push -f ./cf-manifests/jdbc-log-sink-manifest.yml
cf app jdbc-log-sink-rabbit > /tmp/jdbc-log-sink-route.txt
JDBC_LOG_SINK_ROUTE=`grep routes /tmp/jdbc-log-sink-route.txt | awk '{ print $2 }'`
FULL_JDBC_LOG_SINK_ROUTE=http://$JDBC_LOG_SINK_ROUTE
}
function prepare_http_transform_log_with_rabbit_binder() {
wget -O /tmp/http-source-rabbit.jar http://repo.spring.io/snapshot/org/springframework/cloud/stream/app/http-source-rabbit/2.1.0.BUILD-SNAPSHOT/http-source-rabbit-2.1.0.BUILD-SNAPSHOT.jar
@@ -56,7 +86,6 @@ function prepare_http_transform_log_with_rabbit_binder() {
FULL_HTTPTRANSFORM_LOG_SINK_ROUTE=http://$HTTPTRANSFORM_LOG_SINK_ROUTE
}
function prepare_http_splitter_log_with_rabbit_binder() {
wget -O /tmp/http-source-rabbit.jar http://repo.spring.io/snapshot/org/springframework/cloud/stream/app/http-source-rabbit/2.1.0.BUILD-SNAPSHOT/http-source-rabbit-2.1.0.BUILD-SNAPSHOT.jar
@@ -233,29 +262,26 @@ function prepare_partitioning_test_with_rabbit_binder() {
SECONDS=0
echo "Prepare artifacts for http | transform | log testing"
echo "Prepare artifacts for jdbc | log testing"
prepare_http_transform_log_with_rabbit_binder $1 $2 $3 $4 $5 $6
prepare_jdbc_log_with_rabbit_binder $1 $2 $3 $4 $5 $6
pushd ../spring-cloud-stream-acceptance-tests
../mvnw clean package -Dtest=HttpTransformLogAcceptanceTests -Dmaven.test.skip=false -Dhttp.source.route=$FULL_HTTP_SOURCE_ROUTE -Dtransform.processor.route=$FULL_TRANSFORM_PROCESSOR_ROUTE -Dlog.sink.route=$FULL_HTTPTRANSFORM_LOG_SINK_ROUTE
../mvnw clean package -Dtest=JdbcLogAcceptanceTests -Dmaven.test.skip=false -Djdbc.source.route=$FULL_JDBC_SOURCE_ROUTE -Dlog.sink.route=$FULL_JDBC_LOG_SINK_ROUTE
BUILD_RETURN_VALUE=$?
popd
cf stop http-source-rabbit && cf delete http-source-rabbit -f
cf stop transform-processor-rabbit && cf delete splitter-processor-rabbit -f
cf stop log-sink-rabbit && cf delete log-sink-rabbit -f
cf stop jdbc-source-rabbit && cf delete jdbc-source-rabbit -f
cf stop jdbc-log-sink-rabbit && cf delete jdbc-log-sink-rabbit -f
cf logout
rm /tmp/http-source-route.txt
rm /tmp/transform-processor-route.txt
rm /tmp/httptransform-log-sink-route.txt
rm /tmp/jdbc-source-route.txt
rm /tmp/jdbc-log-sink-route.txt
rm /tmp/http-source-rabbit.jar
rm /tmp/transform-processor-rabbit.jar
rm /tmp/jdbc-source-rabbit.jar
rm /tmp/log-sink-rabbit.jar
if [ "$BUILD_RETURN_VALUE" != 0 ]
@@ -268,177 +294,213 @@ then
exit $BUILD_RETURN_VALUE
fi
echo "Prepare artifacts for http | splitter | log testing"
prepare_http_splitter_log_with_rabbit_binder $1 $2 $3 $4 $5 $6
pushd ../spring-cloud-stream-acceptance-tests
../mvnw clean package -Dtest=HttpSplitterLogAcceptanceTests -Dmaven.test.skip=false -Dhttp.source.route=$FULL_HTTP_SOURCE_ROUTE -Dsplitter.processor.route=$FULL_SPLITTER_PROCESSOR_ROUTE -Dlog.sink.route=$FULL_HTTPSPLITTER_LOG_SINK_ROUTE
BUILD_RETURN_VALUE=$?
popd
cf stop http-source-rabbit
cf stop splitter-processor-rabbit
cf stop log-sink-rabbit
cf delete http-source-rabbit -f
cf delete splitter-processor-rabbit -f
cf delete log-sink-rabbit -f
cf logout
rm /tmp/http-source-route.txt
rm /tmp/splitter-processor-route.txt
rm /tmp/httpsplitter-log-sink-route.txt
rm /tmp/http-source-rabbit.jar
rm /tmp/splitter-processor-rabbit.jar
rm /tmp/log-sink-rabbit.jar
if [ "$BUILD_RETURN_VALUE" != 0 ]
then
echo "Early exit due to test failure in ticktock tests"
duration=$SECONDS
echo "Total time: Build took $(($duration / 60)) minutes and $(($duration % 60)) seconds to complete."
exit $BUILD_RETURN_VALUE
fi
echo "Prepare artifacts for ticktock testing"
prepare_ticktock_latest_with_rabbit_binder $1 $2 $3 $4 $5 $6
pushd ../spring-cloud-stream-acceptance-tests
../mvnw clean package -Dtest=TickTockLatestAcceptanceTests -Dmaven.test.skip=false -Dtime.source.route=$FULL_TICKTOCK_TIME_SOURCE_ROUTE -Dlog.sink.route=$FULL_TICKTOCK_LOG_SINK_ROUTE
BUILD_RETURN_VALUE=$?
popd
cf stop ticktock-time-source
cf stop ticktock-log-sink
cf delete ticktock-time-source -f
cf delete ticktock-log-sink -f
cf logout
rm /tmp/ticktock-time-source-route.txt
rm /tmp/ticktock-log-sink-route.txt
rm /tmp/ticktock-time-source.jar
rm /tmp/ticktock-log-sink.jar
if [ "$BUILD_RETURN_VALUE" != 0 ]
then
echo "Early exit due to test failure in ticktock tests"
duration=$SECONDS
echo "Total time: Build took $(($duration / 60)) minutes and $(($duration % 60)) seconds to complete."
exit $BUILD_RETURN_VALUE
fi
echo "Prepare artifacts for ticktock1.3.1 testing"
prepare_ticktock_13_with_rabbit_binder $1 $2 $3 $4 $5 $6
pushd ../spring-cloud-stream-acceptance-tests
../mvnw clean package -Dtest=TickTock13AcceptanceTests -Dmaven.test.skip=false -Dtime.source.route=$FULL_TICKTOCK_TIME_SOURCE_ROUTE_131 -Dlog.sink.route=$FULL_TICKTOCK_LOG_SINK_ROUTE_131
BUILD_RETURN_VALUE=$?
popd
cf stop ticktock-time-source131
cf stop ticktock-log-sink131
cf delete ticktock-time-source131 -f
cf delete ticktock-log-sink131 -f
cf logout
rm /tmp/ticktock-time-source-route131.txt
rm /tmp/ticktock-log-sink-route131.txt
rm /tmp/ticktock-time-source131.jar
rm /tmp/ticktock-log-sink131.jar
if [ "$BUILD_RETURN_VALUE" != 0 ]
then
echo "Early exit due to test failure in ticktock tests"
duration=$SECONDS
echo "Total time: Build took $(($duration / 60)) minutes and $(($duration % 60)) seconds to complete."
exit $BUILD_RETURN_VALUE
fi
echo "Prepare artifacts for uppercase transformer testing"
prepare_uppercase_transformer_with_rabbit_binder $1 $2 $3 $4 $5 $6
pushd ../spring-cloud-stream-acceptance-tests
../mvnw clean package -Dtest=UppercaseTransformerAcceptanceTests -Dmaven.test.skip=false -Duppercase.processor.route=$FULL_UPPERCASE_ROUTE
BUILD_RETURN_VALUE=$?
popd
cf stop uppercase-transformer
cf delete uppercase-transformer -f
cf logout
rm /tmp/uppercase-route.txt
rm /tmp/uppercase-transformer-rabbit.jar
if [ "$BUILD_RETURN_VALUE" != 0 ]
then
echo "Early exit due to test failure in uppercase transformer"
duration=$SECONDS
echo "Total time: Build took $(($duration / 60)) minutes and $(($duration % 60)) seconds to complete."
exit $BUILD_RETURN_VALUE
fi
echo "Prepare artifacts for partitions testing"
prepare_partitioning_test_with_rabbit_binder $1 $2 $3 $4 $5 $6
pushd ../spring-cloud-stream-acceptance-tests
../mvnw clean package -Dtest=PartitioningAcceptanceTests -Dmaven.test.skip=false -Duppercase.processor.route=$FULL_UPPERCASE_ROUTE -Dpartitioning.producer.route=$FULL_PARTITIONING_PRODUCER_ROUTE -Dpartitioning.consumer1.route=$FULL_PARTITIONING_CONSUMER1_ROUTE -Dpartitioning.consumer2.route=$FULL_PARTITIONING_CONSUMER2_ROUTE -Dpartitioning.consumer3.route=$FULL_PARTITIONING_CONSUMER3_ROUTE
BUILD_RETURN_VALUE=$?
popd
cf stop partitioning-producer
cf stop partitioning-consumer1
cf stop partitioning-consumer2
cf stop partitioning-consumer3
cf delete partitioning-producer -f
cf delete partitioning-consumer1 -f
cf delete partitioning-consumer2 -f
cf delete partitioning-consumer3 -f
cf logout
rm /tmp/part-producer-route.txt
rm /tmp/part-consumer1-route.txt
rm /tmp/part-consumer2-route.txt
rm /tmp/part-consumer3-route.txt
rm /tmp/partitioning-producer-rabbit.jar
rm /tmp/partitioning-consumer-rabbit.jar
#echo "Prepare artifacts for http | transform | log testing"
#
#prepare_http_transform_log_with_rabbit_binder $1 $2 $3 $4 $5 $6
#
#pushd ../spring-cloud-stream-acceptance-tests
#
#../mvnw clean package -Dtest=HttpTransformLogAcceptanceTests -Dmaven.test.skip=false -Dhttp.source.route=$FULL_HTTP_SOURCE_ROUTE -Dtransform.processor.route=$FULL_TRANSFORM_PROCESSOR_ROUTE -Dlog.sink.route=$FULL_HTTPTRANSFORM_LOG_SINK_ROUTE
#BUILD_RETURN_VALUE=$?
#
#popd
#
#cf stop http-source-rabbit && cf delete http-source-rabbit -f
#cf stop transform-processor-rabbit && cf delete splitter-processor-rabbit -f
#cf stop log-sink-rabbit && cf delete log-sink-rabbit -f
#
#cf logout
#
#rm /tmp/http-source-route.txt
#rm /tmp/transform-processor-route.txt
#rm /tmp/httptransform-log-sink-route.txt
#
#rm /tmp/http-source-rabbit.jar
#rm /tmp/transform-processor-rabbit.jar
#rm /tmp/log-sink-rabbit.jar
#
#if [ "$BUILD_RETURN_VALUE" != 0 ]
#then
# echo "Early exit due to test failure in ticktock tests"
# duration=$SECONDS
#
# echo "Total time: Build took $(($duration / 60)) minutes and $(($duration % 60)) seconds to complete."
#
# exit $BUILD_RETURN_VALUE
#fi
#
#echo "Prepare artifacts for http | splitter | log testing"
#
#prepare_http_splitter_log_with_rabbit_binder $1 $2 $3 $4 $5 $6
#
#pushd ../spring-cloud-stream-acceptance-tests
#
#../mvnw clean package -Dtest=HttpSplitterLogAcceptanceTests -Dmaven.test.skip=false -Dhttp.source.route=$FULL_HTTP_SOURCE_ROUTE -Dsplitter.processor.route=$FULL_SPLITTER_PROCESSOR_ROUTE -Dlog.sink.route=$FULL_HTTPSPLITTER_LOG_SINK_ROUTE
#BUILD_RETURN_VALUE=$?
#
#popd
#
#cf stop http-source-rabbit
#cf stop splitter-processor-rabbit
#cf stop log-sink-rabbit
#
#cf delete http-source-rabbit -f
#cf delete splitter-processor-rabbit -f
#cf delete log-sink-rabbit -f
#
#cf logout
#
#rm /tmp/http-source-route.txt
#rm /tmp/splitter-processor-route.txt
#rm /tmp/httpsplitter-log-sink-route.txt
#
#rm /tmp/http-source-rabbit.jar
#rm /tmp/splitter-processor-rabbit.jar
#rm /tmp/log-sink-rabbit.jar
#
#if [ "$BUILD_RETURN_VALUE" != 0 ]
#then
# echo "Early exit due to test failure in ticktock tests"
# duration=$SECONDS
#
# echo "Total time: Build took $(($duration / 60)) minutes and $(($duration % 60)) seconds to complete."
#
# exit $BUILD_RETURN_VALUE
#fi
#
#echo "Prepare artifacts for ticktock testing"
#
#prepare_ticktock_latest_with_rabbit_binder $1 $2 $3 $4 $5 $6
#
#pushd ../spring-cloud-stream-acceptance-tests
#
#../mvnw clean package -Dtest=TickTockLatestAcceptanceTests -Dmaven.test.skip=false -Dtime.source.route=$FULL_TICKTOCK_TIME_SOURCE_ROUTE -Dlog.sink.route=$FULL_TICKTOCK_LOG_SINK_ROUTE
#BUILD_RETURN_VALUE=$?
#
#popd
#
#cf stop ticktock-time-source
#cf stop ticktock-log-sink
#
#cf delete ticktock-time-source -f
#cf delete ticktock-log-sink -f
#
#cf logout
#
#rm /tmp/ticktock-time-source-route.txt
#rm /tmp/ticktock-log-sink-route.txt
#
#rm /tmp/ticktock-time-source.jar
#rm /tmp/ticktock-log-sink.jar
#
#if [ "$BUILD_RETURN_VALUE" != 0 ]
#then
# echo "Early exit due to test failure in ticktock tests"
# duration=$SECONDS
#
# echo "Total time: Build took $(($duration / 60)) minutes and $(($duration % 60)) seconds to complete."
#
# exit $BUILD_RETURN_VALUE
#fi
#
#
#echo "Prepare artifacts for ticktock1.3.1 testing"
#
#prepare_ticktock_13_with_rabbit_binder $1 $2 $3 $4 $5 $6
#
#pushd ../spring-cloud-stream-acceptance-tests
#
#../mvnw clean package -Dtest=TickTock13AcceptanceTests -Dmaven.test.skip=false -Dtime.source.route=$FULL_TICKTOCK_TIME_SOURCE_ROUTE_131 -Dlog.sink.route=$FULL_TICKTOCK_LOG_SINK_ROUTE_131
#BUILD_RETURN_VALUE=$?
#
#popd
#
#cf stop ticktock-time-source131
#cf stop ticktock-log-sink131
#
#cf delete ticktock-time-source131 -f
#cf delete ticktock-log-sink131 -f
#
#cf logout
#
#rm /tmp/ticktock-time-source-route131.txt
#rm /tmp/ticktock-log-sink-route131.txt
#
#rm /tmp/ticktock-time-source131.jar
#rm /tmp/ticktock-log-sink131.jar
#
#if [ "$BUILD_RETURN_VALUE" != 0 ]
#then
# echo "Early exit due to test failure in ticktock tests"
# duration=$SECONDS
#
# echo "Total time: Build took $(($duration / 60)) minutes and $(($duration % 60)) seconds to complete."
#
# exit $BUILD_RETURN_VALUE
#fi
#
#echo "Prepare artifacts for uppercase transformer testing"
#
#prepare_uppercase_transformer_with_rabbit_binder $1 $2 $3 $4 $5 $6
#
#pushd ../spring-cloud-stream-acceptance-tests
#
#../mvnw clean package -Dtest=UppercaseTransformerAcceptanceTests -Dmaven.test.skip=false -Duppercase.processor.route=$FULL_UPPERCASE_ROUTE
#BUILD_RETURN_VALUE=$?
#
#popd
#
#cf stop uppercase-transformer
#
#cf delete uppercase-transformer -f
#
#cf logout
#
#rm /tmp/uppercase-route.txt
#
#rm /tmp/uppercase-transformer-rabbit.jar
#
#if [ "$BUILD_RETURN_VALUE" != 0 ]
#then
# echo "Early exit due to test failure in uppercase transformer"
# duration=$SECONDS
#
# echo "Total time: Build took $(($duration / 60)) minutes and $(($duration % 60)) seconds to complete."
#
# exit $BUILD_RETURN_VALUE
#fi
#
#echo "Prepare artifacts for partitions testing"
#
#prepare_partitioning_test_with_rabbit_binder $1 $2 $3 $4 $5 $6
#
#pushd ../spring-cloud-stream-acceptance-tests
#
#../mvnw clean package -Dtest=PartitioningAcceptanceTests -Dmaven.test.skip=false -Duppercase.processor.route=$FULL_UPPERCASE_ROUTE -Dpartitioning.producer.route=$FULL_PARTITIONING_PRODUCER_ROUTE -Dpartitioning.consumer1.route=$FULL_PARTITIONING_CONSUMER1_ROUTE -Dpartitioning.consumer2.route=$FULL_PARTITIONING_CONSUMER2_ROUTE -Dpartitioning.consumer3.route=$FULL_PARTITIONING_CONSUMER3_ROUTE
#BUILD_RETURN_VALUE=$?
#
#popd
#
#cf stop partitioning-producer
#cf stop partitioning-consumer1
#cf stop partitioning-consumer2
#cf stop partitioning-consumer3
#
#cf delete partitioning-producer -f
#cf delete partitioning-consumer1 -f
#cf delete partitioning-consumer2 -f
#cf delete partitioning-consumer3 -f
#
#cf logout
#
#rm /tmp/part-producer-route.txt
#rm /tmp/part-consumer1-route.txt
#rm /tmp/part-consumer2-route.txt
#rm /tmp/part-consumer3-route.txt
#
#rm /tmp/partitioning-producer-rabbit.jar
#rm /tmp/partitioning-consumer-rabbit.jar
duration=$SECONDS

View File

@@ -0,0 +1,56 @@
/*
* Copyright 2019 the original author or authors.
*
* 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 sample.acceptance.tests;
import org.junit.Test;
import static org.junit.Assert.fail;
/**
* @author Soby Chacko
*/
public class JdbcLogAcceptanceTests extends AbstractAcceptanceTests {
@Test
public void testHttpTransformLog() {
String jdbcSourceUrl = System.getProperty("jdbc.source.route");
String logSinkUrl = System.getProperty("log.sink.route");
boolean foundLogs = waitForLogEntry("JDBC Source", jdbcSourceUrl, "Started JdbcSource");
if(!foundLogs) {
fail("Did not find the jdbc source started logging message.");
}
foundLogs = waitForLogEntry("Log Sink", logSinkUrl, "Started LogSink");
if(!foundLogs) {
fail("Did not find the log sink started logging message.");
}
verifyLogs(logSinkUrl, "{\"id\":1,\"name\":\"Bob\",\"tag\":null}");
verifyLogs(logSinkUrl, "{\"id\":2,\"name\":\"Jane\",\"tag\":null}");
verifyLogs(logSinkUrl, "{\"id\":3,\"name\":\"John\",\"tag\":null}");
}
void verifyLogs(String appUrl, String textToLookfor) {
boolean foundMessage = waitForLogEntry("Log Sink", appUrl, textToLookfor);
if (!foundMessage) {
fail("Did not find the message - " + textToLookfor + " - in the logs");
}
}
}