From f4c8387d14d96c6368e3623115504541642a52a7 Mon Sep 17 00:00:00 2001 From: Jack Date: Thu, 18 Apr 2024 09:29:43 +0800 Subject: [PATCH] acc tests are working --- .github/workflows/ci-cd.yml | 22 ++++++++- .../Dockerfile | 47 ------------------- .../Dockerfile-startup.sh | 20 -------- .../athena-example-acceptance-tests/README.md | 18 +++++-- .../docker-compose.yml | 34 -------------- .../mysql-init.sql | 29 ------------ 6 files changed, 35 insertions(+), 135 deletions(-) delete mode 100644 athena-examples/athena-example-acceptance-tests/Dockerfile delete mode 100755 athena-examples/athena-example-acceptance-tests/Dockerfile-startup.sh delete mode 100644 athena-examples/athena-example-acceptance-tests/docker-compose.yml delete mode 100644 athena-examples/athena-example-acceptance-tests/mysql-init.sql diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 94fb3e34a..474b16d39 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -73,9 +73,27 @@ jobs: push: true tags: jack20191124/athena-example-books:latest + acceptance-tests: + name: Run example acceptance tests + needs: examples-basic-app-docker-image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up JDK + uses: QubitPi/hashicorp-aws/.github/actions/jdk-setup@master + - name: Start Book example application Docker Compose + run: docker compose up + working-directory: cd athena/athena-examples/athena-example-books/ + - name: Wait until Docker Compose is up + uses: iFaxity/wait-on-action + with: + resource: http://localhost:8080/v1/metadata/graphql?query={metaData(fileId:%221%22){fileName}} + - name: Run acceptance tests + run: mvn clean verify + documentation: name: Test Documentation Build & Deploy Documentation to GitHub Pages - needs: tests + needs: acceptance-tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -106,7 +124,7 @@ jobs: release: name: Release Athena to Maven Central - needs: tests + needs: acceptance-tests if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest steps: diff --git a/athena-examples/athena-example-acceptance-tests/Dockerfile b/athena-examples/athena-example-acceptance-tests/Dockerfile deleted file mode 100644 index 94c94773e..000000000 --- a/athena-examples/athena-example-acceptance-tests/Dockerfile +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright Jiaqi Liu -# -# 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. -FROM ubuntu:22.04 - -LABEL maintainer="Jiaqi (Jack) Liu" -LABEL maintainer-email="jack20220723@gmail.com" - -ARG WS_VERSION=1.0-SNAPSHOT - -ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk-amd64 - -ENV JETTY_VERSION 11.0.15 -ENV JETTY_BASE /jetty-base -ENV JETTY_HOME /jetty-home-$JETTY_VERSION -ENV JETTY_WEBAPPS_DIR $JETTY_BASE/webapps - -RUN apt update -RUN apt upgrade -y -RUN apt install software-properties-common -y -RUN apt install wget - -# Install JDK 17 - https://www.rosehosting.com/blog/how-to-install-java-17-lts-on-ubuntu-20-04/ -RUN apt update -y -RUN apt install openjdk-17-jdk -y - -# Install and configure Jetty (for JDK 17) container -RUN wget https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/$JETTY_VERSION/jetty-home-$JETTY_VERSION.tar.gz -RUN tar -xzvf jetty-home-$JETTY_VERSION.tar.gz -RUN rm jetty-home-$JETTY_VERSION.tar.gz -RUN mkdir jetty-base -RUN cd jetty-base && java -jar $JETTY_HOME/start.jar --add-module=annotations,server,http,deploy,servlet,webapp,resources,jsp - -COPY ./target/athena-example-books-$WS_VERSION.war $JETTY_WEBAPPS_DIR/ROOT.war - -COPY ./Dockerfile-startup.sh /Dockerfile-startup.sh -CMD [ "/Dockerfile-startup.sh" ] diff --git a/athena-examples/athena-example-acceptance-tests/Dockerfile-startup.sh b/athena-examples/athena-example-acceptance-tests/Dockerfile-startup.sh deleted file mode 100755 index 97aa9b5f1..000000000 --- a/athena-examples/athena-example-acceptance-tests/Dockerfile-startup.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -set -x -set -e - -# Copyright Jiaqi Liu -# -# 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. - -cd $JETTY_BASE -java -jar $JETTY_HOME/start.jar diff --git a/athena-examples/athena-example-acceptance-tests/README.md b/athena-examples/athena-example-acceptance-tests/README.md index c9fd69630..51f785aa3 100644 --- a/athena-examples/athena-example-acceptance-tests/README.md +++ b/athena-examples/athena-example-acceptance-tests/README.md @@ -1,12 +1,24 @@ Athena Acceptance Test Framework ================================ +![Cucumber Badge][Cucumber Badge] + Athena acceptance test framework is a slightly modified BDD, which [eliminates the QA](https://spectrum.ieee.org/yahoos-engineers-move-to-coding-without-a-net) -To run all acceptance tests, run +The acceptances tests runs against the +[book example application](https://github.com/QubitPi/athena/tree/master/athena-examples/athena-example-books), which +can be brought up using its dedicated Docker Compose: + +```console +cd athena/athena-examples/athena-example-books/ +docker compose up +``` -```bash -cd athena-acceptance-tests/ +Then run all acceptance tests with + +```console mvn clean verify ``` + +[Cucumber Badge]: https://img.shields.io/badge/Cucumber-23D96C?style=for-the-badge&logo=cucumber&logoColor=white diff --git a/athena-examples/athena-example-acceptance-tests/docker-compose.yml b/athena-examples/athena-example-acceptance-tests/docker-compose.yml deleted file mode 100644 index d18a018ca..000000000 --- a/athena-examples/athena-example-acceptance-tests/docker-compose.yml +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright Jiaqi Liu -# -# 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: "3.9" -services: - web: - build: . - ports: - - "8080:8080" - depends_on: - db: - condition: service_healthy - db: - image: "mysql:5.7" - ports: - - "3306:3306" - volumes: - - "./mysql-init.sql:/docker-entrypoint-initdb.d/mysql-init.sql" - environment: - MYSQL_ROOT_PASSWORD: root - healthcheck: - test: mysqladmin ping -h localhost -u root -proot - timeout: 3s - retries: 3 diff --git a/athena-examples/athena-example-acceptance-tests/mysql-init.sql b/athena-examples/athena-example-acceptance-tests/mysql-init.sql deleted file mode 100644 index 43cab2151..000000000 --- a/athena-examples/athena-example-acceptance-tests/mysql-init.sql +++ /dev/null @@ -1,29 +0,0 @@ --- Copyright Jiaqi Liu --- --- 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. - -CREATE DATABASE IF NOT EXISTS Athena; -USE Athena; - -CREATE TABLE BOOK_META_DATA ( - id int NOT NULL AUTO_INCREMENT, - file_id VARCHAR(255) NOT NULL, - file_name VARCHAR(255) NOT NULL, - file_type VARCHAR(8) NOT NULL, - PRIMARY KEY (id) -); - --- Predefined test data -INSERT INTO BOOK_META_DATA (file_id, file_name, file_type) VALUES ('1', 'Harry Potter', 'PDF'); -INSERT INTO BOOK_META_DATA (file_id, file_name, file_type) VALUES ('2', 'Moby Dick', 'PDF'); -INSERT INTO BOOK_META_DATA (file_id, file_name, file_type) VALUES ('3', 'Interview with the vampire', 'PDF');