github.com/SUSE/skuba@v1.4.17/ci/infra/testrunner/tests/test_cilium.py (about)

     1  import logging
     2  import re
     3  import time
     4  
     5  import pytest
     6  
     7  from tests.utils import wait
     8  
     9  logger = logging.getLogger("testrunner")
    10  
    11  
    12  @pytest.mark.flaky
    13  def test_cillium(deployment, kubectl):
    14      landing_req = 'curl -sm10 -XPOST deathstar.default.svc.cluster.local/v1/request-landing'
    15  
    16      logger.info("Deploy deathstar")
    17      kubectl.run_kubectl("create -f https://raw.githubusercontent.com/cilium/cilium/v1.6/examples/minikube/http-sw-app.yaml")
    18  
    19      # FIXME: This check should be only get the star wars application's pods
    20      wait(kubectl.run_kubectl,
    21           "wait --for=condition=ready pods --all --timeout=0",
    22           wait_delay=30,
    23           wait_timeout=10,
    24           wait_backoff=30,
    25           wait_elapsed=180)
    26  
    27      # FIXME: this hardcoded wait should be replaces with a (cilum?) condition
    28      time.sleep(100)
    29  
    30      logger.info("Check with L3/L4 policy")
    31      kubectl.run_kubectl("create -f https://raw.githubusercontent.com/cilium/cilium/v1.6/examples/minikube/sw_l3_l4_policy.yaml")
    32      tie_out = kubectl.run_kubectl("exec tiefighter -- {}".format(landing_req))
    33      assert 'Ship landed' in tie_out
    34  
    35      xwing_out = kubectl.run_kubectl("exec xwing -- {} 2>&1 || :".format(landing_req))
    36      assert 'terminated with exit code 28' in xwing_out
    37  
    38      logger.info("Check status (N/N)")
    39      node_list = kubectl.run_kubectl("get nodes -o jsonpath='{ .items[*].metadata.name }'")
    40      node_count = len(node_list.split(" "))
    41      cilium_podlist = kubectl.run_kubectl("get pods -n kube-system -l k8s-app=cilium -o jsonpath='{ .items[0].metadata.name }'").split(" ")
    42      cilium_podid = cilium_podlist[0]
    43      cilium_status_cmd = "-n kube-system exec {} -- cilium status".format(cilium_podid)
    44      cilium_status = kubectl.run_kubectl(cilium_status_cmd)
    45      assert re.search(r'Controller Status:\s+([0-9]+)/\1 healthy', cilium_status) is not None
    46  
    47      for i in range(1, 10):
    48          cilium_status = kubectl.run_kubectl(cilium_status_cmd)
    49          all_reachable = re.search(r"Cluster health:\s+({})/\1 reachable".format(node_count), cilium_status)
    50          if all_reachable:
    51              break
    52          time.sleep(30)
    53  
    54      assert all_reachable