Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define and integrate test run #154

Merged
merged 2 commits into from
Nov 29, 2023
Merged
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
40 changes: 40 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
##

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;
23 changes: 23 additions & 0 deletions testing/infra/machines/nix/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions testing/maskfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

~~~

Expand Down
Loading