Search in sources :

Example 6 with DeleteEntity

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

the class ClusterRoleBindingIT method delete.

@Test
public void delete() {
    ClusterRoleBindingList clusterRoleBindingListBefore = client.rbac().clusterRoleBindings().list();
    boolean deleted = client.rbac().clusterRoleBindings().withName("read-nodes-delete").delete();
    assertTrue(deleted);
    DeleteEntity<ClusterRoleBinding> clusterRoleBindingDeleteEntity = new DeleteEntity<>(ClusterRoleBinding.class, client, "read-nodes", null);
    await().atMost(30, TimeUnit.SECONDS).until(clusterRoleBindingDeleteEntity);
    ClusterRoleBindingList clusterRoleBindingListAfter = client.rbac().clusterRoleBindings().list();
    assertEquals(clusterRoleBindingListBefore.getItems().size() - 1, clusterRoleBindingListAfter.getItems().size());
}
Also used : ClusterRoleBindingList(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBindingList) ClusterRoleBinding(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding) DeleteEntity(io.fabric8.commons.DeleteEntity) Test(org.junit.Test)

Example 7 with DeleteEntity

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

the class DeleteIT method testDeleteResourceCascading.

@Test
public void testDeleteResourceCascading() {
    // Given
    String name = "deleteit-resource-cascading";
    // When
    ReplicaSet replicaSet = client.apps().replicaSets().inNamespace(session.getNamespace()).withName(name).get();
    Boolean isDeleted = client.resource(replicaSet).inNamespace(session.getNamespace()).cascading(true).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 8 with DeleteEntity

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

the class RoleBindingIT method delete.

@Test
public void delete() {
    int initialCountBeforeDeletion = client.rbac().roleBindings().inNamespace(session.getNamespace()).list().getItems().size();
    boolean deleted = client.rbac().roleBindings().inNamespace(session.getNamespace()).withName("rb-delete").delete();
    assertTrue(deleted);
    DeleteEntity<RoleBinding> deleteEntity = new DeleteEntity<>(RoleBinding.class, client, "read-jobs", session.getNamespace());
    await().atMost(60, TimeUnit.SECONDS).until(deleteEntity);
    RoleBindingList roleBindingList = client.rbac().roleBindings().inNamespace(session.getNamespace()).list();
    assertEquals(initialCountBeforeDeletion - 1, roleBindingList.getItems().size());
}
Also used : DeleteEntity(io.fabric8.commons.DeleteEntity) RoleBindingList(io.fabric8.kubernetes.api.model.rbac.RoleBindingList) RoleBinding(io.fabric8.kubernetes.api.model.rbac.RoleBinding) Test(org.junit.Test)

Example 9 with DeleteEntity

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

the class UserImpersonationIT method cleanup.

@After
public void cleanup() {
    // Reset original authentication
    RequestConfig requestConfig = client.getConfiguration().getRequestConfig();
    requestConfig.setImpersonateUsername(null);
    requestConfig.setImpersonateGroups((String) null);
    // DeleteEntity Cluster Role
    client.rbac().clusterRoles().delete(impersonatorRole);
    await().atMost(30, TimeUnit.SECONDS).until(kubernetesClusterRoleIsDeleted());
    // DeleteEntity Cluster Role binding
    client.rbac().clusterRoleBindings().delete(impersonatorRoleBinding);
    await().atMost(30, TimeUnit.SECONDS).until(kubernetesClusterRoleBindingIsDeleted());
    // DeleteEntity project
    client.projects().withName(NEW_PROJECT).delete();
    await().atMost(30, TimeUnit.SECONDS).until(projectIsDeleted());
    // DeleteEntity ServiceAccounts
    client.serviceAccounts().inNamespace(currentNamespace).delete(serviceAccount1);
    await().atMost(30, TimeUnit.SECONDS).until(serviceAccountIsDeleted());
}
Also used : RequestConfig(io.fabric8.kubernetes.client.RequestConfig) After(org.junit.After)

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