Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resiliency to the test. #1471

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -13,6 +13,8 @@ limitations under the License.

package io.kubernetes.client.e2e.basic

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

class CoreV1ApiTest extends Specification {
public deleteNamespace(CoreV1Api api, String namespace) {
try {
api.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 +48,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
}

}