diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f7ab5a5 --- /dev/null +++ b/.github/dependabot.yml @@ -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" \ No newline at end of file diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index c42e4e3..291f290 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -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: @@ -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 @@ -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×pan=-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 diff --git a/Dockerfile b/Dockerfile index 7a33b0a..d0401d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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. @@ -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} diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..677afcc --- /dev/null +++ b/test.sh @@ -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×pan=-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" \ No newline at end of file