Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions e2e/lib/_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,20 @@
function _print_msg {
echo "$(date +%H:%M:%S) - $1: $2"
}

# get_pod_logs() - Collect logs from pods of a deployment
# Usage: get_pod_logs <deployment> <namespace> [kubeconfig]
function get_pod_logs {

Check warning on line 42 in e2e/lib/_utils.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add an explicit return statement at the end of the function.

See more on https://sonarcloud.io/project/issues?id=nephio-project_test-infra&issues=AZsEB9VkPQpDE5lmkq9C&open=AZsEB9VkPQpDE5lmkq9C&pullRequest=373
local deployment=$1
local namespace=$2
local kubeconfig=${3:-}
local kubectl_cmd="kubectl"
[[ -z "$kubeconfig" ]] || kubectl_cmd="kubectl --kubeconfig $kubeconfig"

info "Collecting logs from deployment $deployment in $namespace namespace"
local selector=$($kubectl_cmd get deployment "$deployment" -n "$namespace" -o jsonpath='{.spec.selector.matchLabels}' | jq -r 'to_entries|map("\(.key)=\(.value)")|join(",")')
for pod in $($kubectl_cmd get pods -n "$namespace" -l "$selector" -o jsonpath='{.items[*].metadata.name}'); do
info "Logs from pod: $pod"
$kubectl_cmd logs -n "$namespace" "$pod" --all-containers=true --tail=100 || warn "Failed to get logs from $pod"
done
}
12 changes: 11 additions & 1 deletion e2e/tests/ocloud/001.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
# shellcheck source=e2e/defaults.env
source "$E2EDIR/defaults.env"

focom_kubecofig="/tmp/focom-kubeconfig"

function cleanup {

Check warning on line 25 in e2e/tests/ocloud/001.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add an explicit return statement at the end of the function.

See more on https://sonarcloud.io/project/issues?id=nephio-project_test-infra&issues=AZsEB9TXPQpDE5lmkq9B&open=AZsEB9TXPQpDE5lmkq9B&pullRequest=373
get_pod_logs "o2ims-operator" "o2ims" || true
get_pod_logs "focom-operator-controller-manager" "focom-operator-system" "$focom_kubecofig" || true
}
trap cleanup EXIT

# shellcheck source=e2e/lib/k8s.sh
source "${LIBDIR}/k8s.sh"

Expand All @@ -29,6 +37,9 @@
# shellcheck source=e2e/lib/_assertions.sh
source "${LIBDIR}/_assertions.sh"

# shellcheck source=e2e/lib/_utils.sh
source "${LIBDIR}/_utils.sh"


# Clone the o2ims pkg
pkg_rev=$(porchctl rpkg clone -n default "https://github.com/nephio-project/catalog.git/nephio/optional/o2ims@$BRANCH" --repository mgmt o2ims | cut -f 1 -d ' ')
Expand Down Expand Up @@ -59,7 +70,6 @@
kubectl rollout status deployment/o2ims-operator --namespace="o2ims" --timeout="600s"

# Create the simulated SMO cluster
focom_kubecofig="/tmp/focom-kubeconfig"
kind create cluster -n focom-cluster --kubeconfig $focom_kubecofig

# Get the focom operator pkg
Expand Down