From 86c2e5afb4a32c614a8d0d602f620555dcf0cabe Mon Sep 17 00:00:00 2001 From: Genadi Date: Mon, 28 May 2018 10:25:36 +0300 Subject: [PATCH] Testing curl to the service of type LoadBalancer Create a service with 2 pods related to it Curl the service twice and check 2 different outputs Change-Id: I38655eb7b707c3ba36deab4b43998048dffcc74e --- kuryr_tempest_plugin/tests/scenario/base.py | 4 +-- .../tests/scenario/test_service.py | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/kuryr_tempest_plugin/tests/scenario/base.py b/kuryr_tempest_plugin/tests/scenario/base.py index 568ffece..77b38108 100644 --- a/kuryr_tempest_plugin/tests/scenario/base.py +++ b/kuryr_tempest_plugin/tests/scenario/base.py @@ -223,13 +223,13 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest): raise lib_exc.ServerFault() @classmethod - def create_setup_for_service_test(cls, pod_num=2): + def create_setup_for_service_test(cls, pod_num=2, spec_type="ClusterIP"): for i in range(pod_num): pod_name, pod = cls.create_pod( labels={"app": 'pod-label'}, image='celebdor/kuryr-demo') cls.addClassResourceCleanup(cls.delete_pod, pod_name) service_name, service_obj = cls.create_service( - pod_label=pod.metadata.labels) + pod_label=pod.metadata.labels, spec_type=spec_type) cls.service_ip = cls.get_service_ip(service_name) cls.wait_service_status( cls.service_ip, CONF.kuryr_kubernetes.lb_build_timeout) diff --git a/kuryr_tempest_plugin/tests/scenario/test_service.py b/kuryr_tempest_plugin/tests/scenario/test_service.py index 392572af..7d1731e1 100644 --- a/kuryr_tempest_plugin/tests/scenario/test_service.py +++ b/kuryr_tempest_plugin/tests/scenario/test_service.py @@ -68,3 +68,32 @@ class TestServiceScenario(base.BaseKuryrScenarioTest): LOG.error("Curl the service IP %s failed" % self.service_ip) raise lib_exc.UnexpectedResponseCode() self.assertNotEqual(cmp(cmd_output_list[0], cmd_output_list[1]), '0') + + +class TestLoadBalancerServiceScenario(base.BaseKuryrScenarioTest): + + @classmethod + def skip_checks(cls): + super(TestLoadBalancerServiceScenario, cls).skip_checks() + if not CONF.network_feature_enabled.floating_ips: + raise cls.skipException("Floating ips are not available") + + @classmethod + def resource_setup(cls): + super(TestLoadBalancerServiceScenario, cls).resource_setup() + cls.create_setup_for_service_test(spec_type="LoadBalancer") + + @decorators.idempotent_id('bddf5441-1244-449d-a175-b5fdcfc2a1a9') + def test_lb_service_curl(self): + cmd_output_list = list() + LOG.info("Trying to curl the service IP %s" % self.service_ip) + cmd = "curl {dst_ip}".format(dst_ip=self.service_ip) + for i in range(2): + try: + cmd_output_list.append( + subprocess.check_output(shlex.split(cmd))) + except subprocess.CalledProcessError: + LOG.error("Checking output of curl to the service IP %s " + "failed" % self.service_ip) + raise lib_exc.UnexpectedResponseCode() + self.assertNotEqual(cmp(cmd_output_list[0], cmd_output_list[1]), '0')