Skip to content

Commit 388d38f

Browse files
wip
1 parent 1fc89f6 commit 388d38f

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

.github/workflows/end2end.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ jobs:
502502
- name: Setup PRA test environment
503503
env:
504504
ZENKO_NAME: "${{ env.ZENKO_NAME }}-pra"
505+
MANAGEMENT_INSTANCE: "${{ env.ZENKO_NAME }}"
505506
SETUP_IMAGE: ${{ needs.build-setup-image.outputs.image }}
506507
GIT_ACCESS_TOKEN: ${{ steps.app-token.outputs.token }}
507508
run: ./setup-tests.sh --kubeconfig ~/.kube/config

tests/@setup/setup-tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ spec:
145145
args:
146146
$(for arg in "${setup_args[@]}"; do echo " - \"${arg}\""; done)
147147
env:
148+
- name: MANAGEMENT_INSTANCE
149+
value: "${MANAGEMENT_INSTANCE}"
148150
- name: ENABLE_RING_TESTS
149151
value: "${ENABLE_RING_TESTS}"
150152
- name: KAFKA_IMAGE

tests/@setup/src/utils/management.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,15 @@ export interface AccountResponse {
4646

4747
/**
4848
* Get management endpoint
49+
* For PRA instances, the Management API endpoint is shared (only deployed on primary instance)
4950
* @param subdomain - Subdomain
5051
* @returns Management endpoint
5152
*/
5253
export async function getManagementEndpoint(subdomain: string = 'zenko.local'): Promise<string> {
54+
const managementInstance = process.env.MANAGEMENT_INSTANCE;
55+
if (managementInstance) {
56+
logger.info(`Using Management API from primary instance: ${managementInstance} (target: ${process.env.ZENKO_NAME})`);
57+
}
5358
return `http://management.${subdomain}`;
5459
}
5560

@@ -117,22 +122,29 @@ export async function getManagementToken(subdomain: string = 'zenko.local'): Pro
117122
}
118123

119124
/**
120-
* Get instance ID
125+
* Get instance ID from the target Zenko CR
126+
* NOTE: This returns the TARGET instance's ID (e.g., PRA), which is used when creating locations
127+
* @param zenkoName - Optional Zenko CR name to override ZENKO_NAME env var
121128
* @returns Instance ID
122129
*/
123-
export async function getInstanceId(): Promise<string | null> {
130+
export async function getInstanceId(zenkoName?: string): Promise<string | null> {
124131
if (!KubernetesHelper.customObject) {
125132
throw new Error('KubernetesHelper not initialized');
126133
}
134+
const targetZenkoName = zenkoName || process.env.ZENKO_NAME || 'end2end';
135+
logger.debug(`Getting instanceId from Zenko CR: ${targetZenkoName}`);
136+
127137
const instanceId = await KubernetesHelper.customObject.getNamespacedCustomObject({
128138
group: 'zenko.io',
129139
version: 'v1alpha2',
130140
namespace: process.env.NAMESPACE || 'default',
131141
plural: 'zenkos',
132-
name: process.env.ZENKO_NAME || 'end2end',
142+
name: targetZenkoName,
133143
});
134144

135-
return instanceId.status?.instanceID || process.env.INSTANCE_ID;
145+
const id = instanceId.status?.instanceID || process.env.INSTANCE_ID;
146+
logger.info(`Using instanceId: ${id} from Zenko CR: ${targetZenkoName}`);
147+
return id;
136148
}
137149

138150
/**

0 commit comments

Comments
 (0)