Skip to content
Permalink
Browse files
e2e: add a simple E2E case and set up the workflow (#2166)
* test: rewrite Dockerfile to build from sources on the fly

* test: add a simple test case and set up the workflow
  • Loading branch information
kezhenxu94 committed Jan 10, 2021
1 parent ca31fef commit 6add2e0a4d20972740498789e4b507687d60bbbc
Show file tree
Hide file tree
Showing 10 changed files with 361 additions and 28 deletions.
@@ -0,0 +1,21 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

*
!distribution
@@ -0,0 +1,52 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: E2E Tests

on:
push:
branches:
- master
- 'rel/*'
- test/e2e
paths-ignore:
- 'docs/**'
pull_request:
branches:
- master
- 'rel/*'
- cluster_new
paths-ignore:
- 'docs/**'

jobs:
E2E:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
case:
- cli
steps:
- uses: actions/checkout@v2

- uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build Distribution Zip
run: ./mvnw.sh -B -DskipTests clean package

- name: Build Docker Image
run: |
docker build . -f docker/src/main/Dockerfile -t "iotdb:$GITHUB_SHA"
docker images
- name: Run Test Case ${{ matrix.case }}
run: bash test/e2e/cases/${{ matrix.case }}/run.sh

- name: Clean Up
if: ${{ always() }}
run: bash test/e2e/cases/${{ matrix.case }}/cleanup.sh
@@ -17,37 +17,27 @@
# under the License.
#

# this docker file shows how to build an IoTDB image from IoTDB source codes.
FROM ubuntu:18.04
# docker build context is the root path of the repository

FROM openjdk:11-jre-slim

ADD distribution/target/apache-iotdb-*-bin.zip /

RUN apt update \
&& apt install wget unzip lsof maven thrift-compiler=0.9.1-2.1 -y \
&& wget https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz -O jdk11.tar.gz \
&& tar -xzf jdk11.tar.gz \
&& rm -rf jdk11.tar.gz \
&& export JAVA_HOME=/jdk-11.0.2/ \
&& export PATH="$JAVA_HOME/bin:$PATH" \
&& wget https://github.com/apache/iotdb/archive/master.zip \
&& unzip master.zip \
&& rm master.zip \
&& cd iotdb-master \
&& mvn package -pl server,client -am -Papache-release -DskipTests -Dthrift.download-url="http://www.apache.org/licenses/LICENSE-2.0.txt" -Dthrift.exec.absolute.path="/usr/bin/thrift" \
&& cd target/ \
&& unzip apache-iotdb-0.12.0-SNAPSHOT-bin.zip \
&& mkdir /iotdb \
&& mv apache-iotdb-0.12.0-SNAPSHOT/* /iotdb/ \
&& cd ../../ \
&& mvn clean \
&& ls -lh ~/.m2 \
&& rm -rf ~/.m2 \
&& rm -rf /iotdb-master \
&& sed -i '119d' /iotdb/conf/logback.xml \
&& apt remove wget maven unzip thrift-compiler -y \
&& apt install lsof procps unzip -y \
&& unzip /apache-iotdb-*-bin.zip -d / \
&& rm /apache-iotdb-*-bin.zip \
&& mv /apache-iotdb-* /iotdb \
&& apt remove unzip -y \
&& apt autoremove -y \
&& apt purge --auto-remove -y \
&& apt clean -y
ENV JAVA_HOME "/jdk-11.0.2"
ENV PATH "$JAVA_HOME/bin:$PATH"
&& apt clean -y

EXPOSE 6667
EXPOSE 31999
EXPOSE 5555
EXPOSE 8181
VOLUME /iotdb/data
VOLUME /iotdb/logs
#ENTRYPOINT ["/iotdb/bin/start-server.sh"]
ENV PATH="/iotdb/sbin/:/iotdb/tools/:${PATH}"
ENTRYPOINT ["/iotdb/sbin/start-server.sh"]
@@ -0,0 +1,51 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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: '3.8'

services:
server-prototype:
build:
context: ../../..
dockerfile: docker/src/main/Dockerfile
ports:
- 6667:6667
networks:
iotdb:
healthcheck:
test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/6667" ]
interval: 5s
timeout: 60s
retries: 120

initializer:
build:
context: ../../..
dockerfile: docker/src/main/Dockerfile
networks:
iotdb:
entrypoint:
- bash
- -c
- |
cat /res/init.sql | grep -v '^--' | xargs -I {} /iotdb/sbin/start-cli.sh -h server -e {}
echo "Ready to Run IoTDB E2E Tests"
networks:
iotdb:
@@ -0,0 +1,53 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->

# IoTDB E2E tests cases

Test cases are organized into sub-directories, each of which contains the following files:

* `run.sh`: the entry of the test case.
* `cleanup.sh`: a cleanup script to clean up resources that are created during the test.
* `res`: resources files that will be mounted into the container(s) and be used there.
* `docker-compose.yaml`: orchestrates the services used in the test process.
* `README.md` (Optional): docs or notes when running this case manually.

any other additional files are completely acceptable here, for example, when building
a case to test the JDBC SDK, the files structure may be something like:

```text
.
├── README.md
├── cleanup.sh
├── docker-compose.yaml
├── app <------- Java application that uses JDBC SDK to communicate with IoTDB
│ ├── pom.xml
│ ├── src
│ │ ├── main
│ │ │ └── java
│ │ └── test
│ │ └── java
│ └── src
│ ├── main
│ └── test
├── res
│ └── init.sql
└── run.sh
```
@@ -0,0 +1,24 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->

# Standalone Server Test

The simplest test case that starts up an IoTDB server and verifies that the CLI works.
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

set -x

cd "$(dirname "$0")" || exit 1

docker-compose down

cd - || exit 1
@@ -0,0 +1,41 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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: '3.8'

services:
server:
extends:
file: ../../base/docker-compose.yaml
service: server-prototype
volumes:
- ./res:/resources

initializer:
extends:
service: initializer
file: ../../base/docker-compose.yaml
volumes:
- ./res:/res:ro
depends_on:
server:
condition: service_healthy

networks:
iotdb:
@@ -0,0 +1,26 @@
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you 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.
--

SET STORAGE GROUP TO root.ln;
SHOW STORAGE GROUP;

CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE=FLOAT, ENCODING=PLAIN;

INSERT INTO root.ln.wf01.wt01(timestamp,temperature) values(100, 16);
INSERT INTO root.ln.wf01.wt01(timestamp,temperature) values(200, 26);

0 comments on commit 6add2e0

Please sign in to comment.