Skip to content

Commit

Permalink
denysa: add 007 ueransim test. (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
denysaleksandrov authored Jun 12, 2023
1 parent 873dbf8 commit c958db9
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
11 changes: 11 additions & 0 deletions e2e/lib/k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,14 @@ function k8s_get_capi_kubeconfig {
kubectl --kubeconfig "$kubeconfig" -n "$namespace" get secret "${cluster}-kubeconfig" -o jsonpath='{.data.value}' | base64 -d > "$file"
echo "$file"
}

function k8s_exec {
local kubeconfig=$1
local resource_namespace=$2
local resource_name=$3
local command=$4

echo "executing command $command on $resource_name in namespace $resource_namespace using $kubeconfig"
kubectl --kubeconfig $kubeconfig -n $resource_namespace exec -it $resource_name -- /bin/bash -c "$command"
return $?
}
22 changes: 22 additions & 0 deletions e2e/tests/007-edge-free5gc-ueransim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: config.porch.kpt.dev/v1alpha2
kind: PackageVariantSet
metadata:
name: edge-free5gc-ueransim
spec:
upstream:
repo: nephio-example-packages
package: ueransim
revision: v1
targets:
- objectSelector:
apiVersion: infra.nephio.org/v1alpha1
kind: WorkloadCluster
matchLabels:
nephio.org/site-type: edge
template:
downstream:
package: free5gc-ueransim
annotations:
approval.nephio.org/policy: initial
injectors:
- nameExpr: target.name
48 changes: 48 additions & 0 deletions e2e/tests/007.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
#!/usr/bin/env bash
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2023 The Nephio Authors.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

## TEST METADATA
## TEST-NAME: Deploy ueransim to edge clusters
##

set -o pipefail
set -o errexit
set -o nounset
[[ "${DEBUG:-false}" != "true" ]] || set -o xtrace

export HOME=${HOME:-/home/ubuntu/}
export E2EDIR=${E2EDIR:-$HOME/test-infra/e2e}
export TESTDIR=${TESTDIR:-$E2EDIR/tests}
export LIBDIR=${LIBDIR:-$E2EDIR/lib}

source "${LIBDIR}/k8s.sh"

kubeconfig="$HOME/.kube/config"

k8s_apply "$kubeconfig" "$TESTDIR/007-edge-free5gc-ueransim.yaml"

for cluster in "edge01" "edge02"; do
k8s_wait_exists "$kubeconfig" 600 "default" "packagevariant" "edge-free5gc-ueransim-${cluster}-free5gc-ueransim"
done

for cluster in "edge01" "edge02"; do
k8s_wait_ready "$kubeconfig" 600 "default" "packagevariant" "edge-free5gc-ueransim-${cluster}-free5gc-ueransim"
done

for cluster in "edge01" "edge02"; do
cluster_kubeconfig=$(k8s_get_capi_kubeconfig "$kubeconfig" "default" "$cluster")
k8s_wait_exists "$cluster_kubeconfig" 600 "ueransim" "deployment" "ueransim-gnb"
k8s_wait_exists "$cluster_kubeconfig" 600 "ueransim" "deployment" "ueransim-ue"
k8s_wait_ready_replicas "$cluster_kubeconfig" 600 "ueransim" "deployment" "ueransim-gnb"
k8s_wait_ready_replicas "$cluster_kubeconfig" 600 "ueransim" "deployment" "ueransim-ue"
ue_pod_name=${kubectl --kubeconfig $cluster_kubeconfig get pods -n ueransim -l app=ueransim -l component=ue}
k8s_exec $cluster_kubeconfig "ueransim" $ue_pod_name "ping -I uesimtun0 google.com"
done

0 comments on commit c958db9

Please sign in to comment.