← Back to team overview

canonical-hw-cert team mailing list archive

[Merge] ~pwlars/hwcert-jenkins-tools/+git/tf-cmd-scripts:update-script-for-monorepo-transition into ~canonical-hw-cert/hwcert-jenkins-tools/+git/tf-cmd-scripts:master

 

Paul Larson has proposed merging ~pwlars/hwcert-jenkins-tools/+git/tf-cmd-scripts:update-script-for-monorepo-transition into ~canonical-hw-cert/hwcert-jenkins-tools/+git/tf-cmd-scripts:master.

Requested reviews:
  Canonical Hardware Certification (canonical-hw-cert)

For more details, see:
https://code.launchpad.net/~pwlars/hwcert-jenkins-tools/+git/tf-cmd-scripts/+merge/455089

I've tested this by copying this version of the scripts to the tel4 agent host /usr/local/bin and trying it with the old device agents. The main things this changes are:
- rename snappy-device-agent command to testflinger-device-connector
- locate the config files in /srv/testflinger/<agent-name> (instead of being under testflinger-agents and snappy-device-agents)

The main reason for this is so that during the transition to the monorepo, these scripts should work with both the old testflinger-agents deployed by the old charm, as well as with the new charm proposed in https://github.com/canonical/testflinger/pull/155 that uses the monorepo.
-- 
Your team Canonical Hardware Certification is requested to review the proposed merge of ~pwlars/hwcert-jenkins-tools/+git/tf-cmd-scripts:update-script-for-monorepo-transition into ~canonical-hw-cert/hwcert-jenkins-tools/+git/tf-cmd-scripts:master.
diff --git a/tf-allocate b/tf-allocate
index 5ea35ac..92368fe 100755
--- a/tf-allocate
+++ b/tf-allocate
@@ -3,5 +3,8 @@
 AGENT=$(echo $agent_id | sed 's/-\([0-9]*\)$/\1/g')
 PROVISION_TYPE="$provision_type"
 
-. /srv/testflinger-agent/$AGENT/env/bin/activate && PYTHONIOENCODING=utf-8 PYTHONUNBUFFERED=1 snappy-device-agent $PROVISION_TYPE allocate -c /srv/testflinger-agent/$AGENT/snappy-device-agents/default.yaml testflinger.json
-
+if [ -f /srv/testflinger-agent/$AGENT/testflinger-agent.conf ]; then
+        . /srv/testflinger-agent/$AGENT/env/bin/activate && PYTHONUNBUFFERED=1 testflinger-device-connector $PROVISION_TYPE allocate -c /srv/testflinger-agent/$AGENT/default.yaml testflinger.json
+else
+        . /srv/testflinger-agent/$AGENT/env/bin/activate && PYTHONIOENCODING=utf-8 PYTHONUNBUFFERED=1 snappy-device-agent $PROVISION_TYPE allocate -c /srv/testflinger-agent/$AGENT/snappy-device-agents/default.yaml testflinger.json
+fi
diff --git a/tf-provision b/tf-provision
index 921cd2d..f4f5887 100755
--- a/tf-provision
+++ b/tf-provision
@@ -3,5 +3,8 @@
 AGENT=$(echo $agent_id | sed 's/-\([0-9]*\)$/\1/g')
 PROVISION_TYPE="$provision_type"
 
-. /srv/testflinger-agent/$AGENT/env/bin/activate && PYTHONIOENCODING=utf-8 PYTHONUNBUFFERED=1 snappy-device-agent $PROVISION_TYPE provision -c /srv/testflinger-agent/$AGENT/snappy-device-agents/default.yaml testflinger.json
-
+if [ -f /srv/testflinger-agent/$AGENT/testflinger-agent.conf ]; then
+        . /srv/testflinger-agent/$AGENT/env/bin/activate && PYTHONUNBUFFERED=1 testflinger-device-connector $PROVISION_TYPE provision -c /srv/testflinger-agent/$AGENT/default.yaml testflinger.json
+else
+        . /srv/testflinger-agent/$AGENT/env/bin/activate && PYTHONIOENCODING=utf-8 PYTHONUNBUFFERED=1 snappy-device-agent $PROVISION_TYPE provision -c /srv/testflinger-agent/$AGENT/snappy-device-agents/default.yaml testflinger.json
+fi
diff --git a/tf-reserve b/tf-reserve
index 432255f..2d94099 100755
--- a/tf-reserve
+++ b/tf-reserve
@@ -3,4 +3,8 @@
 AGENT=$(echo $agent_id | sed 's/-\([0-9]*\)$/\1/g')
 PROVISION_TYPE="$provision_type"
 
