Skip to content

Commit f8cc1c7

Browse files
committed
working tests
1 parent 53ea8bc commit f8cc1c7

File tree

6 files changed

+73
-38
lines changed

6 files changed

+73
-38
lines changed

rust/operator-binary/src/discovery.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ pub fn build_endpoint_configmap(
113113

114114
for role_podref in role_podrefs {
115115
let role_name = role_podref.0;
116+
// podrefs are written into the collection by replica index
117+
// and can be retrieved in the same order
118+
let mut i = 0;
116119
for podref in role_podref.1 {
117120
if let HbasePodRef {
118121
fqdn_override: Some(fqdn_override),
@@ -122,12 +125,10 @@ pub fn build_endpoint_configmap(
122125
{
123126
if let Some(ui_port) = ports.get(&hbase.ui_port_name()) {
124127
cmm.add_data(
125-
format!("hbase.{role_name}.ui"),
128+
format!("hbase.{role_name}-{i}.ui"),
126129
format!("{fqdn_override}:{ui_port}"),
127130
);
128-
// the UI endpoint for one replica per role
129-
// is enough for the config map
130-
break;
131+
i += 1;
131132
}
132133
}
133134
}

rust/operator-binary/src/hbase_controller.rs

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -484,27 +484,36 @@ pub async fn reconcile_hbase(
484484

485485
let mut listener_refs: BTreeMap<String, Vec<HbasePodRef>> = BTreeMap::new();
486486

487-
for role in HbaseRole::iter() {
488-
listener_refs.insert(
489-
role.to_string(),
490-
hbase
491-
.listener_refs(client, &role, &resolved_product_image.product_version)
492-
.await
493-
.context(CollectDiscoveryConfigSnafu)?,
487+
// TODO if the listeners are persisted then they will still be present in the
488+
// cluster and can all be found. Or move this up into the role loop above and
489+
// only process those rolegroups where the listener class requires persistence.
490+
if hbase.spec.cluster_operation.reconciliation_paused || hbase.spec.cluster_operation.stopped {
491+
tracing::info!(
492+
"Cluster is in a transitional state so do not attempt to collect listener
493+
information that will only be active once cluster has exited transitional state."
494+
);
495+
} else {
496+
for role in HbaseRole::iter() {
497+
listener_refs.insert(
498+
role.to_string(),
499+
hbase
500+
.listener_refs(client, &role, &resolved_product_image.product_version)
501+
.await
502+
.context(CollectDiscoveryConfigSnafu)?,
503+
);
504+
}
505+
tracing::info!(
506+
"Listener references written to the ConfigMap {:#?}",
507+
listener_refs
494508
);
495-
}
496-
497-
tracing::info!(
498-
?listener_refs,
499-
"Listener references written to the ConfigMap"
500-
);
501509

502-
let endpoint_cm = build_endpoint_configmap(hbase, &resolved_product_image, listener_refs)
503-
.context(BuildDiscoveryConfigMapSnafu)?;
504-
cluster_resources
505-
.add(client, endpoint_cm)
506-
.await
507-
.context(ApplyDiscoveryConfigMapSnafu)?;
510+
let endpoint_cm = build_endpoint_configmap(hbase, &resolved_product_image, listener_refs)
511+
.context(BuildDiscoveryConfigMapSnafu)?;
512+
cluster_resources
513+
.add(client, endpoint_cm)
514+
.await
515+
.context(ApplyDiscoveryConfigMapSnafu)?;
516+
}
508517

509518
// Discovery CM will fail to build until the rest of the cluster has been deployed, so do it last
510519
// so that failure won't inhibit the rest of the cluster from booting up.

tests/templates/kuttl/external-access/30-access-hbase.txt.j2

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,36 @@ spec:
1919
- /bin/bash
2020
- /tmp/script/script.sh
2121
env:
22-
- name: MASTER_UI
22+
- name: MASTER_UI_0
2323
valueFrom:
2424
configMapKeyRef:
2525
name: test-hbase-ui-endpoints
26-
key: hbase.master.ui
27-
- name: REGIONSERVER_UI
26+
key: hbase.master-0.ui
27+
- name: MASTER_UI_1
2828
valueFrom:
2929
configMapKeyRef:
3030
name: test-hbase-ui-endpoints
31-
key: hbase.regionserver.ui
32-
- name: RESTSERVER_UI
31+
key: hbase.master-1.ui
32+
- name: REGIONSERVER_UI_0
3333
valueFrom:
3434
configMapKeyRef:
3535
name: test-hbase-ui-endpoints
36-
key: hbase.restserver.ui
36+
key: hbase.regionserver-0.ui
37+
- name: REGIONSERVER_UI_1
38+
valueFrom:
39+
configMapKeyRef:
40+
name: test-hbase-ui-endpoints
41+
key: hbase.regionserver-1.ui
42+
- name: RESTSERVER_UI_0
43+
valueFrom:
44+
configMapKeyRef:
45+
name: test-hbase-ui-endpoints
46+
key: hbase.restserver-0.ui
47+
- name: RESTSERVER_UI_1
48+
valueFrom:
49+
configMapKeyRef:
50+
name: test-hbase-ui-endpoints
51+
key: hbase.restserver-1.ui
3752
volumeMounts:
3853
- name: script
3954
mountPath: /tmp/script
@@ -55,11 +70,18 @@ data:
5570
script.sh: |
5671
set -euxo pipefail
5772

58-
echo "Attempting to reach master at $MASTER_UI..."
59-
curl --retry 0 -f -s -o /dev/null -w "%{http_code}" $MASTER_UI | grep 200
60-
echo "Attempting to reach region-server at $REGIONSERVER_UI..."
61-
curl --retry 0 -f -s -o /dev/null -w "%{http_code}" $REGIONSERVER_UI | grep 200
62-
echo "Attempting to reach rest-server at $RESTSERVER_UI..."
63-
curl --retry 0 -f -s -o /dev/null -w "%{http_code}" $RESTSERVER_UI | grep 200
73+
echo "Attempting to reach master at $MASTER_UI_0..."
74+
curl --retry 0 -f -s -o /dev/null -w "%{http_code}" "${MASTER_UI_0}" | grep 200
75+
echo "Attempting to reach region-server at $REGIONSERVER_UI_0..."
76+
curl --retry 0 -f -s -o /dev/null -w "%{http_code}" "${REGIONSERVER_UI_0}" | grep 200
77+
echo "Attempting to reach rest-server at $RESTSERVER_UI_0..."
78+
curl --retry 0 -f -s -o /dev/null -w "%{http_code}" "${RESTSERVER_UI_0}" | grep 200
79+
80+
echo "Attempting to reach master at $MASTER_UI_1..."
81+
curl --retry 0 -f -s -o /dev/null -w "%{http_code}" "${MASTER_UI_1}" | grep 200
82+
echo "Attempting to reach region-server at $REGIONSERVER_UI_1..."
83+
curl --retry 0 -f -s -o /dev/null -w "%{http_code}" "${REGIONSERVER_UI_1}" | grep 200
84+
echo "Attempting to reach rest-server at $RESTSERVER_UI_1..."
85+
curl --retry 0 -f -s -o /dev/null -w "%{http_code}" "${RESTSERVER_UI_1}" | grep 200
6486

6587
echo "All tests successful!"

tests/templates/kuttl/kerberos/30-install-hbase.yaml.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ commands:
2828
clusterConfig:
2929
hdfsConfigMapName: hdfs
3030
zookeeperConfigMapName: hbase-znode
31-
listenerClass: {{ test_scenario['values']['listener-class'] }}
3231
authentication:
3332
tlsSecretClass: tls
3433
kerberos:
@@ -41,6 +40,7 @@ commands:
4140
gracefulShutdownTimeout: 1m
4241
logging:
4342
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
43+
listenerClass: {{ test_scenario['values']['listener-class'] }}
4444
resources:
4545
memory:
4646
limit: 1536Mi
@@ -52,6 +52,7 @@ commands:
5252
gracefulShutdownTimeout: 1m
5353
logging:
5454
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
55+
listenerClass: {{ test_scenario['values']['listener-class'] }}
5556
roleGroups:
5657
default:
5758
replicas: 2
@@ -60,6 +61,7 @@ commands:
6061
gracefulShutdownTimeout: 1m
6162
logging:
6263
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
64+
listenerClass: {{ test_scenario['values']['listener-class'] }}
6365
roleGroups:
6466
default:
6567
replicas: 1

tests/templates/kuttl/opa/30-install-hbase.yaml.j2

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ commands:
5151
clusterConfig:
5252
hdfsConfigMapName: hdfs
5353
zookeeperConfigMapName: hbase-znode
54-
listenerClass: 'cluster-internal'
5554
authentication:
5655
tlsSecretClass: tls
5756
kerberos:

tests/templates/kuttl/smoke/30-install-hbase.yaml.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ spec:
1515
clusterConfig:
1616
hdfsConfigMapName: test-hdfs
1717
zookeeperConfigMapName: test-znode
18-
listenerClass: {{ test_scenario['values']['listener-class'] }}
1918
{% if lookup('env', 'VECTOR_AGGREGATOR') %}
2019
vectorAggregatorConfigMapName: vector-aggregator-discovery
2120
{% endif %}
2221
masters:
2322
config:
2423
logging:
2524
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
25+
listenerClass: {{ test_scenario['values']['listener-class'] }}
2626
roleGroups:
2727
default:
2828
configOverrides:
@@ -34,6 +34,7 @@ spec:
3434
config:
3535
logging:
3636
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
37+
listenerClass: {{ test_scenario['values']['listener-class'] }}
3738
roleGroups:
3839
default:
3940
configOverrides:
@@ -45,6 +46,7 @@ spec:
4546
config:
4647
logging:
4748
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
49+
listenerClass: {{ test_scenario['values']['listener-class'] }}
4850
resources:
4951
memory:
5052
limit: 1Gi

0 commit comments

Comments
 (0)