diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..da38b7d2 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,40 @@ +## +## Copyright (c) 2019 Matthias Tafelmeier. +## +## This file is part of godon +## +## godon is free software: you can redistribute it and/or modify +## it under the terms of the GNU Affero General Public License as +## published by the Free Software Foundation, either version 3 of the +## License, or (at your option) any later version. +## +## godon is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU Affero General Public License for more details. +## +## You should have received a copy of the GNU Affero General Public License +## along with this godon. If not, see . +## + +on: + pull_request: + types: [ labeled ] + branches: + - master + + +jobs: + test_perform: + if: ${{ contains(github.event.pull_request.labels.*.name, 'tests')}} + runs-on: [self-hosted, linux] # only unique osuosl instance + env: + MASK_FILE: testing/maskfile.md + steps: + - name: perform test run + run: > + source /etc/bashrc; + cp testing/infra/credentials/ssh/id_rsa testing/infra/credentials/ssh/id_rsa_robot; + chmod 0600 testing/infra/credentials/ssh/id_rsa_robot; + + mask --maskfile "${MASK_FILE}" testing perform; diff --git a/testing/infra/machines/nix/configuration.nix b/testing/infra/machines/nix/configuration.nix index adf9d912..5c036b8b 100644 --- a/testing/infra/machines/nix/configuration.nix +++ b/testing/infra/machines/nix/configuration.nix @@ -39,6 +39,29 @@ }; }; + systemd.services.test-client = { + enable = true; + wantedBy = [ ]; + after = [ ]; + description = "Start test-client"; + serviceConfig = { + Type = "exec"; + EnvironmentFile = "/home/test/sink_ip"; + ExecStart = "/run/current-system/sw/bin/iperf3 -P 5 -t 36000 -c $SINK_IP"; + }; + }; + + systemd.services.test-server = { + enable = true; + wantedBy = [ ]; + after = [ ]; + description = "Start test-server"; + serviceConfig = { + Type = "exec"; + ExecStart = "/run/current-system/sw/bin/iperf3 -s"; + }; + }; + environment.systemPackages = with pkgs; [ python3 bashInteractive_5 diff --git a/testing/maskfile.md b/testing/maskfile.md index 9e483720..87c198bf 100755 --- a/testing/maskfile.md +++ b/testing/maskfile.md @@ -243,25 +243,25 @@ docker-compose -f "${MASKFILE_DIR}/../docker-compose.yml" down --remove-orphans ### testing perform -> Perform/Orchestrate Session of Tests Run +> Orchestrate and Perform Session of Test Run ~~~bash set -eEux echo "performing tests" +__kcli_cmd="mask --maskfile ${MASKFILE_DIR}/maskfile.md util kcli run" +__ssh_cmd="ssh -o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${MASKFILE_DIR}/infra/credentials/ssh/id_rsa_robot" + +__source_vm_ip_address=($(${__kcli_cmd} "list vm" | grep 'micro_stack' | grep 'source' | awk -F\| '{ print $4 }' | xargs)) +__sink_vm_ip_address=($(${__kcli_cmd} "list vm" | grep 'micro_stack' | grep 'sink' | awk -F\| '{ print $4 }' | xargs)) + +__sink_vm_test_iface_ip_address=($(${__ssh_cmd} "godon_robot@${__sink_vm_ip_address}" "ip --json a show dev ens8 | jq '.[0].addr_info[0].local'")) - # TODO improvised until formatted parser install -target_ip="$(sudo ansible-inventory --list -y -i ${MASKFILE_DIR}/infra/inventory.sh | - grep ansible_host | head -n 1 | \ - awk -F: '{print $2}' | xargs echo -n)" -svc_name=control_loop -dag_name="lnx_net_stack" +${__ssh_cmd} "godon_robot@${__sink_vm_ip_address}" "sudo systemctl stop test-server; sudo systemctl start test-server" +${__ssh_cmd} "godon_robot@${__source_vm_ip_address}" "echo "SINK_IP=${__sink_vm_test_iface_ip_address}" > /home/test/sink_ip" +${__ssh_cmd} "godon_robot@${__source_vm_ip_address}" "sudo systemctl stop test-client; sudo systemctl start test-client" -sudo docker-compose -f "${MASKFILE_DIR}/docker-compose.yml" exec -T "${svc_name}" \ - airflow variables --set target "${target_ip}" -sudo docker-compose -f "${MASKFILE_DIR}/docker-compose.yml" exec -T "${svc_name}" \ - airflow trigger_dag "${dag_name}" ~~~