Search in sources :

Example 1 with DeleteEntity

use of io.fabric8.commons.DeleteEntity in project kubernetes-client by fabric8io.

the class ClusterRoleIT method delete.

@Test
public void delete() {
    ClusterRoleList clusterRoleListBefore = client.rbac().clusterRoles().list();
    boolean deleted = client.rbac().clusterRoles().withName("node-reader-delete").delete();
    assertTrue(deleted);
    DeleteEntity<ClusterRole> deleteEntity = new DeleteEntity<>(ClusterRole.class, client, "node-reader", null);
    await().atMost(30, TimeUnit.SECONDS).until(deleteEntity);
    ClusterRoleList clusterRoleListAfter = client.rbac().clusterRoles().list();
    assertEquals(clusterRoleListBefore.getItems().size() - 1, clusterRoleListAfter.getItems().size());
}
Also used : DeleteEntity(io.fabric8.commons.DeleteEntity) ClusterRoleList(io.fabric8.kubernetes.api.model.rbac.ClusterRoleList) ClusterRole(io.fabric8.kubernetes.api.model.rbac.ClusterRole) Test(org.junit.Test)

Example 2 with DeleteEntity

use of io.fabric8.commons.DeleteEntity in project kubernetes-client by fabric8io.

the class DeleteIT method testDeleteResource.

@Test
public void testDeleteResource() {
    // Given
    String name = "deleteit-resource";
    // When
    ReplicaSet replicaSet = client.apps().replicaSets().inNamespace(session.getNamespace()).withName(name).get();
    Boolean isDeleted = client.resource(replicaSet).inNamespace(session.getNamespace()).delete();
    // Then
    assertTrue(isDeleted);
    DeleteEntity<ReplicaSet> deleteEntity = new DeleteEntity<>(ReplicaSet.class, client, name, session.getNamespace());
    await().atMost(30, TimeUnit.SECONDS).until(deleteEntity);
}
Also used : DeleteEntity(io.fabric8.commons.DeleteEntity) ReplicaSet(io.fabric8.kubernetes.api.model.apps.ReplicaSet) Test(org.junit.Test)

Example 3 with DeleteEntity

use of io.fabric8.commons.DeleteEntity in project kubernetes-client by fabric8io.

the class DeleteIT method testDeleteResourcePropagationPolicyBackground.

@Test
public void testDeleteResourcePropagationPolicyBackground() {
    // Given
    String name = "deleteit-resource-background";
    // When
    ReplicaSet replicaSet = client.apps().replicaSets().inNamespace(session.getNamespace()).withName(name).get();
    Boolean isDeleted = client.resource(replicaSet).inNamespace(session.getNamespace()).withPropagationPolicy(DeletionPropagation.BACKGROUND).delete();
    // Then
    assertTrue(isDeleted);
    DeleteEntity<ReplicaSet> deleteEntity = new DeleteEntity<>(ReplicaSet.class, client, name, session.getNamespace());
    await().atMost(30, TimeUnit.SECONDS).until(deleteEntity);
}
Also used : DeleteEntity(io.fabric8.commons.DeleteEntity) ReplicaSet(io.fabric8.kubernetes.api.model.apps.ReplicaSet) Test(org.junit.Test)

Example 4 with DeleteEntity

use of io.fabric8.commons.DeleteEntity in project kubernetes-client by fabric8io.

the class DeleteIT method testDeleteResourcePropagationPolicyForeground.

@Test
public void testDeleteResourcePropagationPolicyForeground() {
    // Given
    String name = "deleteit-resource-foreground";
    // When
    ReplicaSet replicaSet = client.apps().replicaSets().inNamespace(session.getNamespace()).withName(name).get();
    Boolean isDeleted = client.resource(replicaSet).inNamespace(session.getNamespace()).withPropagationPolicy(DeletionPropagation.FOREGROUND).delete();
    // Then
    assertTrue(isDeleted);
    DeleteEntity<ReplicaSet> deleteEntity = new DeleteEntity<>(ReplicaSet.class, client, name, session.getNamespace());
    await().atMost(30, TimeUnit.SECONDS).until(deleteEntity);
}
Also used : DeleteEntity(io.fabric8.commons.DeleteEntity) ReplicaSet(io.fabric8.kubernetes.api.model.apps.ReplicaSet) Test(org.junit.Test)

Example 5 with DeleteEntity

use of io.fabric8.commons.DeleteEntity in project kubernetes-client by fabric8io.

the class RoleIT method delete.

@Test
public void delete() {
    int countBeforeDeletion = client.rbac().roles().inNamespace(currentNamespace).list().getItems().size();
    boolean deleted = client.rbac().roles().inNamespace(currentNamespace).withName("role-delete").delete();
    assertTrue(deleted);
    DeleteEntity<Role> deleteEntity = new DeleteEntity<>(Role.class, client, "role-delete", currentNamespace);
    await().atMost(30, TimeUnit.SECONDS).until(deleteEntity);
    RoleList roleList = client.rbac().roles().inNamespace(currentNamespace).list();
    assertEquals(countBeforeDeletion - 1, roleList.getItems().size());
}
Also used : Role(io.fabric8.kubernetes.api.model.rbac.Role) RoleList(io.fabric8.kubernetes.api.model.rbac.RoleList) DeleteEntity(io.fabric8.commons.DeleteEntity) Test(org.junit.Test)

Aggregations

DeleteEntity (io.fabric8.commons.DeleteEntity)8 Test (org.junit.Test)8 ReplicaSet (io.fabric8.kubernetes.api.model.apps.ReplicaSet)4 ClusterRole (io.fabric8.kubernetes.api.model.rbac.ClusterRole)1 ClusterRoleBinding (io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding)1 ClusterRoleBindingList (io.fabric8.kubernetes.api.model.rbac.ClusterRoleBindingList)1 ClusterRoleList (io.fabric8.kubernetes.api.model.rbac.ClusterRoleList)1 Role (io.fabric8.kubernetes.api.model.rbac.Role)1 RoleBinding (io.fabric8.kubernetes.api.model.rbac.RoleBinding)1 RoleBindingList (io.fabric8.kubernetes.api.model.rbac.RoleBindingList)1 RoleList (io.fabric8.kubernetes.api.model.rbac.RoleList)1 RequestConfig (io.fabric8.kubernetes.client.RequestConfig)1 After (org.junit.After)1