Compare commits
No commits in common. "3da3656b71fe02132c311b32a59b72f9b761b4d8" and "0a0a0a92eed07148ed29459e0c12aef63c63298f" have entirely different histories.
3da3656b71
...
0a0a0a92ee
11
.maidn/database.yaml
Normal file
11
.maidn/database.yaml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: Cluster
|
||||
metadata:
|
||||
name: maidn-e2e-secret
|
||||
namespace: staging
|
||||
labels:
|
||||
maidn.io/e2e: "true"
|
||||
spec:
|
||||
instances: 1
|
||||
storage:
|
||||
size: 1Gi
|
||||
4
.maidn/kustomization.yaml
Normal file
4
.maidn/kustomization.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- database.yaml
|
||||
|
|
@ -27,21 +27,17 @@ spec:
|
|||
ports:
|
||||
- name: http
|
||||
containerPort: 8080
|
||||
{{- if or (eq .Release.Namespace "staging") (eq .Release.Namespace "production") }}
|
||||
env:
|
||||
- name: E2E_SECRET
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ printf "%s-runtime-%s" .Chart.Name .Release.Namespace }}
|
||||
name: maidn-e2e-secret-runtime-staging
|
||||
key: {{ .Values.runtimeSecret.key | quote }}
|
||||
- name: DATABASE_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ printf "%s-postgres-app" .Release.Namespace }}
|
||||
name: maidn-e2e-secret-app
|
||||
key: uri
|
||||
- name: MAIDN_RUNTIME_REQUIRED
|
||||
value: "true"
|
||||
{{- end }}
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { Client } from 'pg';
|
||||
|
||||
export async function isReady(selectOne = databaseSelectOne) {
|
||||
if (process.env.MAIDN_RUNTIME_REQUIRED !== 'true') return true;
|
||||
if (!process.env.E2E_SECRET || !process.env.DATABASE_URL) return false;
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -5,13 +5,8 @@ const { isReady } = require('../dist/health.js');
|
|||
test('readiness requires the secret and a successful database query', async () => {
|
||||
const secret = process.env.E2E_SECRET;
|
||||
const databaseUrl = process.env.DATABASE_URL;
|
||||
const runtimeRequired = process.env.MAIDN_RUNTIME_REQUIRED;
|
||||
|
||||
try {
|
||||
delete process.env.MAIDN_RUNTIME_REQUIRED;
|
||||
assert.equal(await isReady(async () => assert.fail('query should not run')), true);
|
||||
|
||||
process.env.MAIDN_RUNTIME_REQUIRED = 'true';
|
||||
delete process.env.E2E_SECRET;
|
||||
assert.equal(await isReady(async () => assert.fail('query should not run')), false);
|
||||
|
||||
|
|
@ -27,7 +22,5 @@ test('readiness requires the secret and a successful database query', async () =
|
|||
else process.env.E2E_SECRET = secret;
|
||||
if (databaseUrl === undefined) delete process.env.DATABASE_URL;
|
||||
else process.env.DATABASE_URL = databaseUrl;
|
||||
if (runtimeRequired === undefined) delete process.env.MAIDN_RUNTIME_REQUIRED;
|
||||
else process.env.MAIDN_RUNTIME_REQUIRED = runtimeRequired;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue