Skip to content

Commit a99b79e

Browse files
test: Use the discovery ConfigMap in all tests
1 parent 53e5915 commit a99b79e

11 files changed

Lines changed: 68 additions & 84 deletions

tests/templates/kuttl/backup-restore/22-create-testuser.yaml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ spec:
2222
# required for pip install
2323
- name: HOME
2424
value: /stackable
25-
- name: NAMESPACE
26-
valueFrom:
27-
fieldRef:
28-
fieldPath: metadata.namespace
25+
envFrom:
26+
- configMapRef:
27+
name: opensearch-1
2928
volumeMounts:
3029
- name: script
3130
mountPath: /stackable/scripts
@@ -66,17 +65,16 @@ data:
6665
from opensearchpy import OpenSearch
6766
from opensearchpy.exceptions import RequestError
6867
69-
namespace = os.environ['NAMESPACE']
68+
host = os.environ['OPENSEARCH_HOST']
69+
port = os.environ['OPENSEARCH_PORT']
70+
http_use_tls = os.environ['OPENSEARCH_PROTOCOL'] == 'https'
7071
7172
# Login as admin
7273
client = OpenSearch(
74+
hosts = [{'host': host, 'port': port}],
7375
http_auth=('admin', 'AJVFsGJBbpT6mChn'),
74-
hosts=[{
75-
'host': f'opensearch-1-nodes-default-headless.{namespace}.svc.cluster.local',
76-
'port': 9200
77-
}],
7876
http_compress=True,
79-
use_ssl=True,
77+
use_ssl=http_use_tls,
8078
verify_certs=True,
8179
ca_certs='/stackable/tls/ca.crt'
8280
)

tests/templates/kuttl/backup-restore/23-create-data.yaml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ spec:
2222
# required for pip install
2323
- name: HOME
2424
value: /stackable
25-
- name: NAMESPACE
26-
valueFrom:
27-
fieldRef:
28-
fieldPath: metadata.namespace
25+
envFrom:
26+
- configMapRef:
27+
name: opensearch-1
2928
volumeMounts:
3029
- name: script
3130
mountPath: /stackable/scripts
@@ -66,17 +65,16 @@ data:
6665
from opensearchpy import OpenSearch
6766
from opensearchpy.exceptions import RequestError
6867
69-
namespace = os.environ['NAMESPACE']
68+
host = os.environ['OPENSEARCH_HOST']
69+
port = os.environ['OPENSEARCH_PORT']
70+
http_use_tls = os.environ['OPENSEARCH_PROTOCOL'] == 'https'
7071
7172
# Login as test user
7273
client = OpenSearch(
74+
hosts = [{'host': host, 'port': port}],
7375
http_auth=('testuser', 'L9hUHtLVVEsrcLzZ'),
74-
hosts=[{
75-
'host': f'opensearch-1-nodes-default-headless.{namespace}.svc.cluster.local',
76-
'port': 9200
77-
}],
7876
http_compress=True,
79-
use_ssl=True,
77+
use_ssl=http_use_tls,
8078
verify_certs=True,
8179
ca_certs='/stackable/tls/ca.crt'
8280
)

tests/templates/kuttl/backup-restore/30-create-snapshot.yaml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ spec:
2222
# required for pip install
2323
- name: HOME
2424
value: /stackable
25-
- name: NAMESPACE
26-
valueFrom:
27-
fieldRef:
28-
fieldPath: metadata.namespace
25+
envFrom:
26+
- configMapRef:
27+
name: opensearch-1
2928
volumeMounts:
3029
- name: script
3130
mountPath: /stackable/scripts
@@ -66,16 +65,15 @@ data:
6665
from opensearchpy import OpenSearch
6766
from opensearchpy.exceptions import RequestError
6867
69-
namespace = os.environ['NAMESPACE']
68+
host = os.environ['OPENSEARCH_HOST']
69+
port = os.environ['OPENSEARCH_PORT']
70+
http_use_tls = os.environ['OPENSEARCH_PROTOCOL'] == 'https'
7071
7172
client = OpenSearch(
72-
hosts=[{
73-
'host': f'opensearch-1-nodes-default-headless.{namespace}.svc.cluster.local',
74-
'port': 9200
75-
}],
73+
hosts = [{'host': host, 'port': port}],
7674
http_auth=('admin', 'AJVFsGJBbpT6mChn'),
7775
http_compress=True,
78-
use_ssl=True,
76+
use_ssl=http_use_tls,
7977
verify_certs=True,
8078
ca_certs='/stackable/tls/ca.crt'
8179
)