-. /srv/testflinger-agent/$AGENT/env/bin/activate && PYTHONIOENCODING=utf-8 PYTHONUNBUFFERED=1 snappy-device-agent $PROVISION_TYPE reserve -c /srv/testflinger-agent/$AGENT/snappy-device-agents/default.yaml testflinger.json
+if [ -f /srv/testflinger-agent/$AGENT/testflinger-agent.conf ]; then
+        . /srv/testflinger-agent/$AGENT/env/bin/activate && PYTHONUNBUFFERED=1 testflinger-device-connector $PROVISION_TYPE reserve -c /srv/testflinger-agent/$AGENT/default.yaml testflinger.json
+else
+        . /srv/testflinger-agent/$AGENT/env/bin/activate && PYTHONIOENCODING=utf-8 PYTHONUNBUFFERED=1 snappy-device-agent $PROVISION_TYPE reserve -c /srv/testflinger-agent/$AGENT/snappy-device-agents/default.yaml testflinger.json
+fi
diff --git a/tf-test b/tf-test
index 4a3aab9..28429d2 100755
--- a/tf-test
+++ b/tf-test
@@ -3,4 +3,8 @@
 AGENT=$(echo $agent_id | sed 's/-\([0-9]*\)$/\1/g')
 PROVISION_TYPE="$provision_type"
 
-docker run -t --name $AGENT -v $PWD:/home/ubuntu -v ~/.ssh:/home/ubuntu/.ssh:ro -v /srv/testflinger-agent/$AGENT:/srv/testflinger-agent/$AGENT plars/testflinger-testenv-focal bash -c "(cd /srv/testflinger-agent/$AGENT/snappy-device-agents && sudo ./setup.py install &> /dev/null) && PYTHONIOENCODING=utf-8 PYTHONUNBUFFERED=1 snappy-device-agent $PROVISION_TYPE runtest -c /srv/testflinger-agent/$AGENT/snappy-device-agents/default.yaml testflinger.json"
+if [ -f /srv/testflinger-agent/$AGENT/testflinger-agent.conf ]; then
+        docker run -t --name $AGENT -v $PWD:/home/ubuntu -v ~/.ssh:/home/ubuntu/.ssh:ro -v /srv/testflinger-agent/$AGENT:/srv/testflinger-agent/$AGENT plars/testflinger-testenv-focal bash -c "(cd /srv/testflinger-agent/$AGENT/testflinger/device-connectors && sudo ./setup.py install &> /dev/null) && PYTHONUNBUFFERED=1 testflinger-device-connector $PROVISION_TYPE runtest -c /srv/testflinger-agent/$AGENT/default.yaml testflinger.json"
+else
+        docker run -t --name $AGENT -v $PWD:/home/ubuntu -v ~/.ssh:/home/ubuntu/.ssh:ro -v /srv/testflinger-agent/$AGENT:/srv/testflinger-agent/$AGENT plars/testflinger-testenv-focal bash -c "(cd /srv/testflinger-agent/$AGENT/snappy-device-agents && sudo ./setup.py install &> /dev/null) && PYTHONIOENCODING=utf-8 PYTHONUNBUFFERED=1 snappy-device-agent $PROVISION_TYPE runtest -c /srv/testflinger-agent/$AGENT/snappy-device-agents/default.yaml testflinger.json"
+fi

Follow ups