Skip to content

Commit

Permalink
(from AES) Cherry-pick test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
esmet committed Apr 8, 2021
1 parent b055b1a commit 9c58c7b
Show file tree
Hide file tree
Showing 16 changed files with 381 additions and 245 deletions.
59 changes: 57 additions & 2 deletions .circleci/config.yml.d/amb_util.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,64 @@ commands:
name: "Gather logs"
when: always
command: |
rsync -ma --include='*/' --include='*.xml' --include='*.tap' --include='*.log' --include='Test*.webm' --exclude='*' . /tmp/test-logs
rsync \
--prune-empty-dirs --archive --include='*/' \
--include='*.xml' \
--include='*.tap' \
--include='*.log' \
--include='Test*.webm' \
--exclude='*' \
. \
/tmp/test-logs
if test -d ~/.cache/telepresence/logs; then
rsync \
--archive \
~/.cache/telepresence/logs \
/tmp/test-logs/telepresence-logs
fi
if test -f docker/container.txt; then
docker exec $(cat docker/container.txt) /bin/bash -c 'mkdir -p /tmp/build-container-logs && (cp -r /tmp/*.txt /tmp/*.json /tmp/*.log /tmp/*.yaml /tmp/build-container-logs || true) && ((test -d ~/.cache/telepresence/logs && cp -r ~/.cache/telepresence/logs /tmp/build-container-logs/telepresence-logs) || true)'
docker cp $(cat docker/container.txt):/tmp/build-container-logs /tmp/test-logs/build-container-logs
fi
- store_artifacts:
name: "Store logs"
path: /tmp/test-logs
destination: test-logs

- run:
name: "Gather coverage"
when: always
command: |
mkdir -p /tmp/coverage
if test -f docker/container.txt; then
docker cp $(cat docker/container.txt):/tmp/cov_html /tmp/coverage || true
fi
- store_artifacts:
name: "Store coverage"
path: /tmp/coverage
destination: coverage
- run:
name: "Gather pod logs"
when: always
command: |
if ! test -f ~/.kube/kubeception.yaml ; then
exit 0
fi
export KUBECONFIG=~/.kube/kubeception.yaml
podsfile=/tmp/all-pods.txt
(kubectl get pods --all-namespaces -ocustom-columns="name:.metadata.name,namespace:.metadata.namespace" --no-headers || true) > $podsfile
(kubectl describe pods --all-namespaces || true) > /tmp/all-pods-described.txt
mkdir -p /tmp/pod-logs
cat $podsfile | while IFS= read -r line; do
name=$(echo $line | awk '{print $1}')
ns=$(echo $line | awk '{print $2}')
nsdir=/tmp/pod-logs/${ns}/
mkdir -p $nsdir
outfile=${nsdir}/${name}-pod.log
(kubectl logs -n $ns $name > $outfile || echo "FAILED, status $ret, continuing...") || true
done
- store_artifacts:
name: "Store pod logs"
path: /tmp/pod-logs
destination: pod-logs
21 changes: 14 additions & 7 deletions python/kat/harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
import threading
import traceback

from .utils import ShellCommand
from .utils import ShellCommand, namespace_manifest

from yaml.scanner import ScannerError as YAMLScanError

from multi import multi
from .parser import dump, load, Tag
from .utils import namespace_manifest
from tests.manifests import httpbin_manifests, websocket_echo_server_manifests
from tests.kubeutils import apply_kube_artifacts

import yaml as pyyaml

Expand Down Expand Up @@ -1228,8 +1229,8 @@ def setup(self, selected):
finally:
self.done = True

def get_manifests(self, selected) -> OrderedDict:
manifests: OrderedDict[Union[Superpod,Node], list] = OrderedDict() # type: ignore
def get_manifests_and_namespace(self, selected) -> Tuple[Any, str]:
manifests: OrderedDict[Any, list] = OrderedDict() # type: ignore
superpods: Dict[str, Superpod] = {}

for n in (n for n in self.nodes if n in selected and not n.xfail):
Expand Down Expand Up @@ -1338,7 +1339,7 @@ def get_manifests(self, selected) -> OrderedDict:
for superpod in superpods.values():
manifests[superpod] = superpod.get_manifest_list()

return manifests
return manifests, str(nsp)

def do_local_checks(self, selected, fname) -> bool:
if RUN_MODE == 'envoy':
Expand All @@ -1363,7 +1364,7 @@ def do_local_checks(self, selected, fname) -> bool:

def _setup_k8s(self, selected):
# First up, get the full manifest and save it to disk.
manifests = self.get_manifests(selected)
manifests, namespace = self.get_manifests_and_namespace(selected)

configs = OrderedDict()
for n in (n for n in self.nodes if n in selected and not n.xfail):
Expand Down Expand Up @@ -1439,6 +1440,12 @@ def _setup_k8s(self, selected):
print(f'Continuing with Kube tests...')
# print(f"ids_to_strip {self.ids_to_strip}")

# Install httpbin
apply_kube_artifacts(namespace, httpbin_manifests)

# Install websocket-echo-server
apply_kube_artifacts(namespace, websocket_echo_server_manifests)

# XXX It is _so stupid_ that we're reparsing the whole manifest here.
xxx_crap = pyyaml.load_all(open(fname, "r").read(), Loader=pyyaml_loader)

Expand Down Expand Up @@ -1698,7 +1705,7 @@ def _wait(self, selected):
kinds = [ "pod", "url" ]
delay = 5
start = time.time()
limit = int(os.environ.get("KAT_REQ_LIMIT", "300"))
limit = int(os.environ.get("KAT_REQ_LIMIT", "600"))

print("Starting requirements check (limit %ds)... " % limit)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@
"dns_lookup_family": "V4_ONLY",
"lb_policy": "ROUND_ROBIN",
"load_assignment": {
"cluster_name": "cluster_http___echo_websocket_org_default",
"cluster_name": "cluster_websocket_echo_server_default",
"endpoints": [
{
"lb_endpoints": [
{
"endpoint": {
"address": {
"socket_address": {
"address": "echo.websocket.org",
"address": "websocket-echo-server",
"port_value": 80,
"protocol": "TCP"
}
Expand All @@ -93,7 +93,7 @@
}
]
},
"name": "cluster_http___echo_websocket_org_default",
"name": "cluster_websocket_echo_server_default",
"type": "STRICT_DNS"
}
],
Expand Down Expand Up @@ -253,12 +253,11 @@
"denominator": "HUNDRED",
"numerator": 100
},
"runtime_key": "routing.traffic_shift.cluster_http___echo_websocket_org_default"
"runtime_key": "routing.traffic_shift.cluster_websocket_echo_server_default"
}
},
"route": {
"cluster": "cluster_http___echo_websocket_org_default",
"host_rewrite": "echo.websocket.org",
"cluster": "cluster_websocket_echo_server_default",
"prefix_rewrite": "/",
"priority": null,
"timeout": "3.000s",
Expand All @@ -278,12 +277,11 @@
"denominator": "HUNDRED",
"numerator": 100
},
"runtime_key": "routing.traffic_shift.cluster_http___echo_websocket_org_default"
"runtime_key": "routing.traffic_shift.cluster_websocket_echo_server_default"
}
},
"route": {
"cluster": "cluster_http___echo_websocket_org_default",
"host_rewrite": "echo.websocket.org",
"cluster": "cluster_websocket_echo_server_default",
"prefix_rewrite": "/",
"priority": null,
"timeout": "3.000s",
Expand Down
Loading

0 comments on commit 9c58c7b

Please sign in to comment.