Incrementally add more testing infrastructure

This commit is contained in:
Soby Chacko
2018-08-21 17:48:21 -04:00
parent d3d3318c6c
commit 6b2ff28b4b
11 changed files with 168 additions and 12 deletions

View File

@@ -4,7 +4,7 @@ spring:
kafka:
binder:
autoAddPartitions: true
minPartitionCount: 4
minPartitionCount: 3
bindings:
input:
destination: partitioned.destination

View File

@@ -29,7 +29,7 @@ public class Producer {
"f", "g", "h", //making them go to partition-0 by making a single char string
"fo", "go", "ho",
"foo", "goo", "hoo",
"fooz", "gooz", "hooz"
//"fooz", "gooz", "hooz"
};
@InboundChannelAdapter(channel = Source.OUTPUT, poller = @Poller(fixedRate = "1000"))

View File

@@ -7,5 +7,5 @@ spring:
producer:
#payload string length - 1 is the partition where it will get stored
partition-key-expression: headers['partitionKey'] - 1
partition-count: 4
partition-count: 3
required-groups: myGroup #only applicable for rabbit

View File

@@ -5,6 +5,7 @@ metadata:
labels:
app: log
component: log
type: acceptance-tests
spec:
type: LoadBalancer
ports:

View File

@@ -5,6 +5,7 @@ metadata:
labels:
app: time
component: time
type: acceptance-tests
spec:
type: LoadBalancer
ports:

View File

@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: uppercase-transformer-kafka
labels:
app: uppercase-transformer-kafka
type: acceptance-tests
component: uppercase-transformer-kafka
spec:
type: LoadBalancer
ports:
- port: 80
name: uppercase-transformer-kafka-port
targetPort: 8080
protocol: TCP
selector:
app: uppercase-transformer-kafka
type: acceptance-tests
component: uppercase-transformer-kafka

View File

@@ -0,0 +1,43 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: uppercase-transformer-kafka
labels:
app: uppercase-transformer-kafka
type: acceptance-tests
component: uppercase-transformer-kafka
spec:
replicas: 1
template:
metadata:
labels:
app: uppercase-transformer-kafka
type: acceptance-tests
component: uppercase-transformer-kafka
spec:
containers:
- name: uppercase-transformer
image: springcloudstream/uppercase-transformer-kafka:latest
ports:
- containerPort: 8080
env:
- name: SPRING_CLOUD_STREAM_KAFKA_BINDER_BROKERS
value: kafka:9092
- name: SPRING_CLOUD_STREAM_KAFKA_BINDER_ZKNODES
value: kafka-zk:2181
- name: LOGGING_FILE
value: uppercase-transformer-kafka.log
- name: MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE
value: logfile,health,info
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
initialDelaySeconds: 10
periodSeconds: 60
readinessProbe:
httpGet:
path: /actuator/info
port: 8080
initialDelaySeconds: 10
periodSeconds: 10

View File

@@ -135,7 +135,7 @@ echo "Prepare artifacts for ticktock testing"
prepare_ticktock_13_with_rabbit_binder $1 $2 $3 $4 $5 $6
./mvnw -P acceptance-tests clean package -Dtest=TickTockAcceptanceTests -Dmaven.test.skip=false -Dtime.source.route=$FULL_TICKTOCK_TIME_SOURCE_ROUTE -Dlog.sink.route=$FULL_TICKTOCK_LOG_SINK_ROUTE
./mvnw -P acceptance-tests clean package -Dtest=TickTock13AcceptanceTests -Dmaven.test.skip=false -Dtime.source.route=$FULL_TICKTOCK_TIME_SOURCE_ROUTE -Dlog.sink.route=$FULL_TICKTOCK_LOG_SINK_ROUTE
BUILD_RETURN_VALUE=$?
cf stop ticktock-time-source

View File

@@ -69,7 +69,26 @@ function prepare_ticktock_latest_with_kafka_binder() {
FULL_TICKTOCK_LOG_SINK_ROUTE=http://$LOG_SINK_SERVER_URI
}
function delete_ticktock_components() {
function prepare_uppercase_transformer_with_kafka_binder() {
kubectl create -f k8s-templates/uppercase-transformer-kafka.yaml
kubectl create -f k8s-templates/uppercase-transformer-kafka-svc-lb.yaml
READY_FOR_TESTS=1
for i in $( seq 1 "${RETRIES}" ); do
UPPERCASE_TRANSFORMER_KAFKA_SERVER_URI=$(kubectl get service uppercase-transformer-kafka | awk '{print $4}' | grep -v EXTERNAL-IP)
[ '<pending>' != $UPPERCASE_TRANSFORMER_KAFKA_SERVER_URI ] && READY_FOR_TESTS=0 && break
echo "Waiting for server external ip for time source and log sinks. Attempt #$i/${RETRIES}... will try again in [${WAIT_TIME}] seconds" >&2
sleep "${WAIT_TIME}"
done
UPPERCASE_TRANSFORMER_KAFKA_SERVER_URI=$(kubectl get service uppercase-transformer-kafka | awk '{print $4}' | grep -v EXTERNAL-IP)
$(netcat_port ${UPPERCASE_TRANSFORMER_KAFKA_SERVER_URI} 80)
FULL_UPPERCASE_ROUTE=http://$UPPERCASE_TRANSFORMER_KAFKA_SERVER_URI
}
function delete_acceptance_test_components() {
kubectl delete pod,deployment,rc,service -l type="acceptance-tests"
}
@@ -101,14 +120,10 @@ CLUSTER_VERSION=$4
prepare_ticktock_latest_with_kafka_binder ${PROJECT_NAME} ${CLUSTER_NAME} ${GKE_ZONE} ${CLUSTER_VERSION}
./mvnw -P acceptance-tests clean package -Dtest=TickTockAcceptanceTests -Dmaven.test.skip=false -Dtime.source.route=$FULL_TICKTOCK_TIME_SOURCE_ROUTE -Dlog.sink.route=$FULL_TICKTOCK_LOG_SINK_ROUTE
./mvnw -P acceptance-tests 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=$?
delete_ticktock_components
delete_kafka_components
delete_test_cluster ${CLUSTER_NAME} ${GKE_ZONE} ${PROJECT_NAME}
delete_acceptance_test_components
if [ "$BUILD_RETURN_VALUE" != 0 ]
then
@@ -117,9 +132,40 @@ then
echo "Total time: Build took $(($duration / 60)) minutes and $(($duration % 60)) seconds to complete."
delete_kafka_components
delete_test_cluster ${CLUSTER_NAME} ${GKE_ZONE} ${PROJECT_NAME}
exit $BUILD_RETURN_VALUE
fi
prepare_uppercase_transformer_with_kafka_binder
./mvnw -P acceptance-tests clean package -Dtest=UppercaseTransformerAcceptanceTests -Dmaven.test.skip=false -Duppercase.processor.route=$FULL_UPPERCASE_ROUTE
BUILD_RETURN_VALUE=$?
delete_acceptance_test_components
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."
delete_kafka_components
delete_test_cluster ${CLUSTER_NAME} ${GKE_ZONE} ${PROJECT_NAME}
exit $BUILD_RETURN_VALUE
fi
delete_kafka_components
delete_test_cluster ${CLUSTER_NAME} ${GKE_ZONE} ${PROJECT_NAME}
duration=$SECONDS
echo "Cumulative Build Time Across All Tests: Build took $(($duration / 60)) minutes and $(($duration % 60)) seconds to complete."

View File

@@ -23,7 +23,7 @@ import static org.junit.Assert.fail;
/**
* @author Soby Chacko
*/
public class TickTockAcceptanceTests extends AbstractAcceptanceTests {
public class TickTock13AcceptanceTests extends AbstractAcceptanceTests {
@Test
public void testTickTock13Rabbit() {

View File

@@ -0,0 +1,46 @@
/*
* Copyright 2018 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;
public class TickTockLatestAcceptanceTests extends AbstractAcceptanceTests {
@Test
public void testTickTockLatestRabbit() {
String timeSourceUrl = System.getProperty("time.source.route");
String logSinkUrl = System.getProperty("log.sink.route");
boolean foundLogs = waitForLogEntry("Time Source", timeSourceUrl, "Started TimeSource");
if(!foundLogs) {
fail("Did not find the time source started logging message.");
}
foundLogs = waitForLogEntry("Log Sink", logSinkUrl, "Started LogSink");
if(!foundLogs) {
fail("Did not find the log sink started logging message.");
}
foundLogs = waitForLogEntry("Log Sink", logSinkUrl, "TICKTOCK - TIMESTAMP:");
if(!foundLogs) {
fail("Did not find the ticktock messages in log sink");
}
}
}