Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): added basic smoke test making sure everything starts OK #31

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 74 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions: read-all

jobs:
build:
uses: miracum/.github/.github/workflows/standard-build.yaml@e86b05b914141334811d43d0973c95cec61bb729 # v1.4.6
uses: miracum/.github/.github/workflows/standard-build.yaml@f9d64a7dbe928557fde9f96defa3e372bc0eaf21 # v1.6.1
permissions:
contents: read
id-token: write
Expand All @@ -26,8 +26,79 @@ jobs:
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}

test:
name: run k8s smoke test
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'pull_request' }}
needs:
- build
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Create KinD cluster
uses: helm/kind-action@99576bfa6ddf9a8e612d83b513da5a75875caced # v1.9.0
with:
cluster_name: kind

- name: Download image
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
name: ${{ needs.build.outputs.image-slug }}
path: /tmp

- name: Load image into KinD
run: |
kind load image-archive /tmp/image.tar

- name: List images in cluster
run: docker exec kind-control-plane crictl images

- name: Install test chart
env:
IMAGE_TAG: ${{ needs.build.outputs.image-version }}
run: |
helm dep up tests/k8s

# start by first installing the Strimzi and Prometheus operators
helm upgrade --install \
--set "stream-processors.enabled=false" \
--set "stream-processors.processors.obds-to-fhir.container.image.tag=${IMAGE_TAG}" \
--wait \
--timeout=10m \
obds-to-fhir-test \
tests/k8s

# install the actual obds-to-fhir stream processor
helm upgrade --install \
--set "stream-processors.enabled=true" \
--set "stream-processors.processors.obds-to-fhir.container.image.tag=${IMAGE_TAG}" \
--wait \
--timeout=10m \
obds-to-fhir-test \
tests/k8s

- name: Run Helm test to make sure everything started correctly
run: |
helm test obds-to-fhir-test

- name: Print cluster logs
if: always()
run: |
kubectl cluster-info dump -o yaml | tee kind-cluster-dump.txt

- name: Upload cluster dump
if: always()
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: kind-cluster-dump.txt
path: |
kind-cluster-dump.txt

lint:
uses: miracum/.github/.github/workflows/standard-lint.yaml@e86b05b914141334811d43d0973c95cec61bb729 # v1.4.6
uses: miracum/.github/.github/workflows/standard-lint.yaml@f9d64a7dbe928557fde9f96defa3e372bc0eaf21 # v1.6.1
permissions:
contents: read
pull-requests: write
Expand All @@ -41,7 +112,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}

release:
uses: miracum/.github/.github/workflows/standard-release.yaml@e86b05b914141334811d43d0973c95cec61bb729 # v1.4.6
uses: miracum/.github/.github/workflows/standard-release.yaml@f9d64a7dbe928557fde9f96defa3e372bc0eaf21 # v1.6.1
needs:
- build
permissions:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/schedule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions: read-all

jobs:
schedule:
uses: miracum/.github/.github/workflows/standard-schedule.yaml@e86b05b914141334811d43d0973c95cec61bb729 # v1.4.6
uses: miracum/.github/.github/workflows/standard-schedule.yaml@f9d64a7dbe928557fde9f96defa3e372bc0eaf21 # v1.6.1
permissions:
contents: read
issues: write
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ bin
fhirpkg.lock.json

*.received.fhir.json

tests/k8s/**/charts
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
src/test/java/snapshots/**
tests/k8s/**/templates
4 changes: 3 additions & 1 deletion .yamllint → .yamllint.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---

extends: default

rules:
document-start: disable
line-length: disable

