Skip to content

Commit

Permalink
Merge pull request #72 from steven-gueguen/master
Browse files Browse the repository at this point in the history
Add test for in_memory mode
  • Loading branch information
stggn authored Jan 6, 2021
2 parents 2b3d9bd + fdc3360 commit fd357a9
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 32 deletions.
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Copyright 2021 SenX S.A.S.
#
# 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.
#

version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
54 changes: 24 additions & 30 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#
# Copyright 2020-2021 SenX S.A.S.
#
# 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.
#

name: Build Warp 10 docker image

on:
Expand All @@ -18,11 +34,11 @@ jobs:

- name: Set tag
if: startsWith(github.ref, 'refs/tags/')
run: echo "::set-env name=TAG::${GITHUB_REF#refs/tags/}"
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Set fake tag
if: startsWith(github.ref, 'refs/tags/') == false
run: echo "::set-env name=TAG::${GITHUB_RUN_ID}"
run: echo "TAG=${GITHUB_RUN_ID}" >> $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
Expand All @@ -44,35 +60,13 @@ jobs:
load: true
tags: ${{ secrets.DOCKER_USERNAME }}/warp10:${{ env.TAG }}-test

- name: Test the new image
- name: Test the new image, default mode
run: |
./test.sh "docker run -d -p 8080:8080 -p 8081:8081 ${{ secrets.DOCKER_USERNAME }}/warp10:${TAG}-test"
- name: Test the new image, in_memory mode
run: |
echo "Run docker image"
docker run --name testing-${TAG} -d -p 8080:8080 -p 8081:8081 ${{ secrets.DOCKER_USERNAME }}/warp10:${TAG}-test
sleep 10
echo "Get tokens"
READ_TOKEN=$(docker exec -i $(docker ps -q --filter "name=testing-${TAG}") tail -n 1 /opt/warp10/etc/initial.tokens | sed -e 's/{"read":{"token":"//' -e 's/".*//')
WRITE_TOKEN=$(docker exec -i $(docker ps -q --filter "name=testing-${TAG}") tail -n 1 /opt/warp10/etc/initial.tokens | sed -e 's/.*,"write":{"token":"//' -e 's/".*//')
echo "Write data"
curl -s -H "X-Warp10-Token: ${WRITE_TOKEN}" http://127.0.0.1:8080/api/v0/update --data-binary '// test{} 42'
echo "Read data"
res=$(curl -s "http://127.0.0.1:8080/api/v0/fetch?token=${READ_TOKEN}&selector=~.*\{\}&now=now&timespan=-1" | cut -d ' ' -f3)
echo ${res}
if [[ "${res}" != "42" ]]; then
echo "Failed to compare write data with read data"
exit 1
fi
echo "Test WarpStudio"
res=$(curl -Is http://127.0.0.1:8081/ | head -1)
if [[ "${res%?}" != "HTTP/1.1 200 OK" ]]; then
echo "Failed to test WarpStudio URL"
echo "Curl result: ${res}"
echo $(docker ps -a)
exit 1
fi
./test.sh "docker run -d -p 8080:8080 -p 8081:8081 -e IN_MEMORY=true ${{ secrets.DOCKER_USERNAME }}/warp10:${TAG}-test"
- name: Build the main image
uses: docker/build-push-action@v2
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2020 SenX S.A.S.
# Copyright 2016-2021 SenX S.A.S.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,7 +30,7 @@ ENV WARP10_VOLUME=/data \
SENSISION_HOME=/opt/sensision \
SENSISION_DATA_DIR=/data/sensision

ARG WARP10_VERSION=2.7.1
ARG WARP10_VERSION=2.7.2
ARG WARP10_URL=https://dl.bintray.com/senx/generic/io/warp10/warp10/${WARP10_VERSION}
ENV WARP10_VERSION=${WARP10_VERSION}

Expand Down
56 changes: 56 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
#
# Copyright 2021 SenX S.A.S.
#
# 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.
#

#CMD=docker run -d -p 8080:8080 -p 8081:8081 ${{ secrets.DOCKER_USERNAME }}/warp10:${TAG}-test
CMD=$1

echo "Run docker image"
id=$(${CMD})

echo "Wait fo container to start-up"
sleep 10

echo "Get tokens"
READ_TOKEN=$(docker exec -i ${id} tail -n 1 /opt/warp10/etc/initial.tokens | sed -e 's/{"read":{"token":"//' -e 's/".*//')
WRITE_TOKEN=$(docker exec -i ${id} tail -n 1 /opt/warp10/etc/initial.tokens | sed -e 's/.*,"write":{"token":"//' -e 's/".*//')

echo "Write data"
curl -s -H "X-Warp10-Token: ${WRITE_TOKEN}" http://127.0.0.1:8080/api/v0/update --data-binary '// test{} 42'

echo "Read data"
res=$(curl -s "http://127.0.0.1:8080/api/v0/fetch?token=${READ_TOKEN}&selector=~.*\{\}&now=now&timespan=-1" | cut -d ' ' -f3)
if [[ "${res}" != "42" ]]; then
echo "Failed to compare write data with read data"
echo "Value read: ${res}"
docker stop ${id}
exit 1
fi

echo "Test WarpStudio"
res=$(curl -Is http://127.0.0.1:8081/ | head -1)
if [[ "${res%?}" != "HTTP/1.1 200 OK" ]]; then
echo "Failed to test WarpStudio URL"
echo "Curl result: ${res}"
echo $(docker ps -a)
docker stop ${id}
exit 1
fi

echo "Stop container"
docker stop ${id}

echo "Test successful"

0 comments on commit fd357a9

Please sign in to comment.