Skip to content

Commit

Permalink
Merge pull request #121 from open-traffic-generator/dev-ci
Browse files Browse the repository at this point in the history
licensed islands removed, added in internal CI
  • Loading branch information
arkajyoti-cloud authored Jul 5, 2024
2 parents 8b04cf2 + 9652b6d commit d7db209
Show file tree
Hide file tree
Showing 11 changed files with 467 additions and 465 deletions.
666 changes: 333 additions & 333 deletions .github/workflows/cicd.yml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ logs/
/deployments/k8s/meshnet-cni
/deployments/k8s/mod.yaml
/etc
/deployments/.ixia-c-config.yaml
/deployments/k8s/manifests/.ixia-c-b2b-eth0.yaml
40 changes: 0 additions & 40 deletions deployments/ixia-c-config.yaml

This file was deleted.

45 changes: 0 additions & 45 deletions deployments/ixia-c-licensed-config.yaml

This file was deleted.

1 change: 1 addition & 0 deletions deployments/k8s/kne-manifests/ixia-c-b2b.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ links:
a_int: eth1
z_node: otg
z_int: eth2

12 changes: 6 additions & 6 deletions deployments/k8s/manifests/ixia-c-b2b-eth0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ items:
- args:
- --accept-eula
- --debug
image: ghcr.io/open-traffic-generator/keng-controller:local
image: $(configq .images[0].path):$(configq .images[0].tag)
imagePullPolicy: IfNotPresent
name: keng-controller
volumeMounts:
Expand All @@ -45,7 +45,7 @@ items:
- -http-server
- https://localhost:8443
- --debug
image: ghcr.io/open-traffic-generator/otg-gnmi-server:local
image: $(configq .images[1].path):$(configq .images[1].tag)
imagePullPolicy: IfNotPresent
name: otg-gnmi-server
ports:
Expand Down Expand Up @@ -77,15 +77,15 @@ items:
value: "5555"
- name: ARG_CORE_LIST
value: 1 1 1
image: ghcr.io/open-traffic-generator/ixia-c-traffic-engine:local
image: $(configq .images[2].path):$(configq .images[2].tag)
imagePullPolicy: IfNotPresent
name: otg-port-eth1-traffic-engine
securityContext:
privileged: true
- env:
- name: INTF_LIST
value: eth0
image: ghcr.io/open-traffic-generator/ixia-c-protocol-engine:local
image: $(configq .images[3].path):$(configq .images[3].tag)
imagePullPolicy: IfNotPresent
name: otg-port-eth1-protocol-engine
securityContext:
Expand All @@ -110,15 +110,15 @@ items:
value: "5555"
- name: ARG_CORE_LIST
value: 1 1 1
image: ghcr.io/open-traffic-generator/ixia-c-traffic-engine:local
image: $(configq .images[2].path):$(configq .images[2].tag)
imagePullPolicy: IfNotPresent
name: otg-port-eth2-traffic-engine
securityContext:
privileged: true
- env:
- name: INTF_LIST
value: eth0
image: ghcr.io/open-traffic-generator/ixia-c-protocol-engine:local
image: $(configq .images[3].path):$(configq .images[3].tag)
imagePullPolicy: IfNotPresent
name: otg-port-eth2-protocol-engine
securityContext:
Expand Down
33 changes: 33 additions & 0 deletions deployments/template-ixia-c-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: ixiatg-release-config
namespace: ixiatg-op-system
data:
versions: |
{
"release": "local",
"images": [
{
"name": "controller",
"path": "$(configq .images[0].path)",
"tag": "$(configq .images[0].tag)"
},
{
"name": "gnmi-server",
"path": "$(configq .images[1].path)",
"tag": "$(configq .images[1].tag)"
},
{
"name": "traffic-engine",
"path": "$(configq .images[2].path)",
"tag": "$(configq .images[2].tag)"
},
{
"name": "protocol-engine",
"path": "$(configq .images[3].path)",
"tag": "$(configq .images[3].tag)"
}
]
}
120 changes: 84 additions & 36 deletions do.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,49 @@ OPENCONFIG_MODELS_COMMIT=5ca6a36
TIMEOUT_SECONDS=300
APT_GET_UPDATE=true


