Skip to content

Commit

Permalink
making few changes to the testcases names and also changing the sanity
Browse files Browse the repository at this point in the history
tags 
adding support for control data interface  and removing  redundant cases
Closes-bug: #1782685

Change-Id: Ib00ffc66e1e3c9227412f15875de1a9e426d944f
  • Loading branch information
vvelpula committed Jul 25, 2018
1 parent df433a5 commit ddd920a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 114 deletions.
114 changes: 22 additions & 92 deletions scripts/k8s_scripts/test_service.py
Expand Up @@ -15,6 +15,10 @@ class TestService(BaseK8sTest):
@classmethod
def setUpClass(cls):
super(TestService, cls).setUpClass()
if cls.inputs.compute_control_ips:
cls.cn_list = list(cls.inputs.compute_control_ips)
else:
cls.cn_list = list(cls.inputs.compute_ips)

@classmethod
def tearDownClass(cls):
Expand Down Expand Up @@ -53,116 +57,42 @@ def test_service_1(self):
# end test_service_1

@preposttest_wrapper
def test_service_type_nodeport_without_namespace_isolation(self):
def test_service_type_nodeport(self):
''' Create a service with 2 pods running nginx
Create a third busybox pod and validate that webservice is
load-balanced using NodePort service from with in the cluster
outside of the cluster
'''
app = 'http_nodeport_test'
labels = {'app': app}
namespace = self.setup_namespace("ns1")
assert namespace.verify_on_setup()

service = self.setup_http_service(namespace=namespace.name,
labels=labels, type="NodePort")
pod1 = self.setup_nginx_pod(namespace=namespace.name, labels=labels)
pod2 = self.setup_nginx_pod(namespace=namespace.name, labels=labels)
pod3 = self.setup_busybox_pod(namespace=namespace.name)
service = self.setup_http_service(labels=labels, type="NodePort")
pod1 = self.setup_nginx_pod(labels=labels)
pod2 = self.setup_nginx_pod(labels=labels)
pod3 = self.setup_busybox_pod()

namespace = self.setup_namespace()
assert namespace.verify_on_setup()
pod4 = self.setup_busybox_pod(namespace=namespace.name)

assert self.verify_nginx_pod(pod1)
assert self.verify_nginx_pod(pod2)
assert pod3.verify_on_setup()
# validate Service Nodeport functionality with load-balancing on the service
for node_ip in self.inputs.k8s_slave_ips:
assert self.validate_nginx_lb([pod1, pod2], node_ip,
test_pod=pod3,
nodePort=service.nodePort)
assert self.validate_nginx_lb([pod1, pod2], node_ip,
nodePort=service.nodePort)
# end test_service_type_nodeport__without_namespace_isolation
assert pod4.verify_on_setup()
assert service.verify_on_setup()

@preposttest_wrapper
def test_service_type_nodeport_with_namespace_isolation(self):
''' Create a service with 2 pods running nginx
Create a third busybox pod and validate that webservice is
load-balanced using NodePort service using NodePort service from with in the cluster
outside of the cluster with namespace isolation

'''
app = 'http_nodeport_test'
labels = {'app': app}
namespace1_name = get_random_name("ns1")
namespace2_name = get_random_name("ns2")
namespace1 = self.setup_namespace(name = namespace1_name, isolation = True)
namespace2 = self.setup_namespace(name = namespace2_name, isolation = True)
assert namespace1.verify_on_setup()
assert namespace2.verify_on_setup()
service = self.setup_http_service(namespace=namespace1.name,
labels=labels, type="NodePort")
pod1 = self.setup_nginx_pod(namespace=namespace1.name, labels=labels)
pod2 = self.setup_nginx_pod(namespace=namespace1.name, labels=labels)
pod3 = self.setup_busybox_pod(namespace=namespace1.name)
pod4 = self.setup_busybox_pod(namespace=namespace2.name)
assert self.verify_nginx_pod(pod1)
assert self.verify_nginx_pod(pod2)
assert pod3.verify_on_setup()
# validate Service Nodeport functionality with load-balancing on the service
for node_ip in self.inputs.k8s_slave_ips:
for node_ip in self.cn_list:
assert self.validate_nginx_lb([pod1, pod2], node_ip,
test_pod=pod3,
nodePort=service.nodePort)
#access the Nodeport from outside the cluster
assert self.validate_nginx_lb([pod1, pod2], node_ip,
nodePort=service.nodePort)
assert self.validate_nginx_lb([pod1, pod2], node_ip,
test_pod=pod4,
if self.setup_namespace_isolation:
assert self.validate_nginx_lb([pod1, pod2], service.cluster_ip,
test_pod = pod4,
nodePort=service.nodePort,
expectation=False)
# end test_service_type_nodeport_with_namespace_isolation

@preposttest_wrapper
def test_service_type_nodeport_with_namespace_isolation_with_userdefined_nodeport(self):
''' Create a service with 2 pods running nginx
Create a third busybox pod and validate that webservice is
load-balanced NodePort service from with in the cluster
outside of the cluster with user defied noport
'''
app = 'http_nodeport_test'
labels = {'app': app}
user_node_port = 31111
namespace1_name = get_random_name("ns1")
namespace2_name = get_random_name("ns2")
namespace1 = self.setup_namespace(name = namespace1_name, isolation = True)
namespace2 = self.setup_namespace(name = namespace2_name, isolation = True)
assert namespace1.verify_on_setup()
assert namespace2.verify_on_setup()
service = self.setup_http_service(namespace=namespace1.name,
labels=labels, type="NodePort", nodePort = user_node_port)
pod1 = self.setup_nginx_pod(namespace=namespace1.name, labels=labels)
pod2 = self.setup_nginx_pod(namespace=namespace1.name, labels=labels)
pod3 = self.setup_busybox_pod(namespace=namespace1.name)
pod4 = self.setup_busybox_pod(namespace=namespace2.name)
assert self.verify_nginx_pod(pod1)
assert self.verify_nginx_pod(pod2)
assert pod3.verify_on_setup()
assert (service.nodePort == user_node_port) , "service should be having the node port which is user provided"
# validate Service Nodeport functionality with load-balancing on the service
for node_ip in self.inputs.k8s_slave_ips:
assert self.validate_nginx_lb([pod1, pod2], node_ip,
test_pod=pod3,
nodePort=user_node_port)
#access the Nodeport from outside the cluster
assert self.validate_nginx_lb([pod1, pod2], node_ip,
nodePort=user_node_port)
assert self.validate_nginx_lb([pod1, pod2], node_ip,
test_pod=pod4,
nodePort=user_node_port,
expectation=False)
# end test_service_type_nodeport_with_namespace_isolation

expectation=False)

# end test_service_type_nodeport__without_namespace_isolation

@skip_because(mx_gw = False)
@preposttest_wrapper
Expand Down Expand Up @@ -310,7 +240,7 @@ def test_kube_dns_lookup(self):
lookup_str = 'nslookup kubernetes.default.svc.cluster.local'
output = client_pod.run_cmd(lookup_str)
msg = 'DNS resolution failed'
assert 'nslookup: can\'t resolve' not in output, msg
assert ('connection timed out' not in output) and ('nslookup: can\'t resolve' not in output), msg
self.logger.info('DNS resolution check : %s passed. Output: %s' % (
lookup_str, output))
# end test_kube_dns_lookup
Expand Down
47 changes: 25 additions & 22 deletions serial_scripts/k8s_scripts/test_service.py
Expand Up @@ -14,6 +14,10 @@ class TestService(BaseK8sTest):
@classmethod
def setUpClass(cls):
super(TestService, cls).setUpClass()
if cls.inputs.compute_control_ips:
cls.cn_list = list(cls.inputs.compute_control_ips)
else:
cls.cn_list = list(cls.inputs.compute_ips)

@classmethod
def tearDownClass(cls):
Expand All @@ -23,7 +27,6 @@ def parallel_cleanup(self):
parallelCleanupCandidates = ["PodFixture"]
self.delete_in_parallel(parallelCleanupCandidates)

