diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml deleted file mode 100644 index 3b01a75..0000000 --- a/.github/workflows/gradle.yml +++ /dev/null @@ -1,34 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle - -name: Java CI with Gradle - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -permissions: - contents: read - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'temurin' - - name: Build with Gradle - uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 - with: - arguments: build diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml new file mode 100644 index 0000000..30eed7d --- /dev/null +++ b/.github/workflows/integration-tests.yml @@ -0,0 +1,42 @@ +name: Build and Test + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + - name: Build + run: make build + - name: Create K8s Kind Cluster + uses: helm/kind-action@v1.4.0 + with: + cluster_name: 'kind' + - name: Load Docker Images + run: | + kind load docker-image hoptimator + kind load docker-image hoptimator-flink-runner + - name: Deploy Dev Environment + run: make deploy-dev-environment + - name: Deploy Hoptimator + run: make deploy deploy-samples + - name: Wait for Readiness + run: kubectl wait pod hoptimator --for condition=Ready --timeout=5m || kubectl describe pod hoptimator + - name: Integration Tests + run: make integration-tests + diff --git a/Dockerfile b/Dockerfile index 5bdd23d..45f9252 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ COPY ./hoptimator-cli/run.sh ./hoptimator COPY ./hoptimator-operator/run.sh ./hoptimator-operator COPY ./hoptimator-cli/build/libs/hoptimator-cli-all.jar ./hoptimator-cli-all.jar COPY ./hoptimator-operator/build/libs/hoptimator-operator-all.jar ./hoptimator-operator-all.jar +COPY ./etc/* ./ COPY ./test-model.yaml ./test-model.yaml ENTRYPOINT ["/bin/sh", "-c"] CMD ["./hoptimator"] diff --git a/Makefile b/Makefile index 55db66f..12ff7e6 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,12 @@ build: docker build . -t hoptimator docker build hoptimator-flink-runner -t hoptimator-flink-runner +bounce: build undeploy deploy deploy-samples + +integration-tests: + ./bin/hoptimator --run=./integration-tests.sql + echo "\nPASS" + clean: ./gradlew clean @@ -23,4 +29,10 @@ deploy-dev-environment: deploy: kubectl apply -f ./deploy/ -.PHONY: build clean quickstart deploy-dev-environment deploy +undeploy: + kubectl delete -f ./deploy || echo "skipping" + +deploy-samples: + kubectl apply -f ./deploy/samples + +.PHONY: build clean quickstart deploy-dev-environment deploy deploy-samples integration-tests diff --git a/bin/hoptimator b/bin/hoptimator index 27baf53..cf6d655 100755 --- a/bin/hoptimator +++ b/bin/hoptimator @@ -1,5 +1,5 @@ #!/bin/sh docker build . -t hoptimator -kubectl exec -it hoptimator -c hoptimator -- ./hoptimator +kubectl exec -it hoptimator -c hoptimator -- ./hoptimator -n "" -p "" -u "jdbc:calcite:model=./test-model.yaml" "$@" diff --git a/deploy/hoptimator-pod.yaml b/deploy/hoptimator-pod.yaml index 8b2c9b2..b6b3725 100644 --- a/deploy/hoptimator-pod.yaml +++ b/deploy/hoptimator-pod.yaml @@ -8,3 +8,8 @@ spec: image: docker.io/library/hoptimator imagePullPolicy: Never command: ["sleep", "infinity"] + readinessProbe: + exec: + command: ["./hoptimator", "--run=./readiness-probe.sql"] + timeoutSeconds: 30 + diff --git a/etc/integration-tests.sql b/etc/integration-tests.sql new file mode 100644 index 0000000..007c5ea --- /dev/null +++ b/etc/integration-tests.sql @@ -0,0 +1,10 @@ + +!connect "jdbc:calcite:model=./test-model.yaml" "" "" + +!set maxWidth 80 +!table +!schemas + +SELECT * FROM DATAGEN.PERSON; +SELECT * FROM DATAGEN.COMPANY; + diff --git a/etc/readiness-probe.sql b/etc/readiness-probe.sql new file mode 100644 index 0000000..007c5ea --- /dev/null +++ b/etc/readiness-probe.sql @@ -0,0 +1,10 @@ + +!connect "jdbc:calcite:model=./test-model.yaml" "" "" + +!set maxWidth 80 +!table +!schemas + +SELECT * FROM DATAGEN.PERSON; +SELECT * FROM DATAGEN.COMPANY; + diff --git a/hoptimator-cli/run.sh b/hoptimator-cli/run.sh index 94f0e53..09df9ea 100755 --- a/hoptimator-cli/run.sh +++ b/hoptimator-cli/run.sh @@ -6,7 +6,7 @@ if [[ -f "$JAR" ]]; then java \ --add-opens java.base/java.lang=ALL-UNNAMED \ --add-opens java.base/java.util=ALL-UNNAMED \ - -jar $JAR --verbose=true -n "" -p "" -u "jdbc:calcite:model=./test-model.yaml" + -jar $JAR --verbose=true "$@" else echo "jar file not found; maybe forgot to build?" fi