From 02b9dee253ac937b6cd4a43c78dddeb905c221c8 Mon Sep 17 00:00:00 2001 From: ranchodeluxe Date: Thu, 8 Jun 2023 19:40:43 -0700 Subject: [PATCH 1/6] add fixtures --- .github/workflows/ci.yml | 13 +- .github/workflows/helm-tests.yml | 24 ++ helm-chart/eoapi/.gitignore | 1 + helm-chart/eoapi/helm-template.sh | 1 + .../eoapi/initdb-data}/my_data.sql | 0 .../initdb-data}/noaa-emergency-response.json | 0 .../initdb-data}/noaa-eri-nashville2020.json | 0 helm-chart/eoapi/templates/db/configmap.yaml | 32 ++ helm-chart/eoapi/templates/db/deployment.yaml | 34 +- helm-chart/eoapi/templates/db/secrets.yaml | 2 +- helm-chart/eoapi/tests/db_tests.yaml | 43 ++ helm-chart/eoapi/tmp/eoapi-manfests.yaml | 383 ------------------ helm-chart/eoapi/values.yaml | 5 +- 13 files changed, 136 insertions(+), 402 deletions(-) create mode 100644 .github/workflows/helm-tests.yml create mode 100644 helm-chart/eoapi/.gitignore mode change 100644 => 100755 helm-chart/eoapi/helm-template.sh rename {.github/workflows/data => helm-chart/eoapi/initdb-data}/my_data.sql (100%) rename {.github/workflows/data => helm-chart/eoapi/initdb-data}/noaa-emergency-response.json (100%) rename {.github/workflows/data => helm-chart/eoapi/initdb-data}/noaa-eri-nashville2020.json (100%) create mode 100644 helm-chart/eoapi/templates/db/configmap.yaml delete mode 100644 helm-chart/eoapi/tmp/eoapi-manfests.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02264b1c..e1718406 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,16 +9,5 @@ on: - '*' pull_request: -jobs: - helm-tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: d3adb5/helm-unittest-action@v2 - with: - helm-version: v3.8.2 - github-token: ${{ secrets.GITHUB_TOKEN }} - - run: | - cd helm-chart - helm unittest eoapi -f 'tests/*.yaml' -v eoapi/required-test-values.yaml +jobs: {} diff --git a/.github/workflows/helm-tests.yml b/.github/workflows/helm-tests.yml new file mode 100644 index 00000000..65f579c0 --- /dev/null +++ b/.github/workflows/helm-tests.yml @@ -0,0 +1,24 @@ +name: CI + +# On every pull request, but only on push to main +on: + push: + branches: + - '*' + tags: + - '*' + pull_request: + +jobs: + helm-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: d3adb5/helm-unittest-action@v2 + with: + helm-version: v3.8.2 + github-token: ${{ secrets.GITHUB_TOKEN }} + - run: | + cd helm-chart + helm unittest eoapi -f 'tests/*.yaml' -v eoapi/required-test-values.yaml + diff --git a/helm-chart/eoapi/.gitignore b/helm-chart/eoapi/.gitignore new file mode 100644 index 00000000..c0363794 --- /dev/null +++ b/helm-chart/eoapi/.gitignore @@ -0,0 +1 @@ +tmp/ \ No newline at end of file diff --git a/helm-chart/eoapi/helm-template.sh b/helm-chart/eoapi/helm-template.sh old mode 100644 new mode 100755 index 46990d1b..d499bf26 --- a/helm-chart/eoapi/helm-template.sh +++ b/helm-chart/eoapi/helm-template.sh @@ -5,6 +5,7 @@ export PGPASSWORD=password export POSTGRES_PASSWORD=password export GITSHA=$(git rev-parse HEAD | cut -c1-10) +mkdir -p tmp MANIFEST=./tmp/eoapi-manfests.yaml echo "" > $MANIFEST diff --git a/.github/workflows/data/my_data.sql b/helm-chart/eoapi/initdb-data/my_data.sql similarity index 100% rename from .github/workflows/data/my_data.sql rename to helm-chart/eoapi/initdb-data/my_data.sql diff --git a/.github/workflows/data/noaa-emergency-response.json b/helm-chart/eoapi/initdb-data/noaa-emergency-response.json similarity index 100% rename from .github/workflows/data/noaa-emergency-response.json rename to helm-chart/eoapi/initdb-data/noaa-emergency-response.json diff --git a/.github/workflows/data/noaa-eri-nashville2020.json b/helm-chart/eoapi/initdb-data/noaa-eri-nashville2020.json similarity index 100% rename from .github/workflows/data/noaa-eri-nashville2020.json rename to helm-chart/eoapi/initdb-data/noaa-eri-nashville2020.json diff --git a/helm-chart/eoapi/templates/db/configmap.yaml b/helm-chart/eoapi/templates/db/configmap.yaml new file mode 100644 index 00000000..d7073f1e --- /dev/null +++ b/helm-chart/eoapi/templates/db/configmap.yaml @@ -0,0 +1,32 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: initdb-sql-config +data: + initdb.sql: | + {{- range $path, $bytes := $.Files.Glob "initdb-data/*.sql" -}} + {{ $.Files.Get $path | nindent 4 }} + {{- end }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: initdb-json-config +data: + {{- range $path, $bytes := $.Files.Glob "initdb-data/*.json" -}} + {{- base $path | nindent 2 -}}: | {{- $.Files.Get $path | nindent 4 -}} + {{- end -}} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: initdb-sh-config +data: + load.sh: | + pypgstac pgready --dsn postgresql://username:password@pgstac/postgis + pypgstac load items /opt/initdb/json-data/noaa-eri-nashville2020.json --dsn postgresql://username:password@pgstac/postgis --method insert_ignore + pypgstac load collections /opt/initdb/json-data/noaa-emergency-response.json --dsn postgresql://username:password@pgstac/postgis --method insert_ignore + psql postgresql://username:password@pgstac/postgis -f /opt/initdb/sql-data/initdb.sql + # run it forever like a docker process should + tail -f /dev/null diff --git a/helm-chart/eoapi/templates/db/deployment.yaml b/helm-chart/eoapi/templates/db/deployment.yaml index 10970419..6ed553e7 100644 --- a/helm-chart/eoapi/templates/db/deployment.yaml +++ b/helm-chart/eoapi/templates/db/deployment.yaml @@ -25,9 +25,6 @@ spec: - "-N" - "500" envFrom: - # NOTE: there's no reason we need to use a `ConfigMap` or `Secret` here to get os env vars into the pod. - # we could just template them out here immediately with `value: $_` but this allows us - # to store them in k8s intermediately and change them and then bounce deploys if needed - secretRef: name: pgstac-secrets ports: @@ -35,7 +32,38 @@ spec: volumeMounts: - mountPath: /var/lib/postgresql/data name: pgstac-claim + {{- if .Values.db.settings.enable_init_data_fixtures -}} + - name: loader + image: ghcr.io/stac-utils/pgstac:v0.7.1 + command: + - "sh" + args: + - "/opt/initdb/load.sh" + envFrom: + - secretRef: + name: pgstac-secrets + ports: + - containerPort: 6543 + volumeMounts: + - mountPath: /var/lib/postgresql/data + name: pgstac-claim + - mountPath: /opt/initdb/sql-data + name: initdb-sql-volume + - mountPath: /opt/initdb/json-data + name: initdb-json-volume + - mountPath: /opt/initdb/ + name: initdb-sh-volume + {{- end -}} volumes: - name: pgstac-claim persistentVolumeClaim: claimName: pgstac-claim + - name: initdb-sql-volume + configMap: + name: initdb-sql-config + - name: initdb-json-volume + configMap: + name: initdb-json-config + - name: initdb-sh-volume + configMap: + name: initdb-sh-config diff --git a/helm-chart/eoapi/templates/db/secrets.yaml b/helm-chart/eoapi/templates/db/secrets.yaml index b53d9e94..347c5f91 100644 --- a/helm-chart/eoapi/templates/db/secrets.yaml +++ b/helm-chart/eoapi/templates/db/secrets.yaml @@ -8,7 +8,7 @@ stringData: {{- range $envKey, $envValue := .Values.db.settings.secrets }} {{ upper $envKey }}: "{{ $envValue }}" {{- /* stac-utils seems to require different environment variable for postgres so handle here via if/else to - avoid having to pass more arg secrets passed */ -}} + avoid having to pass more arg secrets */ -}} {{- if eq $envKey "PGPASSWORD" }} POSTGRES_PASS: "{{ $envValue }}" {{- end }} diff --git a/helm-chart/eoapi/tests/db_tests.yaml b/helm-chart/eoapi/tests/db_tests.yaml index dc57fd66..926caa82 100644 --- a/helm-chart/eoapi/tests/db_tests.yaml +++ b/helm-chart/eoapi/tests/db_tests.yaml @@ -25,3 +25,46 @@ tests: - equal: path: stringData.POSTGRES_DBNAME value: "dbar" + +suite: db defaults deployment +templates: + - templates/db/deployment.yaml +tests: + - it: "db deploy defaults" + set: + db.enabled: true + gitSha: "ABC123" + asserts: + - isKind: + of: Deployment + - matchRegex: + path: metadata.name + pattern: ^pgstac$ + - equal: + path: spec.strategy.type + value: "Recreate" + - equal: + path: spec.template.spec.containers[0].name + value: "pgstac" + - isNull: + path: spec.template.spec.containers[1].name + - it: "db deploy with fixtures" + set: + db.enabled: true + db.enable_init_data_fixtures: true + gitSha: "ABC123" + asserts: + - isKind: + of: Deployment + - matchRegex: + path: metadata.name + pattern: ^pgstac$ + - equal: + path: spec.strategy.type + value: "Recreate" + - equal: + path: spec.template.spec.containers[0].name + value: "pgstac" + - equal: + path: spec.template.spec.containers[0].name + value: "loader" diff --git a/helm-chart/eoapi/tmp/eoapi-manfests.yaml b/helm-chart/eoapi/tmp/eoapi-manfests.yaml deleted file mode 100644 index 178e3fbf..00000000 --- a/helm-chart/eoapi/tmp/eoapi-manfests.yaml +++ /dev/null @@ -1,383 +0,0 @@ - ---- -# Source: eoapi/templates/db/manifest.yaml -apiVersion: v1 -kind: Secret -metadata: - name: pgstac-secrets -type: "Opaque" -stringData: - DB_MAX_CONN_SIZE: "10" - DB_MIN_CONN_SIZE: "1" - PGDATA: "/var/lib/postgresql/data/pgdata" - PGDATABASE: "postgis" - POSTGRES_DBNAME: "postgis" - PGPASSWORD: "password" - POSTGRES_PASS: "password" - PGUSER: "username" - POSTGRES_DB: "postgis" - POSTGRES_DBNAME: "postgis" - POSTGRES_HOST: "pgstac" - POSTGRES_HOST_READER: "pgstac" - POSTGRES_HOST_WRITER: "pgstac" - POSTGRES_PASS: "password" - POSTGRES_PASSWORD: "password" - POSTGRES_PORT: "5432" - POSTGRES_USER: "username" ---- -# Source: eoapi/templates/db/manifest.yaml -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: pgstac-claim -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 100Mi ---- -# Source: eoapi/templates/db/manifest.yaml -apiVersion: v1 -kind: Service -metadata: - labels: - app: pgstac - name: pgstac -spec: - ports: - - name: "5432" - port: 5432 - targetPort: 5432 - selector: - app: pgstac ---- -# Source: eoapi/templates/db/manifest.yaml -apiVersion: apps/v1 -kind: Deployment -metadata: - name: pgstac - labels: - app: pgstac -spec: - selector: - matchLabels: - app: pgstac - strategy: - type: Recreate - template: - metadata: - labels: - app: pgstac - spec: - restartPolicy: Always - containers: - - name: pgstac - image: ghcr.io/stac-utils/pgstac:v0.7.1 - args: - - "postgres" - - "-N" - - "500" - envFrom: - # NOTE: there's no reason we need to use a `ConfigMap` or `Secret` here to get os env vars into the pod. - # we could just template them out here immediately with `value: $_` but this allows us - # to store them in k8s intermediately and change them and then bounce deploys if needed - - secretRef: - name: pgstac-secrets - ports: - - containerPort: 5432 - volumeMounts: - - mountPath: /var/lib/postgresql/data - name: pgstac-claim - volumes: - - name: pgstac-claim - persistentVolumeClaim: - claimName: pgstac-claim ---- -# Source: eoapi/templates/services/manifest.yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: raster-envvar-configmap -data: - CPL_VSIL_CURL_ALLOWED_EXTENSIONS: ".tif,.TIF,.tiff" - GDAL_CACHEMAX: "200" - GDAL_DISABLE_READDIR_ON_OPEN: "EMPTY_DIR" - GDAL_HTTP_MERGE_CONSECUTIVE_RANGES: "YES" - GDAL_HTTP_MULTIPLEX: "YES" - GDAL_HTTP_VERSION: "2" - GDAL_INGESTED_BYTES_AT_OPEN: "32768" - HOST: "0.0.0.0" - PORT: "8080" - PYTHONWARNINGS: "ignore" - VSI_CACHE: "TRUE" - VSI_CACHE_SIZE: "5000000" - WEB_CONCURRENCY: "10" ---- -# Source: eoapi/templates/services/manifest.yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: stac-envvar-configmap -data: - HOST: "0.0.0.0" - PORT: "8080" - TITILER_ENDPOINT: "raster:8080" - WEB_CONCURRENCY: "10" ---- -# Source: eoapi/templates/services/manifest.yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: vector-envvar-configmap -data: - HOST: "0.0.0.0" - PORT: "8080" - TIPG_CATALOG_TTL: "0" - WEB_CONCURRENCY: "10" ---- -# Source: eoapi/templates/services/manifest.yaml -apiVersion: v1 -kind: Service -metadata: - labels: - app: raster - name: raster -spec: - type: NodePort - ports: - - name: '8080' - port: 8080 - targetPort: 8080 - selector: - app: raster ---- -# Source: eoapi/templates/services/manifest.yaml -apiVersion: v1 -kind: Service -metadata: - labels: - app: stac - name: stac -spec: - type: NodePort - ports: - - name: '8080' - port: 8080 - targetPort: 8080 - selector: - app: stac ---- -# Source: eoapi/templates/services/manifest.yaml -apiVersion: v1 -kind: Service -metadata: - labels: - app: vector - name: vector -spec: - type: NodePort - ports: - - name: '8080' - port: 8080 - targetPort: 8080 - selector: - app: vector ---- -# Source: eoapi/templates/services/manifest.yaml -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: raster - gitsha: a5ba4b476b - name: raster -spec: - progressDeadlineSeconds: 600 - revisionHistoryLimit: 5 - strategy: - type: RollingUpdate - rollingUpdate: - maxSurge: 50% - maxUnavailable: 0 - selector: - matchLabels: - app: raster - template: - metadata: - labels: - app: raster - spec: - containers: - - image: ghcr.io/developmentseed/eoapi-raster:latest - name: raster - ports: - - containerPort: 8080 - resources: - limits: - cpu: 512m - memory: 4096M - requests: - cpu: 256m - memory: 3072M - envFrom: - # NOTE: there's no reason we need to use a `ConfigMap` or `Secret` here to get os env vars into the pod. - # we could just template them out here immediately with `value: $_` but this allows us - # to store them in k8s intermediately and change them and then bounce deploys if needed - - secretRef: - name: pgstac-secrets - - configMapRef: - name: raster-envvar-configmap ---- -# Source: eoapi/templates/services/manifest.yaml -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: stac - gitsha: a5ba4b476b - name: stac -spec: - progressDeadlineSeconds: 600 - revisionHistoryLimit: 5 - strategy: - type: RollingUpdate - rollingUpdate: - maxSurge: 50% - maxUnavailable: 0 - selector: - matchLabels: - app: stac - template: - metadata: - labels: - app: stac - spec: - containers: - - image: ghcr.io/developmentseed/eoapi-stac:latest - name: stac - ports: - - containerPort: 8080 - resources: - limits: - cpu: 512m - memory: 1024Mi - requests: - cpu: 256m - memory: 256Mi - envFrom: - # NOTE: there's no reason we need to use a `ConfigMap` or `Secret` here to get os env vars into the pod. - # we could just template them out here immediately with `value: $_` but this allows us - # to store them in k8s intermediately and change them and then bounce deploys if needed - - secretRef: - name: pgstac-secrets - - configMapRef: - name: stac-envvar-configmap ---- -# Source: eoapi/templates/services/manifest.yaml -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: vector - gitsha: a5ba4b476b - name: vector -spec: - progressDeadlineSeconds: 600 - revisionHistoryLimit: 5 - strategy: - type: RollingUpdate - rollingUpdate: - maxSurge: 50% - maxUnavailable: 0 - selector: - matchLabels: - app: vector - template: - metadata: - labels: - app: vector - spec: - containers: - - image: ghcr.io/developmentseed/eoapi-vector:latest - name: vector - ports: - - containerPort: 8080 - resources: - limits: - cpu: 512m - memory: 1024Mi - requests: - cpu: 256m - memory: 256Mi - envFrom: - # NOTE: there's no reason we need to use a `ConfigMap` or `Secret` here to get os env vars into the pod. - # we could just template them out here immediately with `value: $_` but this allows us - # to store them in k8s intermediately and change them and then bounce deploys if needed - - secretRef: - name: pgstac-secrets - - configMapRef: - name: vector-envvar-configmap ---- -# Source: eoapi/templates/services/manifest.yaml -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: raster - annotations: - alb.ingress.kubernetes.io/scheme: internet-facing - alb.ingress.kubernetes.io/target-type: instance -spec: - ingressClassName: alb - rules: - - http: - paths: - - pathType: Prefix - path: "/" - backend: - service: - name: raster - port: - number: 8080 ---- -# Source: eoapi/templates/services/manifest.yaml -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: stac - annotations: - alb.ingress.kubernetes.io/scheme: internet-facing - alb.ingress.kubernetes.io/target-type: instance -spec: - ingressClassName: alb - rules: - - http: - paths: - - pathType: Prefix - path: "/" - backend: - service: - name: stac - port: - number: 8080 ---- -# Source: eoapi/templates/services/manifest.yaml -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: vector - annotations: - alb.ingress.kubernetes.io/scheme: internet-facing - alb.ingress.kubernetes.io/target-type: instance -spec: - ingressClassName: alb - rules: - - http: - paths: - - pathType: Prefix - path: "/" - backend: - service: - name: vector - port: - number: 8080 diff --git a/helm-chart/eoapi/values.yaml b/helm-chart/eoapi/values.yaml index c676b9a8..0f9881d7 100644 --- a/helm-chart/eoapi/values.yaml +++ b/helm-chart/eoapi/values.yaml @@ -34,6 +34,8 @@ db: # environment options: "rds" || "k8s" environment: "k8s" enabled: true + # toggle to true if you want the db test fixtures loaded + enable_init_data_fixtures: false settings: resources: requests: @@ -79,7 +81,6 @@ raster: image: name: ghcr.io/developmentseed/eoapi-raster tag: latest - # nothing definitive about this, just plumbed in after quick survey of `eoAPI/infrastructure/aws/cdk/config.py` settings: timeout: 10 # https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ @@ -117,7 +118,6 @@ stac: image: name: ghcr.io/developmentseed/eoapi-stac tag: latest - # nothing definitive about this, just plumbed in after quick survey of `eoAPI/infrastructure/aws/cdk/config.py` settings: timeout: 10 # https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ @@ -147,7 +147,6 @@ vector: image: name: ghcr.io/developmentseed/eoapi-vector tag: latest - # nothing definitive about this, just plumbed in after quick survey of `eoAPI/infrastructure/aws/cdk/config.py` settings: timeout: 10 # https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ From 9e48c63c80b0b500184c9fe1803a683f04053c09 Mon Sep 17 00:00:00 2001 From: ranchodeluxe Date: Thu, 8 Jun 2023 19:43:36 -0700 Subject: [PATCH 2/6] remove ci.yaml --- .github/workflows/ci.yml | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index e1718406..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: CI - -# On every pull request, but only on push to main -on: - push: - branches: - - main - tags: - - '*' - pull_request: - -jobs: {} - From 4ba504bcbc5e03223991d0a90f92bb0bc324fe6b Mon Sep 17 00:00:00 2001 From: ranchodeluxe Date: Thu, 8 Jun 2023 19:45:33 -0700 Subject: [PATCH 3/6] fix --- helm-chart/eoapi/tests/db_deploy_tests.yaml | 43 +++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 helm-chart/eoapi/tests/db_deploy_tests.yaml diff --git a/helm-chart/eoapi/tests/db_deploy_tests.yaml b/helm-chart/eoapi/tests/db_deploy_tests.yaml new file mode 100644 index 00000000..7cff9cfd --- /dev/null +++ b/helm-chart/eoapi/tests/db_deploy_tests.yaml @@ -0,0 +1,43 @@ + +suite: db defaults deployment +templates: + - templates/db/deployment.yaml +tests: + - it: "db deploy defaults" + set: + db.enabled: true + gitSha: "ABC123" + asserts: + - isKind: + of: Deployment + - matchRegex: + path: metadata.name + pattern: ^pgstac$ + - equal: + path: spec.strategy.type + value: "Recreate" + - equal: + path: spec.template.spec.containers[0].name + value: "pgstac" + - isNull: + path: spec.template.spec.containers[1].name + - it: "db deploy with fixtures" + set: + db.enabled: true + db.enable_init_data_fixtures: true + gitSha: "ABC123" + asserts: + - isKind: + of: Deployment + - matchRegex: + path: metadata.name + pattern: ^pgstac$ + - equal: + path: spec.strategy.type + value: "Recreate" + - equal: + path: spec.template.spec.containers[0].name + value: "pgstac" + - equal: + path: spec.template.spec.containers[0].name + value: "loader" \ No newline at end of file From 422b74db26d0dc72fabbddb35c911760902517e7 Mon Sep 17 00:00:00 2001 From: ranchodeluxe Date: Thu, 8 Jun 2023 19:46:35 -0700 Subject: [PATCH 4/6] fix db_tests --- helm-chart/eoapi/tests/db_tests.yaml | 43 ---------------------------- 1 file changed, 43 deletions(-) diff --git a/helm-chart/eoapi/tests/db_tests.yaml b/helm-chart/eoapi/tests/db_tests.yaml index 926caa82..dc57fd66 100644 --- a/helm-chart/eoapi/tests/db_tests.yaml +++ b/helm-chart/eoapi/tests/db_tests.yaml @@ -25,46 +25,3 @@ tests: - equal: path: stringData.POSTGRES_DBNAME value: "dbar" - -suite: db defaults deployment -templates: - - templates/db/deployment.yaml -tests: - - it: "db deploy defaults" - set: - db.enabled: true - gitSha: "ABC123" - asserts: - - isKind: - of: Deployment - - matchRegex: - path: metadata.name - pattern: ^pgstac$ - - equal: - path: spec.strategy.type - value: "Recreate" - - equal: - path: spec.template.spec.containers[0].name - value: "pgstac" - - isNull: - path: spec.template.spec.containers[1].name - - it: "db deploy with fixtures" - set: - db.enabled: true - db.enable_init_data_fixtures: true - gitSha: "ABC123" - asserts: - - isKind: - of: Deployment - - matchRegex: - path: metadata.name - pattern: ^pgstac$ - - equal: - path: spec.strategy.type - value: "Recreate" - - equal: - path: spec.template.spec.containers[0].name - value: "pgstac" - - equal: - path: spec.template.spec.containers[0].name - value: "loader" From bf4c52d82a0bb33f127c37e182f39db2056de695 Mon Sep 17 00:00:00 2001 From: ranchodeluxe Date: Fri, 9 Jun 2023 06:31:18 -0700 Subject: [PATCH 5/6] fix tests --- helm-chart/eoapi/templates/db/deployment.yaml | 4 ++-- helm-chart/eoapi/tests/db_deploy_tests.yaml | 7 ++----- helm-chart/eoapi/tests/deploy_tests.yaml | 3 --- helm-chart/eoapi/values.yaml | 2 +- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/helm-chart/eoapi/templates/db/deployment.yaml b/helm-chart/eoapi/templates/db/deployment.yaml index 6ed553e7..451cb449 100644 --- a/helm-chart/eoapi/templates/db/deployment.yaml +++ b/helm-chart/eoapi/templates/db/deployment.yaml @@ -32,7 +32,7 @@ spec: volumeMounts: - mountPath: /var/lib/postgresql/data name: pgstac-claim - {{- if .Values.db.settings.enable_init_data_fixtures -}} + {{- if .Values.db.enable_data_fixtures }} - name: loader image: ghcr.io/stac-utils/pgstac:v0.7.1 command: @@ -53,7 +53,7 @@ spec: name: initdb-json-volume - mountPath: /opt/initdb/ name: initdb-sh-volume - {{- end -}} + {{- end }} volumes: - name: pgstac-claim persistentVolumeClaim: diff --git a/helm-chart/eoapi/tests/db_deploy_tests.yaml b/helm-chart/eoapi/tests/db_deploy_tests.yaml index 7cff9cfd..94e93819 100644 --- a/helm-chart/eoapi/tests/db_deploy_tests.yaml +++ b/helm-chart/eoapi/tests/db_deploy_tests.yaml @@ -1,4 +1,3 @@ - suite: db defaults deployment templates: - templates/db/deployment.yaml @@ -6,7 +5,6 @@ tests: - it: "db deploy defaults" set: db.enabled: true - gitSha: "ABC123" asserts: - isKind: of: Deployment @@ -24,8 +22,7 @@ tests: - it: "db deploy with fixtures" set: db.enabled: true - db.enable_init_data_fixtures: true - gitSha: "ABC123" + db.enable_data_fixtures: true asserts: - isKind: of: Deployment @@ -39,5 +36,5 @@ tests: path: spec.template.spec.containers[0].name value: "pgstac" - equal: - path: spec.template.spec.containers[0].name + path: spec.template.spec.containers[1].name value: "loader" \ No newline at end of file diff --git a/helm-chart/eoapi/tests/deploy_tests.yaml b/helm-chart/eoapi/tests/deploy_tests.yaml index fa431ba0..90d23237 100644 --- a/helm-chart/eoapi/tests/deploy_tests.yaml +++ b/helm-chart/eoapi/tests/deploy_tests.yaml @@ -7,7 +7,6 @@ tests: raster.enabled: false stac.enabled: false vector.enabled: true - gitSha: "ABC123" asserts: - isKind: of: Deployment @@ -37,7 +36,6 @@ tests: raster.enabled: true stac.enabled: false vector.enabled: false - gitSha: "ABC123" asserts: - isKind: of: Deployment @@ -67,7 +65,6 @@ tests: raster.enabled: false stac.enabled: true vector.enabled: false - gitSha: "ABC123" asserts: - isKind: of: Deployment diff --git a/helm-chart/eoapi/values.yaml b/helm-chart/eoapi/values.yaml index 0f9881d7..f896a4cb 100644 --- a/helm-chart/eoapi/values.yaml +++ b/helm-chart/eoapi/values.yaml @@ -35,7 +35,7 @@ db: environment: "k8s" enabled: true # toggle to true if you want the db test fixtures loaded - enable_init_data_fixtures: false + enable_data_fixtures: false settings: resources: requests: From cf0ac145546a6a998a98fd1ab3d54f4a08f48334 Mon Sep 17 00:00:00 2001 From: ranchodeluxe Date: Fri, 9 Jun 2023 06:32:47 -0700 Subject: [PATCH 6/6] more text fixing --- helm-chart/eoapi/tests/db_deploy_tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/helm-chart/eoapi/tests/db_deploy_tests.yaml b/helm-chart/eoapi/tests/db_deploy_tests.yaml index 94e93819..7578e0ec 100644 --- a/helm-chart/eoapi/tests/db_deploy_tests.yaml +++ b/helm-chart/eoapi/tests/db_deploy_tests.yaml @@ -5,6 +5,7 @@ tests: - it: "db deploy defaults" set: db.enabled: true + db.enable_data_fixtures: false asserts: - isKind: of: Deployment