diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ca970101fd46bdf0b281d57b585089c790bc3dd8..c8fcd83a63d46bbab65e82ad6423878ade32bf71 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,44 +19,50 @@ stages: - unit_test - end2end_test +workflow: + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' + when: always + - when: never + # include the individual .gitlab-ci.yml of each micro-service and tests include: - #- local: '/manifests/.gitlab-ci.yml' - - local: '/src/monitoring/.gitlab-ci.yml' - - local: '/src/nbi/.gitlab-ci.yml' - - local: '/src/context/.gitlab-ci.yml' - - local: '/src/device/.gitlab-ci.yml' - - local: '/src/service/.gitlab-ci.yml' - - local: '/src/qkd_app/.gitlab-ci.yml' - - local: '/src/dbscanserving/.gitlab-ci.yml' - - local: '/src/opticalattackmitigator/.gitlab-ci.yml' - - local: '/src/opticalattackdetector/.gitlab-ci.yml' - - local: '/src/opticalattackmanager/.gitlab-ci.yml' - - local: '/src/opticalcontroller/.gitlab-ci.yml' - - local: '/src/ztp/.gitlab-ci.yml' - - local: '/src/policy/.gitlab-ci.yml' - - local: '/src/automation/.gitlab-ci.yml' - - local: '/src/forecaster/.gitlab-ci.yml' - #- local: '/src/webui/.gitlab-ci.yml' - #- local: '/src/l3_distributedattackdetector/.gitlab-ci.yml' - #- local: '/src/l3_centralizedattackdetector/.gitlab-ci.yml' - #- local: '/src/l3_attackmitigator/.gitlab-ci.yml' - - local: '/src/slice/.gitlab-ci.yml' - #- local: '/src/interdomain/.gitlab-ci.yml' - - local: '/src/pathcomp/.gitlab-ci.yml' - #- local: '/src/dlt/.gitlab-ci.yml' - - local: '/src/load_generator/.gitlab-ci.yml' - - local: '/src/bgpls_speaker/.gitlab-ci.yml' - - local: '/src/kpi_manager/.gitlab-ci.yml' - - local: '/src/kpi_value_api/.gitlab-ci.yml' - #- local: '/src/kpi_value_writer/.gitlab-ci.yml' - #- local: '/src/telemetry/.gitlab-ci.yml' - - local: '/src/analytics/.gitlab-ci.yml' - - local: '/src/qos_profile/.gitlab-ci.yml' - - local: '/src/vnt_manager/.gitlab-ci.yml' - - local: '/src/e2e_orchestrator/.gitlab-ci.yml' - - local: '/src/ztp_server/.gitlab-ci.yml' - - local: '/src/osm_client/.gitlab-ci.yml' +# #- local: '/manifests/.gitlab-ci.yml' +# - local: '/src/monitoring/.gitlab-ci.yml' +# - local: '/src/nbi/.gitlab-ci.yml' +# - local: '/src/context/.gitlab-ci.yml' +# - local: '/src/device/.gitlab-ci.yml' +# - local: '/src/service/.gitlab-ci.yml' +# - local: '/src/qkd_app/.gitlab-ci.yml' +# - local: '/src/dbscanserving/.gitlab-ci.yml' +# - local: '/src/opticalattackmitigator/.gitlab-ci.yml' +# - local: '/src/opticalattackdetector/.gitlab-ci.yml' +# - local: '/src/opticalattackmanager/.gitlab-ci.yml' +# - local: '/src/opticalcontroller/.gitlab-ci.yml' +# - local: '/src/ztp/.gitlab-ci.yml' +# - local: '/src/policy/.gitlab-ci.yml' +# - local: '/src/automation/.gitlab-ci.yml' +# - local: '/src/forecaster/.gitlab-ci.yml' +# #- local: '/src/webui/.gitlab-ci.yml' +# #- local: '/src/l3_distributedattackdetector/.gitlab-ci.yml' +# #- local: '/src/l3_centralizedattackdetector/.gitlab-ci.yml' +# #- local: '/src/l3_attackmitigator/.gitlab-ci.yml' +# - local: '/src/slice/.gitlab-ci.yml' +# #- local: '/src/interdomain/.gitlab-ci.yml' +# - local: '/src/pathcomp/.gitlab-ci.yml' +# #- local: '/src/dlt/.gitlab-ci.yml' +# - local: '/src/load_generator/.gitlab-ci.yml' +# - local: '/src/bgpls_speaker/.gitlab-ci.yml' +# - local: '/src/kpi_manager/.gitlab-ci.yml' +# - local: '/src/kpi_value_api/.gitlab-ci.yml' +# #- local: '/src/kpi_value_writer/.gitlab-ci.yml' +# #- local: '/src/telemetry/.gitlab-ci.yml' +# - local: '/src/analytics/.gitlab-ci.yml' +# - local: '/src/qos_profile/.gitlab-ci.yml' +# - local: '/src/vnt_manager/.gitlab-ci.yml' +# - local: '/src/e2e_orchestrator/.gitlab-ci.yml' +# - local: '/src/ztp_server/.gitlab-ci.yml' +# - local: '/src/osm_client/.gitlab-ci.yml' # This should be last one: end-to-end integration tests - local: '/src/tests/.gitlab-ci.yml' diff --git a/src/tests/.gitlab-ci.yml b/src/tests/.gitlab-ci.yml index 67f3b56921d8265ae4f201dbbfe111f88d52fae7..98c0c1eb6d1ad6a890c9916f2263fd406ddf6ef1 100644 --- a/src/tests/.gitlab-ci.yml +++ b/src/tests/.gitlab-ci.yml @@ -14,19 +14,19 @@ # include the individual .gitlab-ci.yml of each end-to-end integration test include: - - local: '/src/tests/ofc22/.gitlab-ci.yml' - #- local: '/src/tests/oeccpsc22/.gitlab-ci.yml' - - local: '/src/tests/ecoc22/.gitlab-ci.yml' - #- local: '/src/tests/nfvsdn22/.gitlab-ci.yml' - #- local: '/src/tests/ofc23/.gitlab-ci.yml' - - local: '/src/tests/ofc24/.gitlab-ci.yml' - - local: '/src/tests/eucnc24/.gitlab-ci.yml' - #- local: '/src/tests/ofc25-camara-agg-net-controller/.gitlab-ci.yml' - #- local: '/src/tests/ofc25-camara-e2e-controller/.gitlab-ci.yml' - #- local: '/src/tests/ofc25/.gitlab-ci.yml' - #- local: '/src/tests/ryu-openflow/.gitlab-ci.yml' - - local: '/src/tests/qkd_end2end/.gitlab-ci.yml' +# - local: '/src/tests/ofc22/.gitlab-ci.yml' +# #- local: '/src/tests/oeccpsc22/.gitlab-ci.yml' +# - local: '/src/tests/ecoc22/.gitlab-ci.yml' +# #- local: '/src/tests/nfvsdn22/.gitlab-ci.yml' +# #- local: '/src/tests/ofc23/.gitlab-ci.yml' +# - local: '/src/tests/ofc24/.gitlab-ci.yml' +# - local: '/src/tests/eucnc24/.gitlab-ci.yml' +# #- local: '/src/tests/ofc25-camara-agg-net-controller/.gitlab-ci.yml' +# #- local: '/src/tests/ofc25-camara-e2e-controller/.gitlab-ci.yml' +# #- local: '/src/tests/ofc25/.gitlab-ci.yml' + - local: '/src/tests/ryu-openflow/.gitlab-ci.yml' +# - local: '/src/tests/qkd_end2end/.gitlab-ci.yml' - - local: '/src/tests/tools/mock_tfs_nbi_dependencies/.gitlab-ci.yml' - - local: '/src/tests/tools/mock_qkd_node/.gitlab-ci.yml' - - local: '/src/tests/tools/mock_osm_nbi/.gitlab-ci.yml' +# - local: '/src/tests/tools/mock_tfs_nbi_dependencies/.gitlab-ci.yml' +# - local: '/src/tests/tools/mock_qkd_node/.gitlab-ci.yml' +# - local: '/src/tests/tools/mock_osm_nbi/.gitlab-ci.yml' diff --git a/src/tests/ryu-openflow/.gitlab-ci.yml b/src/tests/ryu-openflow/.gitlab-ci.yml index 42d59538446edd47c1ea16bd202e183d9d8c4c14..18e35f45445f4d49dadf56de681cd50a04880b5e 100644 --- a/src/tests/ryu-openflow/.gitlab-ci.yml +++ b/src/tests/ryu-openflow/.gitlab-ci.yml @@ -21,28 +21,24 @@ build ryu-openflow: before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - docker ps -aq | xargs -r docker rm -f - - containerlab destroy --all --cleanup || true script: - - echo "CI_PIPELINE_SOURCE = $CI_PIPELINE_SOURCE" - - echo "CI_MERGE_REQUEST_ID = $CI_MERGE_REQUEST_ID" - - echo "CI_MERGE_REQUEST_IID = $CI_MERGE_REQUEST_IID" - docker buildx build -t "$CI_REGISTRY_IMAGE/${TEST_NAME}-ryu:${IMAGE_TAG}" -f ./src/tests/${TEST_NAME}/Ryu.Dockerfile . - docker push "$CI_REGISTRY_IMAGE/${TEST_NAME}-ryu:${IMAGE_TAG}" + - docker buildx build -t "$CI_REGISTRY_IMAGE/${TEST_NAME}-mininet:${IMAGE_TAG}" -f ./src/tests/${TEST_NAME}/mininet/Mininet.Dockerfile . + - docker push "$CI_REGISTRY_IMAGE/${TEST_NAME}-mininet:${IMAGE_TAG}" - docker buildx build -t "$CI_REGISTRY_IMAGE/${TEST_NAME}-test:${IMAGE_TAG}" -f ./src/tests/${TEST_NAME}/Test.Dockerfile . - docker push "$CI_REGISTRY_IMAGE/${TEST_NAME}-test:${IMAGE_TAG}" after_script: - docker images --filter="dangling=true" --quiet | xargs -r docker rmi rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' - - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' + ###- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' - changes: - src/common/**/*.py - proto/*.proto - src/tests/${TEST_NAME}/**/*.{py,in,sh,yml} - src/tests/${TEST_NAME}/Dockerfile - .gitlab-ci.yml - - # - docker rm -f na-t1 na-t2 na-r1 na-r2 # - docker network rm -f na-br # @@ -56,68 +52,88 @@ build ryu-openflow: # asgamb1/oc23bgp.img:latest /confd/examples.confd/OC23/startNetconfAgent.sh -## Deploy TeraFlowSDN and Execute end-2-end test -#end2end_test ryu-openflow: -# timeout: 90m -# variables: -# TEST_NAME: 'ryu-openflow' -# stage: end2end_test -# # Disable to force running it after all other tasks -# #needs: -# # - build ryu-openflow -# before_script: -# - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY -# - docker ps -aq | xargs -r docker rm -f -# - containerlab destroy --all --cleanup || true -# script: -# # Download Docker image to run the test -# - docker pull "${CI_REGISTRY_IMAGE}/${TEST_NAME}:latest" -# -# # Check MicroK8s is ready -# - microk8s status --wait-ready -# - kubectl get pods --all-namespaces -# -# # Deploy ContainerLab Scenario -# - RUNNER_PATH=`pwd` -# #- cd $PWD/src/tests/${TEST_NAME} -# - mkdir -p /tmp/clab/${TEST_NAME} -# - cp -R src/tests/${TEST_NAME}/clab/* /tmp/clab/${TEST_NAME} -# - tree -la /tmp/clab/${TEST_NAME} -# - cd /tmp/clab/${TEST_NAME} -# - containerlab deploy --reconfigure --topo ryu-openflow.clab.yml -# - cd $RUNNER_PATH -# -# # Wait for initialization of Device NOSes -# - sleep 3 -# - docker ps -a -# -# # Dump configuration of the routers (before any configuration) -# - containerlab exec --name ryu-openflow --label clab-node-name=r1 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" -# - containerlab exec --name ryu-openflow --label clab-node-name=r2 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" -# - containerlab exec --name ryu-openflow --label clab-node-name=r3 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" -# -# # Configure TeraFlowSDN deployment -# # Uncomment if DEBUG log level is needed for the components -# #- yq -i '((select(.kind=="Deployment").spec.template.spec.containers.[] | select(.name=="server").env.[]) | select(.name=="LOG_LEVEL").value) |= "DEBUG"' manifests/contextservice.yaml -# #- yq -i '((select(.kind=="Deployment").spec.template.spec.containers.[] | select(.name=="server").env.[]) | select(.name=="LOG_LEVEL").value) |= "DEBUG"' manifests/deviceservice.yaml -# #- yq -i '((select(.kind=="Deployment").spec.template.spec.containers.[] | select(.name=="frontend").env.[]) | select(.name=="LOG_LEVEL").value) |= "DEBUG"' manifests/pathcompservice.yaml -# #- yq -i '((select(.kind=="Deployment").spec.template.spec.containers.[] | select(.name=="server").env.[]) | select(.name=="LOG_LEVEL").value) |= "DEBUG"' manifests/serviceservice.yaml -# #- yq -i '((select(.kind=="Deployment").spec.template.spec.containers.[] | select(.name=="server").env.[]) | select(.name=="LOG_LEVEL").value) |= "DEBUG"' manifests/nbiservice.yaml -# #- yq -i '((select(.kind=="Deployment").spec.template.spec.containers.[] | select(.name=="server").env.[]) | select(.name=="LOG_LEVEL").value) |= "DEBUG"' manifests/monitoringservice.yaml -# -# - source src/tests/${TEST_NAME}/deploy_specs.sh -# #- export TFS_REGISTRY_IMAGES="${CI_REGISTRY_IMAGE}" -# #- export TFS_SKIP_BUILD="YES" -# #- export TFS_IMAGE_TAG="latest" -# #- echo "TFS_REGISTRY_IMAGES=${CI_REGISTRY_IMAGE}" -# -# # Deploy TeraFlowSDN -# - ./deploy/crdb.sh -# - ./deploy/nats.sh -# - ./deploy/kafka.sh -# - ./deploy/qdb.sh -# - ./deploy/tfs.sh -# - ./deploy/show.sh +# Deploy TeraFlowSDN and Execute end-2-end test +end2end_test ryu-openflow: + timeout: 90m + variables: + TEST_NAME: 'ryu-openflow' + IMAGE_TAG: 'mr$CI_MERGE_REQUEST_IID' + stage: end2end_test + #Disable to force running it after all other tasks + needs: + - build ryu-openflow + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + - docker ps -aq | xargs -r docker rm -f + # cleanup mininet + #- docker run --rm "${CI_REGISTRY_IMAGE}/${TEST_NAME}-mininet:${IMAGE_TAG}" mn -c + script: + - echo "Starting script section" + ## Download Docker images to run the test + - docker pull "${CI_REGISTRY_IMAGE}/${TEST_NAME}-ryu:${IMAGE_TAG}" + - docker pull "${CI_REGISTRY_IMAGE}/${TEST_NAME}-mininet:${IMAGE_TAG}" + - docker pull "${CI_REGISTRY_IMAGE}/${TEST_NAME}-test:${IMAGE_TAG}" + + + ## Check MicroK8s is ready + - microk8s status --wait-ready + - kubectl get pods --all-namespaces + ##run ryu and mininet + - docker rm -f ryu mininet || true + - docker network rm tfs-test-ryu || true + ###- docker network create -d bridge --subnet=172.254.254.0/24 --gateway=172.254.254.1 tfs-test-ryu + - docker network create -d bridge --subnet=172.20.0.0/24 --gateway=172.20.0.1 tfs-test-ryu + - docker run -d --name ryu --network tfs-test-ryu --ip 172.20.0.10 "${CI_REGISTRY_IMAGE}/${TEST_NAME}-ryu:${IMAGE_TAG}" + - | + echo "Waiting for Ryu to be ready..." + until curl -s http://172.20.0.10:8080 >/dev/null; do + echo "Still waiting..." + sleep 5 + done + echo "Ryu is ready!" + + - docker run -d --name mininet --network tfs-test-ryu --ip 172.20.0.11 --privileged --ulimit memlock=-1:-1 --ulimit nofile=65536:65536 --ulimit nproc=65536:65536 --volume /lib/modules:/lib/modules "${CI_REGISTRY_IMAGE}/${TEST_NAME}-mininet:${IMAGE_TAG}" + # - docker run -d --name mininet --network tfs-test-ryu --ip 172.20.0.11 "${CI_REGISTRY_IMAGE}/${TEST_NAME}-mininet:${IMAGE_TAG}" + + ## Wait for initialization of Device NOSes + - sleep 10 + - docker ps -a + - docker inspect mininet + - docker logs ryu + - docker logs mininet + - echo "Finishing script section" +# Dump configuration of the switches (OpenFlow rules configured) (before configure IETF service) + - docker exec mininet bash -c "ovs-vsctl show" + - docker logs mininet + - docker exec mininet bash -c "ovs-ofctl dump-flows s1" + - docker exec mininet bash -c "ovs-ofctl dump-flows s2" + - docker exec mininet bash -c "ovs-ofctl dump-flows s3" + - docker exec mininet bash -c "ovs-ofctl dump-flows s4" + - docker exec mininet bash -c "ovs-ofctl dump-flows s5" + + # Configure TeraFlowSDN deployment + ## Uncomment if DEBUG log level is needed for the components + #- yq -i '((select(.kind=="Deployment").spec.template.spec.containers.[] | select(.name=="server").env.[]) | select(.name=="LOG_LEVEL").value) |= "DEBUG"' manifests/contextservice.yaml + #- yq -i '((select(.kind=="Deployment").spec.template.spec.containers.[] | select(.name=="server").env.[]) | select(.name=="LOG_LEVEL").value) |= "DEBUG"' manifests/deviceservice.yaml + #- yq -i '((select(.kind=="Deployment").spec.template.spec.containers.[] | select(.name=="frontend").env.[]) | select(.name=="LOG_LEVEL").value) |= "DEBUG"' manifests/pathcompservice.yaml + #- yq -i '((select(.kind=="Deployment").spec.template.spec.containers.[] | select(.name=="server").env.[]) | select(.name=="LOG_LEVEL").value) |= "DEBUG"' manifests/serviceservice.yaml + #- yq -i '((select(.kind=="Deployment").spec.template.spec.containers.[] | select(.name=="server").env.[]) | select(.name=="LOG_LEVEL").value) |= "DEBUG"' manifests/nbiservice.yaml + #- yq -i '((select(.kind=="Deployment").spec.template.spec.containers.[] | select(.name=="server").env.[]) | select(.name=="LOG_LEVEL").value) |= "DEBUG"' manifests/monitoringservice.yaml + + - source src/tests/${TEST_NAME}/deploy_specs.sh + #- export TFS_REGISTRY_IMAGES="${CI_REGISTRY_IMAGE}" + #- export TFS_SKIP_BUILD="YES" + #- export TFS_IMAGE_TAG="latest" + #- echo "TFS_REGISTRY_IMAGES=${CI_REGISTRY_IMAGE}" + + # Deploy TeraFlowSDN + - ./deploy/crdb.sh + - ./deploy/nats.sh + - ./deploy/kafka.sh + - ./deploy/qdb.sh + - ./deploy/tfs.sh + - ./deploy/show.sh + # # ## Wait for Context to be subscribed to NATS # ## WARNING: this loop is infinite if there is no subscriber (such as monitoring). @@ -136,70 +152,31 @@ build ryu-openflow: # # break # # fi # # done -# - kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/contextservice -c server -# -# # Run end-to-end test: onboard scenario -# - > -# docker run -t --rm --name ${TEST_NAME} --network=host -# --volume "$PWD/tfs_runtime_env_vars.sh:/var/teraflow/tfs_runtime_env_vars.sh" -# --volume "$PWD/src/tests/${TEST_NAME}:/opt/results" -# $CI_REGISTRY_IMAGE/${TEST_NAME}:latest /var/teraflow/run-onboarding.sh -# -# # Run end-to-end test: configure service TFS -# - > -# docker run -t --rm --name ${TEST_NAME} --network=host -# --volume "$PWD/tfs_runtime_env_vars.sh:/var/teraflow/tfs_runtime_env_vars.sh" -# --volume "$PWD/src/tests/${TEST_NAME}:/opt/results" -# $CI_REGISTRY_IMAGE/${TEST_NAME}:latest /var/teraflow/run-service-tfs-create.sh -# -# # Dump configuration of the routers (after configure TFS service) -# - containerlab exec --name ryu-openflow --label clab-node-name=r1 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" -# - containerlab exec --name ryu-openflow --label clab-node-name=r2 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" -# - containerlab exec --name ryu-openflow --label clab-node-name=r3 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" -# -# # Run end-to-end test: test connectivity with ping -# - export TEST1_10=$(containerlab exec --name ryu-openflow --label clab-node-name=dc1 --cmd 'ping -n -c3 172.16.1.10' --format json) -# - echo $TEST1_10 -# - echo $TEST1_10 | grep -E '3 packets transmitted, 3 received, 0\% packet loss' -# - export TEST1_1=$(containerlab exec --name ryu-openflow --label clab-node-name=dc1 --cmd 'ping -n -c3 172.16.1.1' --format json) -# - echo $TEST1_1 -# - echo $TEST1_1 | grep -E '3 packets transmitted, 3 received, 0\% packet loss' -# - export TEST2_1=$(containerlab exec --name ryu-openflow --label clab-node-name=dc1 --cmd 'ping -n -c3 172.16.2.1' --format json) -# - echo $TEST2_1 -# - echo $TEST2_1 | grep -E '3 packets transmitted, 3 received, 0\% packet loss' -# - export TEST2_10=$(containerlab exec --name ryu-openflow --label clab-node-name=dc1 --cmd 'ping -n -c3 172.16.2.10' --format json) -# - echo $TEST2_10 -# - echo $TEST2_10 | grep -E '3 packets transmitted, 3 received, 0\% packet loss' -# - export TEST3_1=$(containerlab exec --name ryu-openflow --label clab-node-name=dc1 --cmd 'ping -n -c3 172.16.3.1' --format json) -# - echo $TEST3_1 -# - echo $TEST3_1 | grep -E '3 packets transmitted, 0 received, 100\% packet loss' -# - export TEST3_10=$(containerlab exec --name ryu-openflow --label clab-node-name=dc1 --cmd 'ping -n -c3 172.16.3.10' --format json) -# - echo $TEST3_10 -# - echo $TEST3_10 | grep -E '3 packets transmitted, 0 received, 100\% packet loss' -# -# # Run end-to-end test: deconfigure service TFS -# - > -# docker run -t --rm --name ${TEST_NAME} --network=host -# --volume "$PWD/tfs_runtime_env_vars.sh:/var/teraflow/tfs_runtime_env_vars.sh" -# --volume "$PWD/src/tests/${TEST_NAME}:/opt/results" -# $CI_REGISTRY_IMAGE/${TEST_NAME}:latest /var/teraflow/run-service-tfs-remove.sh -# -# # Dump configuration of the routers (after deconfigure TFS service) -# - containerlab exec --name ryu-openflow --label clab-node-name=r1 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" -# - containerlab exec --name ryu-openflow --label clab-node-name=r2 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" -# - containerlab exec --name ryu-openflow --label clab-node-name=r3 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" -# -# # Run end-to-end test: configure service IETF -# - > -# docker run -t --rm --name ${TEST_NAME} --network=host -# --volume "$PWD/tfs_runtime_env_vars.sh:/var/teraflow/tfs_runtime_env_vars.sh" -# --volume "$PWD/src/tests/${TEST_NAME}:/opt/results" -# $CI_REGISTRY_IMAGE/${TEST_NAME}:latest /var/teraflow/run-service-ietf-create.sh + - kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/contextservice -c server + + ## Run end-to-end test: onboard scenario + - > + docker run -t --rm --name ${TEST_NAME} --network=host + --volume "$PWD/tfs_runtime_env_vars.sh:/var/teraflow/tfs_runtime_env_vars.sh" + --volume "$PWD/src/tests/${TEST_NAME}:/opt/results" + "${CI_REGISTRY_IMAGE}/${TEST_NAME}-test:${IMAGE_TAG}" /var/teraflow/run-onboarding.sh + +# Dump configuration of the switches (OpenFlow rules configured) (before configure IETF service) + #- docker exec ryu-openflow-mininet ovs-ofctl dump-flows s1 + #- docker exec ryu-openflow-mininet ovs-ofctl dump-flows s2 + #- docker exec ryu-openflow-mininet ovs-ofctl dump-flows s3 + #- docker exec ryu-openflow-mininet ovs-ofctl dump-flows s4 + #- docker exec ryu-openflow-mininet ovs-ofctl dump-flows s5 + + + # Run end-to-end test: configure service IETF + - > + docker run -t --rm --name ${TEST_NAME} --network=host + --volume "$PWD/tfs_runtime_env_vars.sh:/var/teraflow/tfs_runtime_env_vars.sh" + --volume "$PWD/src/tests/${TEST_NAME}:/opt/results" + $CI_REGISTRY_IMAGE/${TEST_NAME}:latest /var/teraflow/run-service-ietf-create.sh # -# # Dump configuration of the routers (after configure IETF service) -# - containerlab exec --name ryu-openflow --label clab-node-name=r1 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" -# - containerlab exec --name ryu-openflow --label clab-node-name=r2 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" -# - containerlab exec --name ryu-openflow --label clab-node-name=r3 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" +# # Dump configuration of the switches (OpenFlow rules configured) (after configure IETF service) # # # Run end-to-end test: test connectivity with ping # - export TEST1_10=$(containerlab exec --name ryu-openflow --label clab-node-name=dc1 --cmd 'ping -n -c3 172.16.1.10' --format json) @@ -228,10 +205,7 @@ build ryu-openflow: # --volume "$PWD/src/tests/${TEST_NAME}:/opt/results" # $CI_REGISTRY_IMAGE/${TEST_NAME}:latest /var/teraflow/run-service-ietf-remove.sh # -# # Dump configuration of the routers (after deconfigure IETF service) -# - containerlab exec --name ryu-openflow --label clab-node-name=r1 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" -# - containerlab exec --name ryu-openflow --label clab-node-name=r2 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" -# - containerlab exec --name ryu-openflow --label clab-node-name=r3 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" +# # Dump configuration of the switches (OpenFlow rules configured) (after deconfigure IETF service) # # # Run end-to-end test: cleanup scenario # - > @@ -241,10 +215,7 @@ build ryu-openflow: # $CI_REGISTRY_IMAGE/${TEST_NAME}:latest /var/teraflow/run-cleanup.sh # # after_script: -# # Dump configuration of the routers (on after_script) -# - containerlab exec --name ryu-openflow --label clab-node-name=r1 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" -# - containerlab exec --name ryu-openflow --label clab-node-name=r2 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" -# - containerlab exec --name ryu-openflow --label clab-node-name=r3 --cmd "Cli --command \"enable"$'\n'$"show running-config\"" +# # Dump configuration of the switches (OpenFlow rules configured) (on after_script) # # # Dump TeraFlowSDN component logs # - source src/tests/${TEST_NAME}/deploy_specs.sh @@ -262,17 +233,21 @@ build ryu-openflow: # - cd /tmp/clab/${TEST_NAME} # - containerlab destroy --topo ryu-openflow.clab.yml --cleanup || true # - sudo rm -rf clab-ryu-openflow/ .ryu-openflow.clab.yml.bak || true + +# destroy ryu +# destroy mininet + # - cd $RUNNER_PATH # - kubectl delete namespaces tfs || true -# -# # Clean old docker images -# - docker images --filter="dangling=true" --quiet | xargs -r docker rmi -# -# #coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' -# rules: -# - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' -# - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' -# artifacts: -# when: always -# reports: -# junit: ./src/tests/${TEST_NAME}/report_*.xml + + # Clean old docker images + - docker images --filter="dangling=true" --quiet | xargs -r docker rmi + + #coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' + #- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' + artifacts: + when: always + reports: + junit: ./src/tests/${TEST_NAME}/report_*.xml diff --git a/src/tests/ryu-openflow/data/tfs-topology.json b/src/tests/ryu-openflow/data/tfs-topology.json index e427f16ea95833a1480a84c4fe83d7539c2707ac..d7823d4bb9db98f0d66ac25ba0c6738dad2df2e3 100644 --- a/src/tests/ryu-openflow/data/tfs-topology.json +++ b/src/tests/ryu-openflow/data/tfs-topology.json @@ -14,7 +14,7 @@ { "device_id": {"device_uuid": {"uuid": "RYU"}}, "device_type": "openflow-ryu-controller", "device_drivers": ["DEVICEDRIVER_RYU"], "device_config": {"config_rules": [ - {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "10.0.2.10"}}, + {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "172.20.0.10"}}, {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "8080"}}, {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"timeout": 120}}} ]} diff --git a/src/tests/ryu-openflow/Mininet.Dockerfile b/src/tests/ryu-openflow/mininet/Mininet.Dockerfile similarity index 74% rename from src/tests/ryu-openflow/Mininet.Dockerfile rename to src/tests/ryu-openflow/mininet/Mininet.Dockerfile index a465297e42eb87a4f19cc1b5c07f111feed4fccd..ea18a3dd8e71f298457f44f508e48e6e514eede6 100644 --- a/src/tests/ryu-openflow/Mininet.Dockerfile +++ b/src/tests/ryu-openflow/mininet/Mininet.Dockerfile @@ -12,8 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Based on: https://github.com/iwaseyusuke/docker-mininet + FROM ubuntu:22.04 +USER root +WORKDIR /root + ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && \ apt-get install -y --no-install-recommends iproute2 net-tools openvswitch-switch ca-certificates && \ @@ -22,6 +27,9 @@ RUN apt-get update && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -COPY custom_pentagon_topology.py /opt/custom_pentagon_topology.py +COPY src/tests/ryu-openflow/mininet/custom_pentagon_topology.py /opt/custom_pentagon_topology.py +COPY src/tests/ryu-openflow/mininet/mininet-entrypoint.sh /mininet-entrypoint.sh + +EXPOSE 6633 6653 6640 -CMD ["python3", "/opt/custom_pentagon_topology.py"] +ENTRYPOINT ["/mininet-entrypoint.sh"] diff --git a/src/tests/ryu-openflow/mininet/README.md b/src/tests/ryu-openflow/mininet/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8cc1065555929700dc266561c4c91daec048a645 --- /dev/null +++ b/src/tests/ryu-openflow/mininet/README.md @@ -0,0 +1,3 @@ +# Docker-containerized Mininet environment + +- Based on: https://github.com/iwaseyusuke/docker-mininet diff --git a/src/tests/ryu-openflow/custom_pentagon_topology.py b/src/tests/ryu-openflow/mininet/custom_pentagon_topology.py similarity index 91% rename from src/tests/ryu-openflow/custom_pentagon_topology.py rename to src/tests/ryu-openflow/mininet/custom_pentagon_topology.py index 03605f24a50c81fc2313c329acb3674487270f67..5d9012866a94902505a818a3ac43102538984c33 100644 --- a/src/tests/ryu-openflow/custom_pentagon_topology.py +++ b/src/tests/ryu-openflow/mininet/custom_pentagon_topology.py @@ -18,6 +18,7 @@ from mininet.net import Mininet from mininet.node import RemoteController from mininet.cli import CLI from mininet.link import TCLink +import time class PentagonTopo(Topo): def build(self): @@ -45,11 +46,15 @@ class PentagonTopo(Topo): if __name__ == '__main__': topo = PentagonTopo() - net = Mininet(topo=topo, controller=lambda name: RemoteController(name, ip='127.0.0.1'), link=TCLink) + net = Mininet(topo=topo, controller=lambda name: RemoteController(name, ip='172.20.0.10', port=6653), link=TCLink) net.start() net.staticArp() print('Custom Pentagon Topology is up with static ARP.') - CLI(net) - net.stop() + #CLI(net) + while True: + time.sleep(60) + #while True: + #time.sleep(60) + #net.stop() diff --git a/src/tests/ryu-openflow/mininet/mininet-entrypoint.sh b/src/tests/ryu-openflow/mininet/mininet-entrypoint.sh new file mode 100755 index 0000000000000000000000000000000000000000..525e89d0a59eac7eb0508318bc7eddeecd556f8c --- /dev/null +++ b/src/tests/ryu-openflow/mininet/mininet-entrypoint.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Based on: https://github.com/iwaseyusuke/docker-mininet + +service openvswitch-switch start +ovs-vsctl set-manager ptcp:6640 + +python3 /opt/custom_pentagon_topology.py + +service openvswitch-switch stop