|
| 1 | +suite: test standard hooks (command, args, initContainers, extraObjects) |
| 2 | +templates: |
| 3 | + - deployment.yaml |
| 4 | + - fusillade/deployment.yaml |
| 5 | + - migrations/job.yaml |
| 6 | + - extra-objects.yaml |
| 7 | + - configmap.yaml |
| 8 | + - secret.yaml |
| 9 | + - migrations/config.yaml |
| 10 | + - migrations/secret.yaml |
| 11 | +tests: |
| 12 | + - it: leaves command, args and init containers unset by default |
| 13 | + template: deployment.yaml |
| 14 | + asserts: |
| 15 | + - notExists: |
| 16 | + path: spec.template.spec.containers[0].command |
| 17 | + - notExists: |
| 18 | + path: spec.template.spec.containers[0].args |
| 19 | + - notExists: |
| 20 | + path: spec.template.spec.initContainers |
| 21 | + |
| 22 | + - it: sets command, args and init containers on the API pods |
| 23 | + template: deployment.yaml |
| 24 | + set: |
| 25 | + command: ["/tools/launcher", "--", "./dwctl"] |
| 26 | + args: ["--validate"] |
| 27 | + initContainers: |
| 28 | + - name: fetch-tools |
| 29 | + image: example/tools:1.0 |
| 30 | + - name: helper |
| 31 | + image: example/helper:1.0 |
| 32 | + restartPolicy: Always |
| 33 | + asserts: |
| 34 | + - equal: |
| 35 | + path: spec.template.spec.containers[0].command |
| 36 | + value: ["/tools/launcher", "--", "./dwctl"] |
| 37 | + - equal: |
| 38 | + path: spec.template.spec.containers[0].args |
| 39 | + value: ["--validate"] |
| 40 | + - equal: |
| 41 | + path: spec.template.spec.initContainers[0].name |
| 42 | + value: fetch-tools |
| 43 | + - equal: |
| 44 | + path: spec.template.spec.initContainers[1].restartPolicy |
| 45 | + value: Always |
| 46 | + |
| 47 | + - it: sets the same command and init containers on the Fusillade pods |
| 48 | + template: fusillade/deployment.yaml |
| 49 | + set: |
| 50 | + fusillade.enabled: true |
| 51 | + command: ["/tools/launcher", "--", "./dwctl"] |
| 52 | + initContainers: |
| 53 | + - name: fetch-tools |
| 54 | + image: example/tools:1.0 |
| 55 | + asserts: |
| 56 | + - equal: |
| 57 | + path: spec.template.spec.containers[0].command |
| 58 | + value: ["/tools/launcher", "--", "./dwctl"] |
| 59 | + - equal: |
| 60 | + path: spec.template.spec.initContainers[0].name |
| 61 | + value: fetch-tools |
| 62 | + |
| 63 | + - it: gives the migration Job its own command and init containers, keeping args migrate |
| 64 | + template: migrations/job.yaml |
| 65 | + set: |
| 66 | + migrations.job.enabled: true |
| 67 | + postgresql.enabled: false |
| 68 | + secrets.controlLayer.data.DATABASE_URL: "postgres://db.example.com/control_layer" |
| 69 | + command: ["/not/for/the/job"] |
| 70 | + migrations.job.command: ["/tools/launcher", "--", "./dwctl"] |
| 71 | + migrations.job.initContainers: |
| 72 | + - name: fetch-tools |
| 73 | + image: example/tools:1.0 |
| 74 | + asserts: |
| 75 | + - equal: |
| 76 | + path: spec.template.spec.containers[0].command |
| 77 | + value: ["/tools/launcher", "--", "./dwctl"] |
| 78 | + - equal: |
| 79 | + path: spec.template.spec.containers[0].args |
| 80 | + value: ["migrate"] |
| 81 | + - equal: |
| 82 | + path: spec.template.spec.initContainers[0].name |
| 83 | + value: fetch-tools |
| 84 | + |
| 85 | + - it: leaves the migration Job's command unset by default |
| 86 | + template: migrations/job.yaml |
| 87 | + set: |
| 88 | + migrations.job.enabled: true |
| 89 | + postgresql.enabled: false |
| 90 | + secrets.controlLayer.data.DATABASE_URL: "postgres://db.example.com/control_layer" |
| 91 | + command: ["/not/for/the/job"] |
| 92 | + asserts: |
| 93 | + - notExists: |
| 94 | + path: spec.template.spec.containers[0].command |
| 95 | + - notExists: |
| 96 | + path: spec.template.spec.initContainers |
| 97 | + |
| 98 | + - it: renders nothing for extraObjects by default |
| 99 | + template: extra-objects.yaml |
| 100 | + asserts: |
| 101 | + - hasDocuments: |
| 102 | + count: 0 |
| 103 | + |
| 104 | + - it: renders extraObjects as-is, leaving template syntax untouched |
| 105 | + template: extra-objects.yaml |
| 106 | + set: |
| 107 | + extraObjects: |
| 108 | + - apiVersion: v1 |
| 109 | + kind: ConfigMap |
| 110 | + metadata: |
| 111 | + name: launcher-config |
| 112 | + data: |
| 113 | + config.yaml: "value: {{ .Value }}" |
| 114 | + asserts: |
| 115 | + - hasDocuments: |
| 116 | + count: 1 |
| 117 | + - isKind: |
| 118 | + of: ConfigMap |
| 119 | + - equal: |
| 120 | + path: data["config.yaml"] |
| 121 | + value: "value: {{ .Value }}" |
0 commit comments