Skip to content

Commit

Permalink
[Improvement] Make travis scripts more robust (#1082)
Browse files Browse the repository at this point in the history
* [Improvement] Make travis scripts more robust

* fix...

* more logs, longer timeout
  • Loading branch information
mproch committed Jul 22, 2020
1 parent 00e08d8 commit 1177920
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
10 changes: 2 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,5 @@ jobs:
- node -v
- npm -v
script:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin;
- ./ciBuildDocker.sh --version=${BUILD_VERSION} --docker-publish-type=publishLocal --add-dev-model=$ADD_DEV_MODEL
- cd ./demo/docker && echo "NUSSKNACKER_VERSION=$BUILD_VERSION" > .env && ./testQuickstart.sh
- docker push ${DOCKER_SOURCE_TAG}
- docker tag ${DOCKER_SOURCE_TAG} ${DOCKER_REPOSITORY}:${SANITIZED_TRAVIS_BRANCH}-latest
- docker push ${DOCKER_REPOSITORY}:${SANITIZED_TRAVIS_BRANCH}-latest
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then docker tag ${DOCKER_SOURCE_TAG} ${DOCKER_REPOSITORY}:demo-latest; fi
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then docker push ${DOCKER_REPOSITORY}:demo-latest; fi
#We use separate script, as travis does not stop after command error: https://github.com/travis-ci/travis-ci/issues/1066
- ./.travis/buildPushDocker.sh
11 changes: 11 additions & 0 deletions .travis/buildPushDocker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
set -e

echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin;
./ciBuildDocker.sh --version=${BUILD_VERSION} --docker-publish-type=publishLocal --add-dev-model=$ADD_DEV_MODEL
cd ./demo/docker && echo "NUSSKNACKER_VERSION=$BUILD_VERSION" > .env && ./testQuickstart.sh
docker push ${DOCKER_SOURCE_TAG}
docker tag ${DOCKER_SOURCE_TAG} ${DOCKER_REPOSITORY}:${SANITIZED_TRAVIS_BRANCH}-latest
docker push ${DOCKER_REPOSITORY}:${SANITIZED_TRAVIS_BRANCH}-latest
if [[ "$TRAVIS_BRANCH" == "master" ]]; then docker tag ${DOCKER_SOURCE_TAG} ${DOCKER_REPOSITORY}:demo-latest; fi
if [[ "$TRAVIS_BRANCH" == "master" ]]; then docker push ${DOCKER_REPOSITORY}:demo-latest; fi
2 changes: 2 additions & 0 deletions demo/docker/docker-compose-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ services:
- "8081:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
restart: on-failure
depends_on:
- zookeeper
- influxdb
Expand All @@ -184,6 +185,7 @@ services:
- kibana
- grafana


volumes:
nussknacker_storage_zookeeper_datalog:
nussknacker_storage_zookeeper_data:
Expand Down
15 changes: 9 additions & 6 deletions demo/docker/testQuickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ trap 'docker-compose -f docker-compose.yml -f docker-compose-env.yml kill && doc
#TODO: Consider rewriting below, e.g. in Python
waitTime=0
sleep=10
waitLimit=120

checkCode() {
echo "$(curl -s -o /dev/null -w "%{http_code}" "http://admin:admin@localhost:8081/$1")"
Expand All @@ -25,8 +26,9 @@ waitForOK() {

URL_PATH=$1
STATUS_CODE=$(checkCode "$URL_PATH")
CONTAINER_FOR_LOGS=$4

while [[ $waitTime < 60 && $STATUS_CODE != 200 ]]
while [[ $waitTime -lt $waitLimit && $STATUS_CODE != 200 ]]
do
sleep $sleep
waitTime=$((waitTime+sleep))
Expand All @@ -40,11 +42,12 @@ waitForOK() {
if [[ $STATUS_CODE != 200 ]]
then
echo "$3"
docker-compose -f docker-compose-env.yml -f docker-compose.yml logs --tail=200 $CONTAINER_FOR_LOGS
exit 1
fi
}

waitForOK "api/processes" "Checking Frontend API response.." "Frontend not started"
waitForOK "api/processes" "Checking Frontend API response.." "Frontend not started" "app"

echo "Creating process"
CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST "http://admin:admin@localhost:8081/api/processes/DetectLargeTransactions/FraudDetection?isSubprocess=false")
Expand All @@ -57,13 +60,13 @@ else
exit 1
fi

waitForOK "api/processes/status" "Checking connect with Flink.." "Frontend not connected with flink"
waitForOK "api/processes/status" "Checking connect with Flink.." "Frontend not connected with flink" "app"

waitForOK "flink/" "Checking Flink response.." "Flink not started"
waitForOK "flink/" "Checking Flink response.." "Flink not started" "jobmanager"

waitForOK "metrics" "Checking Grafana response.." "Grafana not started"
waitForOK "metrics" "Checking Grafana response.." "Grafana not started" "grafana"

waitForOK "search" "Checking Kibana response.." "Kibana not started"
waitForOK "search" "Checking Kibana response.." "Kibana not started" "kibana"

#TODO:
#check import process
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class GenericItSpec extends FunSuite with BeforeAndAfterAll with Matchers with K
import org.apache.flink.streaming.api.scala._
import spel.Implicits._

private val secondsToWaitForAvro = 30

override lazy val config: Config = ConfigFactory.load()
.withValue("kafka.kafkaAddress", fromAnyRef(kafkaZookeeperServer.kafkaAddress))
.withValue("kafka.kafkaProperties.\"schema.registry.url\"", fromAnyRef("not_used"))
Expand Down Expand Up @@ -176,7 +178,7 @@ class GenericItSpec extends FunSuite with BeforeAndAfterAll with Matchers with K
"#input.list2[0] != 15")
run(validJsonProcess) {
val consumer = kafkaClient.createConsumer()
val processed = consumer.consume(JsonOutTopic).map(_.message()).map(new String(_, StandardCharsets.UTF_8)).take(1).toList
val processed = consumer.consume(JsonOutTopic, secondsToWaitForAvro).map(_.message()).map(new String(_, StandardCharsets.UTF_8)).take(1).toList
processed.map(parseJson) shouldEqual List(parseJson(givenMatchingJsonObj))
}
}
Expand Down Expand Up @@ -242,7 +244,7 @@ class GenericItSpec extends FunSuite with BeforeAndAfterAll with Matchers with K
logger.info("Starting union process")
run(process) {
logger.info("Waiting for consumer")
val consumer = kafkaClient.createConsumer().consume(topicOut, 20)
val consumer = kafkaClient.createConsumer().consume(topicOut, secondsToWaitForAvro)
logger.info("Waiting for messages")
val processed = consumer.map(_.message()).map(new String(_, StandardCharsets.UTF_8)).take(2).toList
processed.map(parseJson) should contain theSameElementsAs List(
Expand Down Expand Up @@ -309,7 +311,7 @@ class GenericItSpec extends FunSuite with BeforeAndAfterAll with Matchers with K

private def consumeOneAvroMessage(topic: String) = {
val consumer = kafkaClient.createConsumer()
consumer.consume(topic).map { record =>
consumer.consume(topic, secondsToWaitForAvro).map { record =>
valueDeserializer.deserialize(topic, record.message())
}.take(1).toList
}
Expand Down

0 comments on commit 1177920

Please sign in to comment.