    @Test
    public void testAll() throws IOException, ApiException, InterruptedException {

        KubeHelper.inst("").delete("ns-test", KubeRES.NAME_SPACE);

        Assert.assertFalse(KubeHelper.inst("").exist("ns-test", KubeRES.NAME_SPACE));
        KubeHelper.inst("").create($.file.readAllByClassPath("ns-test.yaml", "UTF-8"));
        Assert.assertTrue(KubeHelper.inst("").exist("ns-test", KubeRES.NAME_SPACE));
        Assert.assertEquals("Active",
                KubeHelper.inst("").read("ns-test", KubeRES.NAME_SPACE, V1Namespace.class).getStatus().getPhase());

        V1Deployment deployment = buildDeployment();
        CountDownLatch cdl = new CountDownLatch(1);
        final String watchId = KubeHelper.inst("").watch((coreApi, appApi, extensionsApi, rbacAuthorizationApi, autoscalingApi)
                        -> appApi
                        .listNamespacedDeploymentCall(
                                deployment.getMetadata().getNamespace(),
                                null, null, null, null, "name=test-nginx", 1, null, null, Boolean.TRUE, null),
                resp -> {
                    System.out.printf("%s : %s%n", resp.type, $.json.toJsonString(resp.object.getStatus()));
                    if (resp.object.getStatus().getReadyReplicas() != null
                            && resp.object.getStatus().getAvailableReplicas() != null
                            && resp.object.getStatus().getReadyReplicas() == 2
                            && resp.object.getStatus().getAvailableReplicas() == 2) {
                        try {
                            long runningPodSize = KubeHelper.inst("")
                                    .list("name=nginx", "ns-test", KubeRES.POD, V1Pod.class)
                                    .stream().filter(pod ->
                                            pod.getStatus().getPhase().equalsIgnoreCase("Running")
                                                    && pod.getStatus().getContainerStatuses().stream().allMatch(V1ContainerStatus::getReady)
                                    )
                                    .count();
                            if (2 != runningPodSize) {
                                // 之前版本没有销毁
                                Thread.sleep(1000);
                            }
                        } catch (ApiException | InterruptedException e) {
                            e.printStackTrace();
                        }
                        cdl.countDown();
                    }

                },
                V1Deployment.class);
        Assert.assertFalse(
                KubeHelper.inst("").exist(deployment.getMetadata().getName(), deployment.getMetadata().getNamespace(), KubeRES.DEPLOYMENT));
        KubeHelper.inst("").apply(deployment);
        Assert.assertTrue(
                KubeHelper.inst("").exist(deployment.getMetadata().getName(), deployment.getMetadata().getNamespace(), KubeRES.DEPLOYMENT));

        Assert.assertEquals(1, KubeHelper.inst("").list(
                "",
                deployment.getMetadata().getNamespace(),
                KubeRES.DEPLOYMENT,
                V1Deployment.class).size());
        Assert.assertEquals(0, KubeHelper.inst("").list(
                "name=nginx",
                deployment.getMetadata().getNamespace(),
                KubeRES.DEPLOYMENT,
                V1Deployment.class).size());
        Assert.assertEquals(1, KubeHelper.inst("").list(
                "name=test-nginx",
                deployment.getMetadata().getNamespace(),
                KubeRES.DEPLOYMENT,
                V1Deployment.class).size());

        // 避免各pod的startTime相同
        Thread.sleep(1000);
        KubeHelper.inst("").patch("nginx-deployment", new ArrayList<>() {
            {
                add("{\"op\":\"replace\",\"path\":\"/spec/replicas\",\"value\":2}");
                add("{\"op\":\"replace\",\"path\":\"/spec/template/spec/containers/0/image\",\"value\":\"nginx:latest\"}");
            }
        }, "ns-test", KubeRES.DEPLOYMENT);
        V1Deployment fetchedDeployment = KubeHelper.inst("").read(deployment.getMetadata().getName(),
                deployment.getMetadata().getNamespace(),
                KubeRES.DEPLOYMENT,
                V1Deployment.class);

        Assert.assertEquals(2, fetchedDeployment.getSpec().getReplicas().intValue());
        Assert.assertEquals("nginx:latest", fetchedDeployment.getSpec().getTemplate().getSpec().getContainers().get(0).getImage());
        Assert.assertEquals("test-nginx", fetchedDeployment.getMetadata().getLabels().get("name"));

        cdl.await();

        List<V1Pod> pods = KubeHelper.inst("").list(
                "app=nginx",
                deployment.getMetadata().getNamespace(),
                KubeRES.POD,
                V1Pod.class)
                .stream()
                .filter(pod -> pod.getStatus().getPhase().equalsIgnoreCase("Running"))
                .sorted((m1, m2) ->
                        Long.compare(m2.getStatus().getStartTime().getMillis(), m1.getStatus().getStartTime().getMillis()))
                .collect(Collectors.toList());
        String podName = pods.get(0).getMetadata().getName();
        List<String> execResult = KubeHelper.inst("").exec(podName, null, deployment.getMetadata().getNamespace(),
                new String[]{
                        "sh",
                        "-c",
                        "ls -l"
                });
        Assert.assertTrue(execResult.get(0).contains("total"));

        /* Closeable closeable = KubeHelper.inst("").forward(podName, deployment.getMetadata().getNamespace(), 80, 8081);

        Assert.assertTrue($.http.get("http://127.0.0.1:8081").contains("Welcome to nginx!"));
        Assert.assertTrue($.http.get("http://127.0.0.1:8081").contains("Welcome to nginx!"));

        closeable.close();
        */
        // TODO
        /*
        Ngnix没有日志输出，程序会一直等待
        List<String> logs = KubeHelper.inst("").log(podName, "ns-test");
        logs.forEach(System.out::println);
        */


        KubeHelper.inst("").stopWatch(watchId);
        KubeHelper.inst("").delete("ns-test", KubeRES.NAME_SPACE);
        Assert.assertFalse(KubeHelper.inst("").exist("ns-test", KubeRES.NAME_SPACE));
    }