tests/templates/kuttl/backup-restore/31-backup-security-indices.yaml.j2

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ spec:
1111
image: oci.stackable.tech/sdp/opensearch:{{ test_scenario['values']['opensearch'].split(',')[0] }}-stackable{{ test_scenario['values']['release'] }}
1212
command:
1313
- /stackable/scripts/backup-security-indices.sh
14-
env:
15-
- name: NAMESPACE
16-
valueFrom:
17-
fieldRef:
18-
fieldPath: metadata.namespace
14+
envFrom:
15+
- configMapRef:
16+
name: opensearch-1
1917
volumeMounts:
2018
- name: scripts
2119
mountPath: /stackable/scripts
@@ -116,7 +114,7 @@ data:
116114
-cacert config/tls/ca.crt \
117115
-cert config/tls-client/tls.crt \
118116
-key config/tls-client/tls.key \
119-
--hostname opensearch-1-nodes-default-headless.$NAMESPACE.svc.cluster.local \
117+
--hostname $OPENSEARCH_HOST \
120118
-backup /tmp/backup
121119
upload-security-indices-backup.sh: |
122120
#!/usr/bin/env sh

tests/templates/kuttl/backup-restore/60-restore-security-indices.yaml.j2

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,9 @@ spec:
4848
image: oci.stackable.tech/sdp/opensearch:{{ test_scenario['values']['opensearch'].split(',')[0] }}-stackable{{ test_scenario['values']['release'] }}
4949
command:
5050
- /stackable/scripts/restore-security-indices.sh
51-
env:
52-
- name: NAMESPACE
53-
valueFrom:
54-
fieldRef:
55-
fieldPath: metadata.namespace
51+
envFrom:
52+
- configMapRef:
53+
name: opensearch-2
5654
volumeMounts:
5755
- name: scripts
5856
mountPath: /stackable/scripts
@@ -121,5 +119,5 @@ data:
121119
-cacert config/tls/ca.crt \
122120
-cert config/tls-client/tls.crt \
123121
-key config/tls-client/tls.key \
124-
--hostname opensearch-2-nodes-default-headless.$NAMESPACE.svc.cluster.local \
122+
--hostname $OPENSEARCH_HOST \
125123
--configdir /tmp/backup

tests/templates/kuttl/backup-restore/61-restore-snapshot.yaml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ spec:
2222
# required for pip install
2323
- name: HOME
2424
value: /stackable
25-
- name: NAMESPACE
26-
valueFrom:
27-
fieldRef:
28-
fieldPath: metadata.namespace
25+
envFrom:
26+
- configMapRef:
27+
name: opensearch-2
2928
volumeMounts:
3029
- name: script
3130
mountPath: /stackable/scripts
@@ -66,16 +65,15 @@ data:
6665
from opensearchpy import OpenSearch
6766
from opensearchpy.exceptions import RequestError
6867
69-
namespace = os.environ['NAMESPACE']
68+
host = os.environ['OPENSEARCH_HOST']
69+
port = os.environ['OPENSEARCH_PORT']
70+
http_use_tls = os.environ['OPENSEARCH_PROTOCOL'] == 'https'
7071
7172
client = OpenSearch(
72-
hosts=[{
73-
'host': f'opensearch-2-nodes-default-headless.{namespace}.svc.cluster.local',
74-
'port': 9200
75-
}],
73+
hosts = [{'host': host, 'port': port}],
7674
http_auth=('admin', 'AJVFsGJBbpT6mChn'),
7775
http_compress=True,
78-
use_ssl=True,
76+
use_ssl=http_use_tls,
7977
verify_certs=True,
8078
ca_certs='/stackable/tls/ca.crt'
8179
)

