Skip to content

Commit 6add2e0

Browse files
authored
e2e: add a simple E2E case and set up the workflow (apache#2166)
* test: rewrite Dockerfile to build from sources on the fly * test: add a simple test case and set up the workflow
1 parent ca31fef commit 6add2e0

File tree

10 files changed

+361
-28
lines changed

10 files changed

+361
-28
lines changed

.dockerignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
*
21+
!distribution

.github/workflows/e2e.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This workflow will build a Java project with Maven
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
4+
name: E2E Tests
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
- 'rel/*'
11+
- test/e2e
12+
paths-ignore:
13+
- 'docs/**'
14+
pull_request:
15+
branches:
16+
- master
17+
- 'rel/*'
18+
- cluster_new
19+
paths-ignore:
20+
- 'docs/**'
21+
22+
jobs:
23+
E2E:
24+
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: true
27+
matrix:
28+
case:
29+
- cli
30+
steps:
31+
- uses: actions/checkout@v2
32+
33+
- uses: actions/cache@v2
34+
with:
35+
path: ~/.m2
36+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
37+
restore-keys: ${{ runner.os }}-m2
38+
39+
- name: Build Distribution Zip
40+
run: ./mvnw.sh -B -DskipTests clean package
41+
42+
- name: Build Docker Image
43+
run: |
44+
docker build . -f docker/src/main/Dockerfile -t "iotdb:$GITHUB_SHA"
45+
docker images
46+
47+
- name: Run Test Case ${{ matrix.case }}
48+
run: bash test/e2e/cases/${{ matrix.case }}/run.sh
49+
50+
- name: Clean Up
51+
if: ${{ always() }}
52+
run: bash test/e2e/cases/${{ matrix.case }}/cleanup.sh

docker/src/main/Dockerfile

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,27 @@
1717
# under the License.
1818
#
1919

20-
# this docker file shows how to build an IoTDB image from IoTDB source codes.
21-
FROM ubuntu:18.04
20+
# docker build context is the root path of the repository
21+
22+
FROM openjdk:11-jre-slim
23+
24+
ADD distribution/target/apache-iotdb-*-bin.zip /
25+
2226
RUN apt update \
23-
&& apt install wget unzip lsof maven thrift-compiler=0.9.1-2.1 -y \
24-
&& wget https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz -O jdk11.tar.gz \
25-
&& tar -xzf jdk11.tar.gz \
26-
&& rm -rf jdk11.tar.gz \
27-
&& export JAVA_HOME=/jdk-11.0.2/ \
28-
&& export PATH="$JAVA_HOME/bin:$PATH" \
29-
&& wget https://github.com/apache/iotdb/archive/master.zip \
30-
&& unzip master.zip \
31-
&& rm master.zip \
32-
&& cd iotdb-master \
33-
&& 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" \
34-
&& cd target/ \
35-
&& unzip apache-iotdb-0.12.0-SNAPSHOT-bin.zip \
36-
&& mkdir /iotdb \
37-
&& mv apache-iotdb-0.12.0-SNAPSHOT/* /iotdb/ \
38-
&& cd ../../ \
39-
&& mvn clean \
40-
&& ls -lh ~/.m2 \
41-
&& rm -rf ~/.m2 \
42-
&& rm -rf /iotdb-master \
43-
&& sed -i '119d' /iotdb/conf/logback.xml \
44-
&& apt remove wget maven unzip thrift-compiler -y \
27+
&& apt install lsof procps unzip -y \
28+
&& unzip /apache-iotdb-*-bin.zip -d / \
29+
&& rm /apache-iotdb-*-bin.zip \
30+
&& mv /apache-iotdb-* /iotdb \
31+
&& apt remove unzip -y \
4532
&& apt autoremove -y \
4633
&& apt purge --auto-remove -y \
47-
&& apt clean -y
48-
ENV JAVA_HOME "/jdk-11.0.2"
49-
ENV PATH "$JAVA_HOME/bin:$PATH"
34+
&& apt clean -y
35+
5036
EXPOSE 6667
37+
EXPOSE 31999
38+
EXPOSE 5555
39+
EXPOSE 8181
5140
VOLUME /iotdb/data
5241
VOLUME /iotdb/logs
53-
#ENTRYPOINT ["/iotdb/bin/start-server.sh"]
42+
ENV PATH="/iotdb/sbin/:/iotdb/tools/:${PATH}"
43+
ENTRYPOINT ["/iotdb/sbin/start-server.sh"]

test/e2e/base/docker-compose.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
version: '3.8'
21+
22+
services:
23+
server-prototype:
24+
build:
25+
context: ../../..
26+
dockerfile: docker/src/main/Dockerfile
27+
ports:
28+
- 6667:6667
29+
networks:
30+
iotdb:
31+
healthcheck:
32+
test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/6667" ]
33+
interval: 5s
34+
timeout: 60s
35+
retries: 120
36+
37+
initializer:
38+
build:
39+
context: ../../..
40+
dockerfile: docker/src/main/Dockerfile
41+
networks:
42+
iotdb:
43+
entrypoint:
44+
- bash
45+
- -c
46+
- |
47+
cat /res/init.sql | grep -v '^--' | xargs -I {} /iotdb/sbin/start-cli.sh -h server -e {}
48+
echo "Ready to Run IoTDB E2E Tests"
49+
50+
networks:
51+
iotdb:

test/e2e/cases/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<!--
2+
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
20+
-->
21+
22+
# IoTDB E2E tests cases
23+
24+
Test cases are organized into sub-directories, each of which contains the following files:
25+
26+
* `run.sh`: the entry of the test case.
27+
* `cleanup.sh`: a cleanup script to clean up resources that are created during the test.
28+
* `res`: resources files that will be mounted into the container(s) and be used there.
29+
* `docker-compose.yaml`: orchestrates the services used in the test process.
30+
* `README.md` (Optional): docs or notes when running this case manually.
31+
32+
any other additional files are completely acceptable here, for example, when building
33+
a case to test the JDBC SDK, the files structure may be something like:
34+
35+
```text
36+
.
37+
├── README.md
38+
├── cleanup.sh
39+
├── docker-compose.yaml
40+
├── app <------- Java application that uses JDBC SDK to communicate with IoTDB
41+
│ ├── pom.xml
42+
│ ├── src
43+
│ │ ├── main
44+
│ │ │ └── java
45+
│ │ └── test
46+
│ │ └── java
47+
│ └── src
48+
│ ├── main
49+
│ └── test
50+
├── res
51+
│ └── init.sql
52+
└── run.sh
53+
```

test/e2e/cases/cli/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!--
2+
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
20+
-->
21+
22+
# Standalone Server Test
23+
24+
The simplest test case that starts up an IoTDB server and verifies that the CLI works.

test/e2e/cases/cli/cleanup.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
21+
set -x
22+
23+
cd "$(dirname "$0")" || exit 1
24+
25+
docker-compose down
26+
27+
cd - || exit 1
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
version: '3.8'
21+
22+
services:
23+
server:
24+
extends:
25+
file: ../../base/docker-compose.yaml
26+
service: server-prototype
27+
volumes:
28+
- ./res:/resources
29+
30+
initializer:
31+
extends:
32+
service: initializer
33+
file: ../../base/docker-compose.yaml
34+
volumes:
35+
- ./res:/res:ro
36+
depends_on:
37+
server:
38+
condition: service_healthy
39+
40+
networks:
41+
iotdb:

test/e2e/cases/cli/res/init.sql

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--
2+
-- Licensed to the Apache Software Foundation (ASF) under one
3+
-- or more contributor license agreements. See the NOTICE file
4+
-- distributed with this work for additional information
5+
-- regarding copyright ownership. The ASF licenses this file
6+
-- to you under the Apache License, Version 2.0 (the
7+
-- "License"); you may not use this file except in compliance
8+
-- with the License. You may obtain a copy of the License at
9+
--
10+
-- http://www.apache.org/licenses/LICENSE-2.0
11+
--
12+
-- Unless required by applicable law or agreed to in writing,
13+
-- software distributed under the License is distributed on an
14+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
-- KIND, either express or implied. See the License for the
16+
-- specific language governing permissions and limitations
17+
-- under the License.
18+
--
19+
20+
SET STORAGE GROUP TO root.ln;
21+
SHOW STORAGE GROUP;
22+
23+
CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE=FLOAT, ENCODING=PLAIN;
24+
25+
INSERT INTO root.ln.wf01.wt01(timestamp,temperature) values(100, 16);
26+
INSERT INTO root.ln.wf01.wt01(timestamp,temperature) values(200, 26);

0 commit comments

Comments
 (0)