Skip to content

Commit

Permalink
Add resiliency to the test.
Browse files Browse the repository at this point in the history
  • Loading branch information
brendandburns committed Jan 5, 2021
1 parent 614f0de commit 4453859
Showing 1 changed file with 18 additions and 2 deletions.
Expand Up @@ -13,7 +13,9 @@ limitations under the License.

package io.kubernetes.client.e2e.basic

import com.google.gson.JsonSyntaxException
import io.kubernetes.client.openapi.Configuration
import io.kubernetes.client.openapi.apis.ApiException
import io.kubernetes.client.openapi.apis.CoreV1Api
import io.kubernetes.client.openapi.models.V1Namespace
import io.kubernetes.client.openapi.models.V1ObjectMeta
Expand All @@ -22,6 +24,20 @@ import io.kubernetes.client.util.ClientBuilder
import spock.lang.Specification

class CoreV1ApiTest extends Specification {
public deleteNamespace(CoreV1Api api, String namespace) {
try {
CoreV1Api coreV1Api = new CoreV1Api(apiClient);
coreV1Api.deleteNamespace(namespace, null, null, null, null, null, null);
} catch (ApiException ex) {
if (ex.getCode() != HttpURLConnection.HTTP_NOT_FOUND) {
throw ex;
}
} catch (JsonSyntaxException ex) {
// Delete returned v1Status, try again.
deleteNamespace(api, namespace);
}
}

def "Create Namespace then Delete should work"() {
given:
def apiClient = ClientBuilder.defaultClient()
Expand All @@ -33,9 +49,9 @@ class CoreV1ApiTest extends Specification {
then:
created != null
when:
V1Status deleted = corev1api.deleteNamespace("e2e-basic", null, null, null, null, null, null)
boolean deleted = deleteNamespace(corev1api, "e2e-basic");
then:
deleted != null
deleted == true
}

}

0 comments on commit 4453859

Please sign in to comment.