@test.attr(type=['k8s_sanity'])
@skip_because(mx_gw = False)
@preposttest_wrapper
def test_service_with_kube_manager_restart(self):
Expand Down Expand Up @@ -84,30 +87,25 @@ def common_checks_for_nodeport_service(self, svclist, pdslist) :
a. with in the same namespace
b. from the different namespace
"""
for node_ip in self.inputs.k8s_slave_ips:
import pdb;pdb.set_trace()
for node_ip in self.cn_list :
assert self.validate_nginx_lb([pdslist[0], pdslist[1]], node_ip,
test_pod=pdslist[2],
nodePort=svclist[0].nodePort)
assert self.validate_nginx_lb([pdslist[3], pdslist[4]], node_ip,
assert self.validate_nginx_lb([pdslist[0], pdslist[1]], svclist[0].cluster_ip,
test_pod=pdslist[5],
nodePort=svclist[0].nodePort,
expectation=False)
assert self.validate_nginx_lb([pdslist[3], pdslist[4]], node_ip,
nodePort=svclist[1].nodePort)

#access the Nodeport from outside the cluster
#access the Nodeport from outside the namespace
assert self.validate_nginx_lb([pdslist[0], pdslist[1]], node_ip,
test_pod = pdslist[6],
nodePort=svclist[0].nodePort)

assert self.validate_nginx_lb([pdslist[3], pdslist[4]], node_ip,
test_pod = pdslist[6],
nodePort=svclist[1].nodePort)

#access the Nodeport from outside of the anmespaces
assert self.validate_nginx_lb([pdslist[0], pdslist[1]], node_ip,
test_pod=pdslist[5],
nodePort=svclist[0].nodePort,
expectation=False)
assert self.validate_nginx_lb([pdslist[3], pdslist[4]], node_ip,
test_pod=pdslist[2],
nodePort=svclist[1].nodePort,
expectation=False)
#End of common_checks_for_nodeport_service

def common_setup_for_nodeport(self, userport=None, tag1="http_nodeport_test",
Expand All @@ -119,10 +117,13 @@ def common_setup_for_nodeport(self, userport=None, tag1="http_nodeport_test",
labels1 = {'app': tag2}
namespace1_name = get_random_name("ns1")
namespace2_name = get_random_name("ns2")
namespace3_name = get_random_name("ns3")
namespace1 = self.setup_namespace(name=namespace1_name, isolation=isolation)
namespace2 = self.setup_namespace(name=namespace2_name, isolation=isolation)
namespace3 = self.setup_namespace(name=namespace3_name, isolation=isolation, ip_fabric_forwarding=True)
assert namespace1.verify_on_setup()
assert namespace2.verify_on_setup()
assert namespace3.verify_on_setup()
service_in_ns1 = self.setup_http_service(namespace=namespace1.name,
labels=labels, type="NodePort", nodePort=userport)
service_in_ns2 = self.setup_http_service(namespace=namespace2.name,
Expand All @@ -133,19 +134,21 @@ def common_setup_for_nodeport(self, userport=None, tag1="http_nodeport_test",
pod4 = self.setup_nginx_pod(namespace=namespace2.name, labels=labels1)
pod5 = self.setup_nginx_pod(namespace=namespace2.name, labels=labels1)
pod6 = self.setup_busybox_pod(namespace=namespace2.name)
pod7 = self.setup_busybox_pod(namespace=namespace3.name)
assert self.verify_nginx_pod(pod1)
assert self.verify_nginx_pod(pod2)
assert self.verify_nginx_pod(pod4)
assert self.verify_nginx_pod(pod5)
assert self.verify_nginx_pod(pod7)
assert pod3.verify_on_setup()
assert pod6.verify_on_setup()
namespace_list=[namespace1,namespace2]
service_list=[service_in_ns1,service_in_ns2]
pod_list=[pod1,pod2,pod3,pod4,pod5,pod6]
pod_list=[pod1,pod2,pod3,pod4,pod5,pod6,pod7]
return (service_list,pod_list)

@preposttest_wrapper
def test_kubelet_restart_on_slaves_with_multiple_nodeport_servoces_with_namespace_isolation(self):
def test_kubelet_restart_on_slaves_with_nodeport_services(self):
app1 = 'http_nodeport_test1'
user_node_port = 31111
(svc,pds) = self.common_setup_for_nodeport(user_node_port, tag2=app1)
Expand All @@ -157,7 +160,7 @@ def test_kubelet_restart_on_slaves_with_multiple_nodeport_servoces_with_namespac
self.common_checks_for_nodeport_service(svc,pds)

@preposttest_wrapper
def test_docker_restart_on_slaves_with_multiple_nodeports_with_namespace_isolation(self):
def test_docker_restart_on_slaves_with_nodeport_services(self):
user_node_port = 30001
(svc,pds) = self.common_setup_for_nodeport(user_node_port)
assert (svc[0].nodePort == user_node_port),"nodeport is not refclecting"
Expand All @@ -168,7 +171,7 @@ def test_docker_restart_on_slaves_with_multiple_nodeports_with_namespace_isolati
self.common_checks_for_nodeport_service(svc, pds)

@preposttest_wrapper
def test_vrouter_restart_on_slaves_with_multiple_nodeports_with_namespace_isolation(self):
def test_vrouter_restart_on_slaves_with_nodeports(self):
(svc,pds) = self.common_setup_for_nodeport()
self.common_checks_for_nodeport_service(svc, pds)
# Restart Vrouter agent
Expand All @@ -177,23 +180,23 @@ def test_vrouter_restart_on_slaves_with_multiple_nodeports_with_namespace_isolat

@test.attr(type=['k8s_sanity'])
@preposttest_wrapper
def test_kube_manager_restart_with_multiple_nodeport_services_with_namespace_isolation(self):
def test_kube_manager_restart_with_nodeport_services(self):
(svc,pds) = self.common_setup_for_nodeport()
self.common_checks_for_nodeport_service(svc, pds)
# Restart Kube manager
self.restart_kube_manager()
self.common_checks_for_nodeport_service(svc, pds)

@preposttest_wrapper
def test_reboot_slaves_with_multiple_nodeport_servoces_with_namespace_isolation(self):
def test_reboot_slaves_with_nodeport_services(self):
(svc,pds) = self.common_setup_for_nodeport()
self.common_checks_for_nodeport_service(svc, pds)
for node in self.inputs.k8s_slave_ips:
self.inputs.reboot(node)
self.common_checks_for_nodeport_service(svc, pds)

@preposttest_wrapper
def test_docker_restart_on_master_with_multiple_nodeport_servoces_with_namespace_isolation(self):
def test_docker_restart_on_master_with_nodeport_services(self):
user_node_port = 30002
(svc,pds) = self.common_setup_for_nodeport(user_node_port)
assert (svc[0].nodePort == user_node_port),"nodeport is not refclecting"
Expand Down

0 comments on commit ddd920a

Please sign in to comment.