ignore: |
tests/k8s/**/templates
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ dependencies {
implementation 'org.apache.kafka:kafka-streams'
implementation 'org.springframework.cloud:spring-cloud-stream'
implementation 'org.springframework.cloud:spring-cloud-stream-binder-kafka-streams'
implementation "org.springframework.boot:spring-boot-starter-actuator"
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "ca.uhn.hapi.fhir:hapi-fhir-structures-r4:${hapiVersion}"
implementation 'io.micrometer:micrometer-registry-prometheus:1.12.2'
implementation 'io.micrometer:micrometer-core:1.12.2'
Expand Down
18 changes: 1 addition & 17 deletions deploy/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.7"

services:
oracle2:
image: docker.miracum.org/oracle/database:19.3.0-se2
image: harbor.miracum.org/oracle/database:19.3.0-se2
hostname: oracle2
ports:
- "1521:1521"
Expand Down Expand Up @@ -39,21 +39,6 @@ services:
depends_on:
- zoo1

kafka-rest-proxy:
image: confluentinc/cp-kafka-rest:7.5.3@sha256:a4558632cad6c4eedd8bc340a30277ab020b4fd97444844df1be0dbf9061782d
hostname: kafka-rest-proxy
ports:
- "8082:8082"
environment:
# KAFKA_REST_ZOOKEEPER_CONNECT: zoo1:2181
KAFKA_REST_LISTENERS: http://0.0.0.0:8082/
KAFKA_REST_SCHEMA_REGISTRY_URL: http://kafka-schema-registry:8081/
KAFKA_REST_HOST_NAME: kafka-rest-proxy
KAFKA_REST_BOOTSTRAP_SERVERS: PLAINTEXT://kafka1:19092
depends_on:
- zoo1
- kafka1

kafka-connect:
image: confluentinc/cp-kafka-connect:7.5.3@sha256:e6bc1b88b43a23de290da574b0bbc06135b0005ecb9cac0c95155d3ff50f283a
hostname: kafka-connect
Expand All @@ -80,7 +65,6 @@ services:
depends_on:
- zoo1
- kafka1
- kafka-rest-proxy

akhq:
image: tchiotludo/akhq:0.24.0
Expand Down
17 changes: 17 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,20 @@ spring:
key-store-password: ${SSL_KEY_STORE_PASSWORD}
producer:
compression-type: gzip

management:
endpoint:
health:
show-details: always
probes:
enabled: true
add-additional-paths: true
endpoints:
web:
exposure:
include: "health,prometheus"
health:
livenessstate:
enabled: true
readinessstate:
enabled: true
12 changes: 12 additions & 0 deletions tests/k8s/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
dependencies:
- name: stream-processors
repository: oci://ghcr.io/miracum/charts
version: 1.6.1
- name: strimzi-kafka-operator
repository: oci://quay.io/strimzi-helm
version: 0.40.0
- name: kube-prometheus-stack
repository: oci://ghcr.io/prometheus-community/charts
version: 57.0.3
digest: sha256:c3e7f5ed93a6ac74b481eacebb57b683a410808b4c2be3f41436914e3b0d1a82
generated: "2024-03-18T15:26:37.617325079+01:00"
18 changes: 18 additions & 0 deletions tests/k8s/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v2
name: obds-to-fhir-test
type: application
description: Simple smoke test for deploying obds-to-fhir on K8s.
deprecated: false
kubeVersion: ">= 1.21.0"
dependencies:
- name: kube-prometheus-stack
repository: oci://ghcr.io/prometheus-community/charts
version: 57.0.3
- name: stream-processors
repository: oci://ghcr.io/miracum/charts
version: 1.6.1
- name: strimzi-kafka-operator
repository: oci://quay.io/strimzi-helm
version: 0.40.0
version: 0.0.0
appVersion: 0.0.0
49 changes: 49 additions & 0 deletions tests/k8s/templates/kafka-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaNodePool
metadata:
name: dual-role
labels:
strimzi.io/cluster: obds-to-fhir-kafka
spec:
replicas: 1
roles:
- controller
- broker
storage:
type: jbod
volumes:
- id: 0
type: persistent-claim
size: 8Gi
deleteClaim: false
---
apiVersion: kafka.strimzi.io/v1beta2
kind: Kafka
metadata:
name: obds-to-fhir-kafka
annotations:
strimzi.io/node-pools: enabled
strimzi.io/kraft: enabled
spec:
kafka:
version: 3.7.0
metadataVersion: 3.7-IV4
listeners:
- name: tls
port: 9093
type: internal
tls: true
config:
offsets.topic.replication.factor: 1
transaction.state.log.replication.factor: 1
transaction.state.log.min.isr: 1
num.partitions: 1
auto.create.topics.enable: true
default.replication.factor: 1
log.cleanup.policy: compact
# 30 MiB
message.max.bytes: 31457280
# https://kafka.apache.org/documentation/#brokerconfigs_compression.type
compression.type: gzip
entityOperator:
userOperator: {}
48 changes: 48 additions & 0 deletions tests/k8s/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{- $streamProcessorsFullName := (include "stream-processors.fullname" (index .Subcharts "stream-processors")) -}}
apiVersion: v1
kind: Pod
metadata:
name: "{{ .Release.Name }}-test-connection"
annotations:
helm.sh/hook: test-success
spec:
restartPolicy: Never
containers:
- name: probe-health-endpoint
image: "{{ .Values.curl.image.registry }}/{{ .Values.curl.image.repository }}:{{ .Values.curl.image.tag }}"
imagePullPolicy: IfNotPresent
command: ["curl", "--fail-with-body"]
args: ["http://{{ $streamProcessorsFullName }}-obds-to-fhir-metrics:8080/actuator/health"]
{{- with $.Values.restrictedContainerSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tests.resources }}
resources:
{{- toYaml . | nindent 8 }}
{{- end }}
livenessProbe:
exec:
command: ["true"]
readinessProbe:
exec:
command: ["true"]
- name: probe-metrics-endpoint
image: "{{ .Values.curl.image.registry }}/{{ .Values.curl.image.repository }}:{{ .Values.curl.image.tag }}"
imagePullPolicy: IfNotPresent
command: ["curl", "--fail-with-body"]
args: ["http://{{ $streamProcessorsFullName }}-obds-to-fhir-metrics:8080/actuator/prometheus"]
{{- with $.Values.restrictedContainerSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tests.resources }}
resources:
{{- toYaml . | nindent 8 }}
{{- end }}
livenessProbe:
exec:
command: ["true"]
readinessProbe:
exec:
command: ["true"]
Loading
Loading