|
1 | 1 | # frozen_string_literal: true
|
2 | 2 | require 'spec_helper'
|
3 | 3 |
|
4 |
| -describe 'imagePullSecrets configuration' do |
| 4 | +describe 'worker probes configuration' do |
5 | 5 | let(:template) { HelmTemplate.new(default_values) }
|
| 6 | + let(:worker) { 'Deployment/optest-openproject-worker-default' } |
6 | 7 |
|
7 |
| - context 'when setting custom workers' do |
| 8 | + context 'when disabling probes' do |
8 | 9 | let(:default_values) do
|
9 | 10 | HelmTemplate.with_defaults(<<~YAML
|
10 | 11 | workers:
|
11 | 12 | default:
|
12 | 13 | queues: ""
|
13 |
| - replicaCount: 1 |
14 |
| - strategy: |
15 |
| - type: "Recreate" |
16 |
| - multitenancy: |
17 |
| - queues: "multitenancy" |
18 |
| - replicaCount: 1 |
19 |
| - strategy: |
20 |
| - type: "Recreate" |
21 |
| - bim: |
22 |
| - queues: "bim,ifc_conversion" |
23 |
| - replicaCount: 0 |
24 |
| - strategy: |
25 |
| - type: "Recreate" |
26 |
| - YAML |
| 14 | + replicas: 1 |
| 15 | + probes: |
| 16 | + enabled: false |
| 17 | + port: 7001 |
| 18 | + YAML |
27 | 19 | )
|
28 | 20 | end
|
29 | 21 |
|
30 |
| - it 'Creates the different worker deployments', :aggregate_failures do |
31 |
| - expect(template.keys).to include 'Deployment/optest-openproject-worker-default' |
32 |
| - expect(template.dig('Deployment/optest-openproject-worker-default', 'spec', 'replicas')) |
33 |
| - .to eq(1) |
34 |
| - expect(template.env('Deployment/optest-openproject-worker-default', 'openproject', 'QUEUE')) |
35 |
| - .to be_nil |
36 |
| - |
37 |
| - expect(template.keys).to include 'Deployment/optest-openproject-worker-multitenancy' |
38 |
| - expect(template.dig('Deployment/optest-openproject-worker-multitenancy', 'spec', 'replicas')) |
39 |
| - .to eq(1) |
40 |
| - expect(template.env_named('Deployment/optest-openproject-worker-multitenancy', 'openproject', 'QUEUE')['value']) |
41 |
| - .to eq('multitenancy') |
42 |
| - |
43 |
| - expect(template.keys).to include 'Deployment/optest-openproject-worker-bim' |
44 |
| - expect(template.dig('Deployment/optest-openproject-worker-bim', 'spec', 'replicas')) |
45 |
| - .to eq(0) |
46 |
| - expect(template.env_named('Deployment/optest-openproject-worker-bim', 'openproject', 'QUEUE')['value']) |
47 |
| - .to eq('bim,ifc_conversion') |
| 22 | + it 'does not define worker probes', :aggregate_failures do |
| 23 | + expect(template.keys).to include worker |
| 24 | + |
| 25 | + spec = template.find_container(worker, 'openproject') |
| 26 | + expect(spec['livenessProbe']).to be_nil |
| 27 | + expect(spec['readinessProbe']).to be_nil |
| 28 | + |
| 29 | + env = template.env_named(worker, 'openproject', 'GOOD_JOB_PROBE_PORT') |
| 30 | + expect(env).to be_nil |
48 | 31 | end
|
49 | 32 | end
|
50 | 33 |
|
51 |
| - context 'when setting no workers' do |
| 34 | + context 'when setting custom port' do |
| 35 | + let(:default_values) do |
| 36 | + HelmTemplate.with_defaults(<<~YAML |
| 37 | + workers: |
| 38 | + default: |
| 39 | + queues: "" |
| 40 | + replicas: 1 |
| 41 | + probes: |
| 42 | + enabled: true |
| 43 | + port: 9999 |
| 44 | + YAML |
| 45 | + ) |
| 46 | + end |
| 47 | + |
| 48 | + it 'does define the probe', :aggregate_failures do |
| 49 | + expect(template.keys).to include worker |
| 50 | + spec = template.find_container(worker, 'openproject') |
| 51 | + expect(spec['livenessProbe']).to be_a(Hash) |
| 52 | + expect(spec['readinessProbe']).to be_a(Hash) |
| 53 | + expect(spec['readinessProbe']['httpGet']['port']).to eq 9999 |
| 54 | + expect(spec['livenessProbe']['httpGet']['port']).to eq 9999 |
| 55 | + |
| 56 | + env = template.env_named(worker, 'openproject', 'GOOD_JOB_PROBE_PORT') |
| 57 | + expect(env).to be_a(Hash) |
| 58 | + expect(env['value']).to eq '9999' |
| 59 | + end |
| 60 | + end |
| 61 | + |
| 62 | + context 'with default configuration' do |
52 | 63 | let(:default_values) do
|
53 | 64 | {}
|
54 | 65 | end
|
55 | 66 |
|
56 |
| - it 'Creates the default worker', :aggregate_failures do |
57 |
| - expect(template.keys).to include 'Deployment/optest-openproject-worker-default' |
| 67 | + it 'uses the default probes', :aggregate_failures do |
| 68 | + expect(template.keys).to include worker |
| 69 | + spec = template.find_container(worker, 'openproject') |
| 70 | + expect(spec['livenessProbe']).to be_a(Hash) |
| 71 | + expect(spec['readinessProbe']).to be_a(Hash) |
| 72 | + expect(spec['readinessProbe']['httpGet']['port']).to eq 7001 |
| 73 | + expect(spec['livenessProbe']['httpGet']['port']).to eq 7001 |
| 74 | + |
| 75 | + env = template.env_named(worker, 'openproject', 'GOOD_JOB_PROBE_PORT') |
| 76 | + expect(env).to be_a(Hash) |
| 77 | + expect(env['value']).to eq '7001' |
58 | 78 | end
|
59 | 79 | end
|
60 | 80 | end
|
0 commit comments