IXIA_C_CONFIG_MAP="deployments/ixia-c-config.yaml"
if [ "${LICENSING}" = "true" ]
then
IXIA_C_CONFIG_MAP="deployments/ixia-c-licensed-config.yaml"
fi
IXIA_C_CONFIG_MAP_TEMP="deployments/template-ixia-c-config.yaml"
IXIA_C_CONFIG_MAP="deployments/.ixia-c-config.yaml"

YQ_RELEASE="v4.34.1"
YQ_SOURCE="github.com/mikefarah/yq/v4@${YQ_RELEASE}"
get_yq() {
echo "Getting yq ..."
echo "Installing yq ${YQ_SOURCE} ..."
go install "${YQ_SOURCE}"
echo "Successfully installed yq !"
}

configq() {
# echo is needed to further evaluate the
# contents extracted from configuration
eval echo $(yq "${@}" versions.yaml)
}

eval_config_map() {
get_yq \
&& rm -rf ${IXIA_C_CONFIG_MAP}

# avoid splitting based on whitespace
IFS=''
# mix of cat and echo is used to ensure the input file has
# at least one newline before EOF, otherwise read will not
# provide last line
{ cat ${IXIA_C_CONFIG_MAP_TEMP}; echo; } | while read line; do
# replace all double-quotes with single quotes
line=$(echo "${line}" | sed s#\"#\'#g)
# and revert them back to double-quotes post eval;
# this will result in converting all single-quotes
# to double-quotes regardless of whether they were
# originally double-quotes, but hopefully this won't
# be an issue
# this workaround was put in place because eval gets
# rid of double-quotes
eval echo \"$line\" | sed s#\'#\"#g >> ${IXIA_C_CONFIG_MAP}
done
# restore default IFS
unset IFS
cat ${IXIA_C_CONFIG_MAP}
}
apt_update() {
if [ "${APT_UPDATE}" = "true" ]
Expand Down Expand Up @@ -418,9 +455,10 @@ gen_config_kne() {
}
gen_config_k8s() {
pwd
ADDR=$(kubectl get service -n ixia-c service-otg-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
ETH1=$(grep "location:" deployments/k8s/manifests/${1}.yaml -m 2 | head -n1 | cut -d\: -f2 | cut -d\ -f2)
ETH2=$(grep "location:" deployments/k8s/manifests/${1}.yaml -m 2 | tail -n1 | cut -d\: -f2 | cut -d\ -f2)
ETH1=$(grep "location:" deployments/k8s/manifests/.${1}.yaml -m 2 | head -n1 | cut -d\: -f2 | cut -d\ -f2)
ETH2=$(grep "location:" deployments/k8s/manifests/.${1}.yaml -m 2 | tail -n1 | cut -d\: -f2 | cut -d\ -f2)
yml="otg_host: https://${ADDR}:8443
otg_ports:
- ${ETH1}
Expand Down Expand Up @@ -625,13 +663,7 @@ create_ixia_c_b2b_cpdp() {
--accept-eula \
--trace \
--disable-app-usage-reporter \
--license-servers localhost \
&& docker run -d \
--net=container:keng-controller \
--name=keng-license-server \
$(keng_license_server_img) \
--accept-eula \
--debug
--license-servers localhost
else
docker run -d \
--name=keng-controller \
Expand Down Expand Up @@ -682,11 +714,6 @@ rm_ixia_c_b2b_cpdp() {
echo "Tearing down back-to-back with CP/DP distribution of ixia-c ..."
docker stop keng-controller && docker rm keng-controller
if [ "${LICENSING}" = "true" ]
then
docker stop keng-license-server && docker rm keng-license-server
fi

docker stop ixia-c-traffic-engine-${VETH_A}
docker stop ixia-c-protocol-engine-${VETH_A}
docker rm ixia-c-traffic-engine-${VETH_A}
Expand All @@ -713,13 +740,7 @@ create_ixia_c_b2b_lag() {
--accept-eula \
--trace \
--disable-app-usage-reporter \
--license-servers localhost \
&& docker run -d \
--net=container:keng-controller \
--name=keng-license-server \
$(keng_license_server_img) \
--accept-eula \
--debug
--license-servers localhost
else
docker run -d \
--name=keng-controller \
Expand Down Expand Up @@ -997,10 +1018,6 @@ load_ixia_c_images() {
echo "Loading ixia-c images in cluster ..."
login_ghcr
names="controller gnmi-server traffic-engine protocol-engine"
if [ "${LICENSING}" = "true" ]
then
names="$names license-server"
fi
for name in $names
do
p=$(ixia_c_image_path ${name})
Expand Down Expand Up @@ -1066,6 +1083,8 @@ new_k8s_cluster() {
common_install \
&& setup_kind_cluster \
&& setup_k8s_plugins ${1} ${2} \
&& eval_config_map \
&& eval_yaml deployments/k8s/manifests/${1}.yaml \
&& load_ixia_c_images
}
Expand Down Expand Up @@ -1093,7 +1112,8 @@ create_ixia_c_kne() {
echo "Creating KNE ${1} ${2} topology ..."
ns=$(kne_namespace ${1} ${2})
topo=$(kne_topo_file ${1} ${2})
kubectl apply -f $IXIA_C_CONFIG_MAP \
eval_config_map \
&& kubectl apply -f $IXIA_C_CONFIG_MAP \
&& kne create ${topo} \
&& wait_for_pods ${ns} \
&& kubectl get pods -A \
Expand All @@ -1114,10 +1134,38 @@ k8s_namespace() {
grep namespace deployments/k8s/manifests/${1}.yaml -m 1 | cut -d \: -f2 | cut -d \ -f 2
}
eval_yaml() {
get_yq
new_yaml=$(dirname ${1})/.$(basename ${1})
rm -rf ${new_yaml}
# avoid splitting based on whitespace
IFS=''
# mix of cat and echo is used to ensure the input file has
# at least one newline before EOF, otherwise read will not
# provide last line
{ cat ${1}; echo; } | while read line; do
# replace all double-quotes with single quotes
line=$(echo "${line}" | sed s#\"#\'#g)
# and revert them back to double-quotes post eval;
# this will result in converting all single-quotes
# to double-quotes regardless of whether they were
# originally double-quotes, but hopefully this won't
# be an issue
# this workaround was put in place because eval gets
# rid of double-quotes
eval echo \"$line\" | sed s#\'#\"#g >> ${new_yaml}
done
# restore default IFS
unset IFS
echo ${new_yaml}
}
create_ixia_c_k8s() {
echo "Creating K8S ${1} topology ..."
ns=$(k8s_namespace ${1})
kubectl apply -f deployments/k8s/manifests/${1}.yaml \
eval_yaml deployments/k8s/manifests/${1}.yaml \
&& kubectl apply -f deployments/k8s/manifests/.${1}.yaml \
&& wait_for_pods ${ns} \
&& kubectl get pods -A \
&& kubectl get services -A \
Expand All @@ -1126,9 +1174,9 @@ create_ixia_c_k8s() {
}
rm_ixia_c_k8s() {
echo "Removing K8S ${1} topology ..."
ns=$(k8s_namespace ${1})
kubectl delete -f deployments/k8s/manifests/${1}.yaml \
echo "Removing K8S .${1}.yaml topology ..."
ns=$(k8s_namespace deployments/k8s/manifests/.${1}.yaml)
kubectl delete -f deployments/k8s/manifests/.${1}.yaml \
&& wait_for_no_namespace ${ns}
}
Expand Down
3 changes: 2 additions & 1 deletion helpers/dut/gnmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ func NewGnmiClient(d *DutApi) (*GnmiClient, error) {
location := fmt.Sprintf("%s:%d", d.dutConfig.Host, d.dutConfig.GnmiPort)
d.t.Logf("Creating gNMI client for server %s ...\n", location)

grpcConn, err := grpc.Dial(
grpcConn, err := grpc.NewClient(
location,
grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{InsecureSkipVerify: true})),
grpc.WithPerRPCCredentials(&grpcPassCred{
username: d.dutConfig.GnmiUsername,
password: d.dutConfig.GnmiPassword,
}),
)

if err != nil {
return nil, fmt.Errorf("failed to dial gRPC for location %s: %v", location, err)
}
Expand Down
Loading

0 comments on commit d7db209

Please sign in to comment.