Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jonlamb-gh committed Feb 13, 2024
1 parent cf34b05 commit 463e653
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Integration Tests
#on: [workflow_dispatch]
on: [push]

env:
MODALITY_URL: "http://localhost:14181/v1"
MODALITY_WORKSPACE: "ci-tests"
RENODE_CI_MODE: YES

jobs:
demo:
name: Run, collect, and test
timeout-minutes: 30
runs-on: ubuntu-22.04
steps:
- name: Print Environment
run: |
echo "GITHUB_WORKFLOW=$GITHUB_WORKFLOW"
echo "GITHUB_RUN_ID=$GITHUB_RUN_ID"
echo "GITHUB_RUN_NUMBER=$GITHUB_RUN_NUMBER"
echo "GITHUB_JOB=$GITHUB_JOB"
echo "GITHUB_ACTION=$GITHUB_ACTION"
echo "GITHUB_ACTOR=$GITHUB_ACTOR"
echo "GITHUB_REF=$GITHUB_REF"
echo "GITHUB_SHA=$GITHUB_SHA"
docker --version
- name: Checkout Sources
uses: actions/checkout@v4

- name: Install system packages
run: |
sudo apt-get update
sudo apt-get install -y libusb-1.0-0-dev libftdi1-dev libudev-dev bridge-utils
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
toolchain: stable

- name: Build release binary
run: cargo build --release

- name: Install Auxon Packages
env:
DEBIAN_FRONTEND: noninteractive
run: |
wget --no-verbose --quiet https://get.keygen.sh/auxon-io/auxon.deb -O /tmp/auxon.deb
sudo apt-get install -y /tmp/auxon.deb
sudo apt-get update
sudo apt-get install -y --no-install-recommends modalityd modality-client modality-reflector conform deviant
- name: Setup Modality Server
run: |
sudo systemctl stop modalityd
echo 'license-key = "'"${{secrets.MODALITY_LICENSE_KEY}}"'"' | sudo tee -a /etc/modalityd/config.toml
sudo systemctl start modalityd
sudo systemctl status modalityd --no-pager --full
curl --retry-max-time 30 --retry 10 --retry-connrefused ${{env.MODALITY_URL}}/alive
- name: Setup Initial Modality Configuration
run: |
modality --version
modality config --modalityd ${{env.MODALITY_URL}}
modality user create --use ci
echo "MODALITY_AUTH_TOKEN=$(modality user auth-token)" >> $GITHUB_ENV
modality workspace create --use ${{env.MODALITY_WORKSPACE}} test_system/workspace.toml
- name: Update Reflector Plugins
run: |
sudo cp target/release/modality-trace-recorder-importer /usr/lib/modality-reflector-plugins/importers/
sudo cp target/release/modality-trace-recorder-tcp-collector /usr/lib/modality-reflector-plugins/collectors/
sudo cp target/release/modality-trace-recorder-itm-collector /usr/lib/modality-reflector-plugins/collectors/
- name: Create Specs
run: |
conform spec create --file test_system/specs/device.speqtr device-specs
96 changes: 96 additions & 0 deletions test_system/specs/device.speqtr
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# @author = "[email protected]"
# @project = "Test System"

# @type = "task-resources"
behavior "Task Scheduling Resource Usage"
when "a stats event is logged for a task"
stats @ * (_.task != "IDLE") AS task_stats
end

prohibited case "the task's CPU runtime utilization never exceeds 75%"
(task_stats.task_run_time / task_stats.total_run_time) > 0.75
end

prohibited case "the task's stack usage never exceeds 70%"
(1.0 - (task_stats.stack_high_water / task_stats.stack_size)) > 0.70
end
end

# @type = "memory"
behavior "Heap Usage"
prohibited case "the consumed heap never exceeds 80%"
MEMORY_ALLOC @ * AS alloc
AND
(alloc.internal.trace_recorder.memory.heap_counter / alloc.timeline.heap_size) > 0.80
end
end

# @type = "scheduler"
behavior "Task Activation Time"
prohibited case "ready tasks are activated within 20 ms"
TASK_READY @ * (_.task != "IDLE" AND _.task != "TzCtrl" AND _.timeline.name != "init") as ready
FOLLOWED BY
TASK_ACTIVATE @ * (_.timeline.name = ready.task) AS activated
AND
(activated.timestamp - ready.timestamp) > 20ms
end
end

# @type = "error logs"
behavior "No Errors"
prohibited case "no error messages exist"
* @ * (_.channel = "error" OR _.channel = "#WFR")
end
end

# @type = "led-timer-isr"
behavior "LED Timer Interrupt"
when "the LED timer ISR begins"
TASK_SWITCH_ISR_BEGIN @ LEDTimerISR as isr_begin
end

until "the next LED timer ISR"
TASK_SWITCH_ISR_BEGIN @ LEDTimerISR
end

nominal case "an info message is logged"
isr_begin
FOLLOWED BY
info @ LEDTimerISR (_.formatted_string = "blink")
end
end

# @type = "control-cycle"
behavior "Control Cycle"
when "an ADC measurement is read"
adc @ Sensor as adc
end

until "the next ADC measurement is read"
adc @ Sensor
end

nominal case "program execution follows the control cycle expectations"
adc
FOLLOWED BY
QUEUE_SEND @ Sensor (_.queue = "adc_queue")
FOLLOWED BY
TASK_READY @ Sensor (_.task = "Actuator")
FOLLOWED BY
TASK_ACTIVATE @ Actuator
FOLLOWED BY
QUEUE_RECEIVE @ Actuator (_.queue = "adc_queue")
FOLLOWED BY
pwm @ Actuator as pwm
FOLLOWED BY
QUEUE_SEND @ Actuator (_.queue = "comms_queue")
FOLLOWED BY
TASK_READY @ Actuator (_.task = "Comms")
FOLLOWED BY
TASK_ACTIVATE @ Comms
FOLLOWED BY
QUEUE_RECEIVE @ Comms (_.queue = "comms_queue")
FOLLOWED BY
comms_tx @ Comms (_.adc = adc.measurement AND _.pwm = pwm.value)
end
end
5 changes: 5 additions & 0 deletions test_system/workspace.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[[segmentation-rule]]
name = "by-run-id"
attributes = ["run_id"]
segment-name-template = "Run {timeline.run_id}"
causally-partition-segments = true

0 comments on commit 463e653

Please sign in to comment.