@@ -0,0 +1,2937 @@
+import os%0Aimport pytest%0Aimport subprocess%0Afrom .common import random_str%0Afrom .conftest import cluster_and_client, ClusterContext%0A%0Akube_fname = os.path.join(os.path.dirname(os.path.realpath(__file__)),%0A                          %22k8s_kube_config%22)%0Aistio_crd_url = %22https://raw.githubusercontent.com/istio/istio/1.1.5%22 %5C%0A                %22/install/kubernetes/helm/istio-init/files/crd-10.yaml%22%0A%0A%0Adef test_virtual_service(admin_pc):%0A    client = admin_pc.client%0A    ns = admin_pc.cluster.client.create_namespace(%0A        name=random_str(),%0A        projectId=admin_pc.project.id)%0A    name = random_str()%0A    client.create_virtualService(%0A        name=name,%0A        namespaceId=ns.id,%0A        hosts=%5B%22test%22%5D,%0A        http=%5B%7B%0A            %22route%22: %5B%0A                %7B%0A                    %22destination%22: %7B%0A                        %22host%22: %22test%22,%0A                        %22subset%22: %22v1%22%0A                    %7D%0A                %7D%0A            %5D%0A        %7D%5D,%0A    )%0A    virtualServices = client.list_virtualService(%0A        namespaceId=ns.id%0A    )%0A    assert len(virtualServices) == 1%0A    client.delete(virtualServices.data%5B0%5D)%0A    client.delete(ns)%0A%0A%0Adef test_destination_rule(admin_pc):%0A    client = admin_pc.client%0A    ns = admin_pc.cluster.client.create_namespace(%0A        name=random_str(),%0A        projectId=admin_pc.project.id)%0A    name = random_str()%0A    client.create_destinationRule(%0A        name=name,%0A        namespaceId=ns.id,%0A        host=%22test%22,%0A        subsets=%5B%7B%0A            %22name%22: %22v1%22,%0A            %22labels%22: %7B%0A                %22version%22: %22v1%22,%0A            %7D%0A        %7D%5D,%0A    )%0A    destinationRules = client.list_destinationRule(%0A        namespaceId=ns.id%0A    )%0A    assert len(destinationRules) == 1%0A    client.delete(destinationRules.data%5B0%5D)%0A    client.delete(ns)%0A%0A%0A@pytest.fixture(scope='module', autouse=%22True%22)%0Adef install_crd(admin_mc):%0A    cluster, client = cluster_and_client('local', admin_mc.client)%0A    cc = ClusterContext(admin_mc, cluster, client)%0A    create_kubeconfig(cc.cluster)%0A    try:%0A        return subprocess.check_output(%0A            'kubectl apply ' +%0A            ' --kubeconfig ' + kube_fname +%0A            ' -f ' + istio_crd_url,%0A            stderr=subprocess.STDOUT, shell=True,%0A        )%0A    except subprocess.CalledProcessError as err:%0A        print('kubectl error: ' + str(err.output))%0A        raise err%0A%0A%0Adef teardown_module(module):%0A    try:%0A        return subprocess.check_output(%0A            'kubectl delete ' +%0A            ' --kubeconfig ' + kube_fname +%0A            ' -f ' + istio_crd_url,%0A            stderr=subprocess.STDOUT, shell=True,%0A        )%0A    except subprocess.CalledProcessError as err:%0A        print('kubectl error: ' + str(err.output))%0A        raise err%0A%0A%0Adef create_kubeconfig(cluster):%0A    generateKubeConfigOutput = cluster.generateKubeconfig()%0A    print(generateKubeConfigOutput.config)%0A    file = open(kube_fname, %22w%22)%0A    file.write(generateKubeConfigOutput.config)%0A    file.close()%0A

Add integration tests for VirtualService and DestinationRule