tests/templates/kuttl/backup-restore/70-test-opensearch-2.yaml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ spec:
2222
# required for pip install
2323
- name: HOME
2424
value: /stackable
25-
- name: NAMESPACE
26-
valueFrom:
27-
fieldRef:
28-
fieldPath: metadata.namespace
25+
envFrom:
26+
- configMapRef:
27+
name: opensearch-2
2928
volumeMounts:
3029
- name: script
3130
mountPath: /stackable/scripts
@@ -66,17 +65,16 @@ data:
6665
from opensearchpy import OpenSearch
6766
from opensearchpy.exceptions import RequestError
6867
69-
namespace = os.environ['NAMESPACE']
68+
host = os.environ['OPENSEARCH_HOST']
69+
port = os.environ['OPENSEARCH_PORT']
70+
http_use_tls = os.environ['OPENSEARCH_PROTOCOL'] == 'https'
7071
7172
# Login as test user
7273
client = OpenSearch(
74+
hosts = [{'host': host, 'port': port}],
7375
http_auth=('testuser', 'L9hUHtLVVEsrcLzZ'),
74-
hosts=[{
75-
'host': f'opensearch-2-nodes-default-headless.{namespace}.svc.cluster.local',
76-
'port': 9200
77-
}],
7876
http_compress=True,
79-
use_ssl=True,
77+
use_ssl=http_use_tls,
8078
verify_certs=True,
8179
ca_certs='/stackable/tls/ca.crt'
8280
)

tests/templates/kuttl/external-access/20-assert.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ spec:
5757
apiVersion: v1
5858
kind: Service
5959
metadata:
60-
name: opensearch-discovery
60+
name: opensearch
6161
spec:
62-
type: ClusterIP
62+
type: NodePort # external-stable

tests/templates/kuttl/external-access/opensearch.yaml.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ spec:
1818
config:
1919
logging:
2020
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
21+
roleConfig:
22+
discoveryServiceListenerClass: test-external-stable-$NAMESPACE
2123
roleGroups:
2224
cluster-manager:
2325
config:

tests/templates/kuttl/ldap/30-test-opensearch.yaml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ spec:
2222
# required for pip install
2323
- name: HOME
2424
value: /stackable
25-
- name: NAMESPACE
26-
valueFrom:
27-
fieldRef:
28-
fieldPath: metadata.namespace
25+
envFrom:
26+
- configMapRef:
27+
name: opensearch
2928
volumeMounts:
3029
- name: script
3130
mountPath: /stackable/scripts
@@ -75,20 +74,17 @@ data:
7574
import os
7675
from opensearchpy import OpenSearch
7776
78-
namespace = os.environ['NAMESPACE']
79-
80-
host = f'opensearch-nodes-default-headless.{namespace}.svc.cluster.local'
81-
port = 9200
82-
auth = ('integrationtest', 'integrationtest')
83-
ca_certs_path = '/stackable/tls/ca.crt'
77+
host = os.environ['OPENSEARCH_HOST']
78+
port = os.environ['OPENSEARCH_PORT']
79+
http_use_tls = os.environ['OPENSEARCH_PROTOCOL'] == 'https'
8480
8581
client = OpenSearch(
86-
hosts = [{'host': host, 'port': port}],
87-
http_compress = True,
88-
http_auth = auth,
89-
use_ssl = True,
90-
verify_certs = True,
91-
ca_certs = ca_certs_path
82+
hosts = [{'host': host, 'port': port}],
83+
http_auth=('integrationtest', 'integrationtest'),
84+
http_compress=True,
85+
use_ssl=http_use_tls,
86+
verify_certs=True,
87+
ca_certs='/stackable/tls/ca.crt'
9288
)
9389
9490
# Create an index

0 commit comments

Comments
 (0)