Skip to content

Commit 0fd612d

Browse files
authored
use retry for getting token and verifying the http response from admin server (#3533)
* use retry for getting token and verifying the http response from adminserver * fix waitForPod in ingress installation * fix ingress deletion
1 parent 1cf89ec commit 0fd612d

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItConfigDistributionStrategy.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,9 +822,11 @@ private void verifyResourceJDBC1Override(boolean configUpdated) {
822822
for (int i = 1; i <= replicaCount; i++) {
823823
appURI = "dsTest=true&dsName=" + dsName1 + "&" + "serverName=" + managedServerNameBase + i;
824824
String dsConnectionPoolTestUrl = baseUri + appURI;
825-
HttpResponse<String> response = assertDoesNotThrow(() -> OracleHttpClient.get(dsConnectionPoolTestUrl, true));
826-
assertEquals(200, response.statusCode(), "Status code not equals to 200");
827-
assertTrue(response.body().contains("Connection successful"), "Didn't get Connection successful");
825+
testUntil(() -> {
826+
HttpResponse<String> response = assertDoesNotThrow(() -> OracleHttpClient.get(dsConnectionPoolTestUrl, true));
827+
logger.info("Http response status code {0} \n Http response body {1} ", response.statusCode(), response.body());
828+
return response.statusCode() == 200 && response.body().contains("Connection successful");
829+
}, logger, "Waiting for http response code 200 and message Connection successful");
828830
}
829831
}
830832

integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/Secret.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,15 @@ public static String getSecretOfServiceAccount(String namespace, String serviceA
9292
return saSecretName;
9393
}
9494

95-
private static boolean hasToken(String saSecretName, String namespace) throws ApiException {
95+
/**
96+
* Check if the secret has token.
97+
*
98+
* @param saSecretName name of the secret
99+
* @param namespace namespace in which secret exists
100+
* @return true if token in the secret exists otherwise false
101+
* @throws ApiException when there is issue getting secret
102+
*/
103+
public static boolean hasToken(String saSecretName, String namespace) throws ApiException {
96104
V1Secret secret = Kubernetes.getSecret(saSecretName, namespace);
97105
if (secret != null) {
98106
Map<String, byte[]> data = Optional.of(secret).map(V1Secret::getData).orElse(Collections.emptyMap());
@@ -109,6 +117,10 @@ private static boolean hasToken(String saSecretName, String namespace) throws Ap
109117
* @return the encoded token of the secret
110118
*/
111119
public static String getSecretEncodedToken(String namespace, String secretName) {
120+
testUntil(
121+
() -> hasToken(secretName, namespace),
122+
getLogger(),
123+
"Waiting for token to be populated in secret");
112124

113125
List<V1Secret> v1Secrets = new ArrayList<>();
114126

kubernetes/samples/charts/util/setupLoadBalancer.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,23 @@ createNameSpace() {
168168
waitForIngressPod() {
169169
type=$1
170170
ns=$2
171+
if [[ "${type}" == "traefik" ]]; then
172+
instance=${type}-release-${ns}
173+
elif [[ "${type}" == "nginx" ]]; then
174+
instance=${type}-release
175+
fi
171176

172177
printInfo "Wait (max 5min) until ${type} ingress controller pod to be ready."
173178
${kubernetesCli} wait --namespace ${ns} \
174179
--for=condition=ready pod \
175-
--selector=app.kubernetes.io/instance=${type}-release \
180+
--selector=app.kubernetes.io/instance=${instance} \
176181
--timeout=300s
177182

178183
if [ $? != 0 ]; then
179184
printError "${type} ingress controller pod not READY in state in 5 min"
180185
exit -1;
181186
else
182-
ipod=$(${kubernetesCli} get pod -n ${ns} -l app.kubernetes.io/instance=${type}-release -o jsonpath="{.items[0].metadata.name}")
187+
ipod=$(${kubernetesCli} get pod -n ${ns} -l app.kubernetes.io/instance=${instance} -o jsonpath="{.items[0].metadata.name}")
183188
${kubernetesCli} get po/${ipod} -n ${ns}
184189
helm list -n ${ns}
185190
fi
@@ -247,12 +252,19 @@ purgeDefaultResources() {
247252
deleteIngress() {
248253
type=${1}
249254
ns=${2}
255+
256+
if [[ "${type}" == "traefik" ]]; then
257+
instance=${type}-release-${ns}
258+
elif [[ "${type}" == "nginx" ]]; then
259+
instance=${type}-release
260+
fi
261+
250262
if [ "$(helm list --namespace $ns | grep $chart | wc -l)" = 1 ]; then
251263
printInfo "Deleting ${type} controller from namespace $ns"
252264
helm uninstall --namespace $ns $chart
253265
${kubernetesCli} wait --namespace ${ns} \
254266
--for=delete pod \
255-
--selector=app.kubernetes.io/instance=${type}-release \
267+
--selector=app.kubernetes.io/instance=${instance} \
256268
--timeout=120s
257269
if [ ${skipDeleteNamespace} == "false" ]; then
258270
${kubernetesCli} delete ns ${ns}

0 commit comments

Comments
 (0)