CF AT for http | splitter | log

Each of the apps are run as standalone and then verify in the
log sink that we see the results
This commit is contained in:
Soby Chacko
2019-02-01 17:24:24 -05:00
parent 5f74d4afb1
commit 4df84b089e
5 changed files with 201 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
---
applications:
- name: http-source-rabbit
host: http-source-rabbit
memory: 2G
disk_quota: 2G
instances: 1
path: /tmp/http-source-rabbit.jar
env:
LOGGING_FILE: httpsourcerabbit.log
MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE: logfile,health,info
SPRING_CLOUD_STREAMAPP_SECURITY_ENABLED: false
SPRING_CLOUD_STREAM_BINDINGS_OUTPUT_DESTINATION: fromhttpsource
services:
- scst-rabbit

View File

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

View File

@@ -0,0 +1,17 @@
---
applications:
- name: splitter-processor-rabbit
host: splitter-processor-rabbit
memory: 2G
disk_quota: 2G
instances: 1
path: /tmp/splitter-processor-rabbit.jar
env:
LOGGING_FILE: splitterprocessorrabbit.log
MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE: logfile,health,info
SPRING_CLOUD_STREAMAPP_SECURITY_ENABLED: false
SPRING_CLOUD_STREAM_BINDINGS_INPUT_DESTINATION: fromhttpsource
SPRING_CLOUD_STREAM_BINDINGS_OUTPUT_DESTINATION: fromsplitter
SPLITTER_EXPRESSION: "payload.split(' ')"
services:
- scst-rabbit

View File

@@ -16,6 +16,46 @@ popd () {
command popd "$@" > /dev/null
}
function prepare_http_splitter_log_with_rabbit_binder() {
wget -O /tmp/http-source.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
wget -O /tmp/splitter-processor.jar http://repo.spring.io/snapshot/org/springframework/cloud/stream/app/splitter-processor-rabbit/2.1.0.BUILD-SNAPSHOT/splitter-processor-rabbit-2.1.0.BUILD-SNAPSHOT.jar
wget -O /tmp/httpsplitter-log-sink.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/http-source-manifest.yml
cf app http-source-rabbit > /tmp/http-source-route.txt
HTTP_SOURCE_ROUTE=`grep routes /tmp/http-source-route.txt | awk '{ print $2 }'`
FULL_HTTP_SOURCE_ROUTE=http://$HTTP_SOURCE_ROUTE
cf push -f ./cf-manifests/splitter-processor-manifest.yml
cf app splitter-processor-rabbit > /tmp/splitter-processor-route.txt
SPLITTER_PROCESSOR_ROUTE=`grep routes /tmp/splitter-processor-route.txt | awk '{ print $2 }'`
FULL_SPLITTER_PROCESSOR_ROUTE=http://$SPLITTER_PROCESSOR_ROUTE
cf push -f ./cf-manifests/httpsplitter-log-sink-manifest.yml
cf app log-sink-rabbit > /tmp/httpsplitter-log-sink-route.txt
HTTPSPLITTER_LOG_SINK_ROUTE=`grep routes /tmp/httpsplitter-log-sink-route.txt | awk '{ print $2 }'`
FULL_HTTPSPLITTER_LOG_SINK_ROUTE=http://$HTTPSPLITTER_LOG_SINK_ROUTE
}
function prepare_ticktock_latest_with_rabbit_binder() {
wget -O /tmp/ticktock-time-source.jar http://repo.spring.io/snapshot/org/springframework/cloud/stream/app/time-source-rabbit/2.1.0.BUILD-SNAPSHOT/time-source-rabbit-2.1.0.BUILD-SNAPSHOT.jar
@@ -152,6 +192,42 @@ function prepare_partitioning_test_with_rabbit_binder() {
SECONDS=0
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 httpsplitter-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
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

View File

@@ -0,0 +1,78 @@
/*
* 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 org.springframework.web.client.RestTemplate;
import static org.junit.Assert.fail;
/**
* @author Soby Chacko
*/
public class HttpSplitterLogAcceptanceTests extends AbstractAcceptanceTests {
@Test
public void testHttpSplitterLog() {
String httpSourceUrl = System.getProperty("http.source.route");
String splitterProcessorUrl = System.getProperty("splitter.processor.route");
String logSinkUrl = System.getProperty("log.sink.route");
boolean foundLogs = waitForLogEntry("HTTP Source", httpSourceUrl, "Started HttpSource");
if(!foundLogs) {
fail("Did not find the http source started logging message.");
}
foundLogs = waitForLogEntry("Splitter Processor", splitterProcessorUrl, "Started SplitterProcessor");
if(!foundLogs) {
fail("Did not find the splitter processor started logging message.");
}
foundLogs = waitForLogEntry("Log Sink", logSinkUrl, "Started LogSink");
if(!foundLogs) {
fail("Did not find the log sink started logging message.");
}
RestTemplate restTemplate = new RestTemplate();
restTemplate.postForObject(
httpSourceUrl,
"how much wood would a woodchuck chuck if that woodchuck could chuck wood", String.class);
verifyLogs(logSinkUrl, ": how");
verifyLogs(logSinkUrl, ": much");
verifyLogs(logSinkUrl, ": wood");
verifyLogs(logSinkUrl, ": a");
verifyLogs(logSinkUrl, ": woodchuck");
verifyLogs(logSinkUrl, ": chuck");
verifyLogs(logSinkUrl, ": if");
verifyLogs(logSinkUrl, ": that");
verifyLogs(logSinkUrl, ": woodchuck");
verifyLogs(logSinkUrl, ": could");
verifyLogs(logSinkUrl, ": chuck");
verifyLogs(logSinkUrl, ": wood");
}
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");
}
}
}