Skip to content
Draft
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
3 changes: 3 additions & 0 deletions .github/workflows/flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ jobs:
matrix:
which_test: [ static_flow, no_mirror, flakey_broker, dynamic_flow, restart_server, partitioned_flow ]
osver: [ "ubuntu-22.04", "ubuntu-24.04" ]
# Fork proof runs use local fixtures; dynamic_flow consumes live datamarts.
exclude:
- which_test: ${{ github.repository == 'robjarawan/sarracenia' && 'dynamic_flow' || '__none__' }}

runs-on: ${{ matrix.osver }}

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/flow_amqp_consumer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
matrix:
which_test: [ static_flow, no_mirror, flakey_broker, dynamic_flow, restart_server ]
osver: [ "ubuntu-22.04", "ubuntu-24.04" ]
# Fork proof runs use local fixtures; dynamic_flow consumes live datamarts.
exclude:
- which_test: ${{ github.repository == 'robjarawan/sarracenia' && 'dynamic_flow' || '__none__' }}

runs-on: ${{ matrix.osver }}

Expand Down
69 changes: 31 additions & 38 deletions .github/workflows/flow_basic.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,46 @@
name: sr_insects test basic declare/cleanup, and python API
name: Maintenance and Python API tests

on:
pull_request:
types: [opened, edited, reopened]
types: [opened, synchronize, reopened]
push:
paths-ignore:
- '.github/**'
- 'debian/changelog'
- 'TODO.txt'


workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false

jobs:

run_sr_insects_tests:

maintenance:
strategy:
# Don't cancel the entire matrix when one job fails
fail-fast: false
matrix:
osver: [ "ubuntu-22.04", "ubuntu-24.04" ]

runs-on: ${{ matrix.osver }}

name: Maintenance test on ${{ matrix.osver }}
timeout-minutes: 40

include:
- os: ubuntu-22.04
python: '3.10'
- os: ubuntu-24.04
python: '3.12'
runs-on: ${{ matrix.os }}
name: Maintenance test on ${{ matrix.os }}
timeout-minutes: 10
services:
rabbitmq:
image: rabbitmq:4-alpine
ports:
- 5672:5672
env:
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: '+S 2:2 +A 2'
options: >-
--health-cmd "rabbitmq-diagnostics -q check_port_connectivity"
--health-interval 5s
--health-timeout 5s
--health-retries 12
steps:
- uses: actions/checkout@v6

- name: Install dependencies
run: |
travis/flow_autoconfig.sh
travis/ssh_localhost.sh

# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}

- name: Add and Remove configs,
run: |
pwd
ls
cd ${HOME}/sr_insects/static_flow; ./flow_maint_test.sh
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
- name: Install the package under test
run: python -m pip install '.[amqp]'
- name: Check local maintenance and Python APIs
working-directory: ${{ runner.temp }}
run: python "$GITHUB_WORKSPACE/tests/maintenance/run.py"
3 changes: 3 additions & 0 deletions .github/workflows/flow_mqtt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
matrix:
which_test: [ static_flow, no_mirror, flakey_broker, dynamic_flow ]
osver: [ "ubuntu-22.04", "ubuntu-24.04" ]
# Fork proof runs use local fixtures; dynamic_flow consumes live datamarts.
exclude:
- which_test: ${{ github.repository == 'robjarawan/sarracenia' && 'dynamic_flow' || '__none__' }}

runs-on: ${{ matrix.osver }}

Expand Down
7 changes: 3 additions & 4 deletions sarracenia/flowcb/gather/am.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
André LeBlanc, ANL, Autumn 2022
"""

import logging, socket, struct, time, sys, os, signal, ipaddress, urllib.parse, getpass, psutil
import logging, socket, struct, time, sys, os, ipaddress, urllib.parse, getpass, psutil
import re
from base64 import b64encode
from random import randint
Expand Down Expand Up @@ -113,9 +113,8 @@ def __init__(self, options):
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

# Add signal handler
## Override outer signal handler with a default one to exit correctly.
signal.signal(signal.SIGTERM, signal.SIG_DFL)
# Let the parent flow's signal handler manage graceful shutdown.
# Previously overrode with SIG_DFL which bypassed all cleanup.


def __WaitForRemoteConnections__(self) -> NoReturn:
Expand Down
7 changes: 3 additions & 4 deletions sarracenia/flowcb/send/am.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
André LeBlanc, ANL, Autumn 2022
"""

import logging, socket, struct, time, signal, sys, os
import logging, socket, struct, time, sys, os
import urllib.parse
from sarracenia.flowcb import FlowCB

Expand Down Expand Up @@ -63,9 +63,8 @@ def __init__(self, options):
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 2)

# Add signal handler
## Override outer signal handler with a default one to exit correctly.
signal.signal(signal.SIGTERM, signal.SIG_DFL)
# Let the parent flow's signal handler manage graceful shutdown.
# Previously overrode with SIG_DFL which bypassed all cleanup.


def wrapbulletin(self, sarra_msg):
Expand Down
107 changes: 107 additions & 0 deletions tests/maintenance/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Local maintenance and Python API checks

Author: Rob Jarawan - Data Interchange

This check exercises the installed SR3 package with two subscriber configurations,
one one-shot post configuration, five generated files, and a disposable local
RabbitMQ. It replaces the maintenance job's downloads of examples from upstream
branch names and its dependence on public data feeds.

The separate static/protocol flow suites still cover the wider flow fixture set,
including C components. This focused Python maintenance check does not replace
those suites or claim a complete flow/platform verification gate.

## What is checked

| Operation | Required result |
| --- | --- |
| `sr3 add` | Each generated configuration is copied without changes |
| `sr3 declare` | Both named queues exist and start empty |
| Moth publisher/subscriber API | Five distinct products arrive with the expected sizes and identities; each is acknowledged |
| Subscribe Flow API | A bounded worker downloads exactly the five complete files and drains its queue |
| `sr3 cleanup` | Both queues disappear; the selected count includes the one-shot post configuration |
| `sr3 remove` | All three generated configuration files disappear |

SR3 can return zero after logging a refused maintenance action. The check therefore
verifies broker/filesystem outcomes as well as command exit status. An empty poll
is not counted as a delivered message. It rejects execution against a source-tree
import and prints the installed module path and Python version.

The fixture finalizes the added configurations through the Python API before
running maintenance commands, including creation of their private cache directories.
This check does not claim coverage of startup with missing cache directories.

## Reproduce locally

Prerequisites: Docker and public package/image downloads. Run from this PR's
checkout. No host home directory, credentials, or operational configuration is
mounted. The test creates its own private XDG directories.

Build an image containing the installed package and the matching test script:

```bash
docker build -t sr-maintenance-check -f - . <<'DOCKERFILE'
FROM python:3.10-slim
WORKDIR /package
COPY . .
RUN pip install --no-cache-dir '.[amqp]'
RUN useradd --create-home maintenance
USER maintenance
WORKDIR /tmp
CMD ["python", "/package/tests/maintenance/run.py"]
DOCKERFILE
```

Start a dedicated broker without external networking or published ports:

```bash
docker run -d --name sr-maintenance-check-broker --network none --memory 384m --cpus 1 \
-e 'RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=+S 2:2 +A 2' rabbitmq:4-alpine
docker exec sr-maintenance-check-broker rabbitmq-diagnostics -q check_port_connectivity
```

Wait until the readiness check succeeds. Then run the check:

```bash
docker run --rm --network container:sr-maintenance-check-broker --memory 512m --cpus 1 \
--pids-limit 128 sr-maintenance-check
```

Success ends with a JSON `PASS` result naming the five products and reporting
three removed configurations and two removed queues. The workflow runs this same
script against the package installed on Ubuntu 22.04/Python 3.10 and
Ubuntu 24.04/Python 3.12, using the runner's local RabbitMQ service.

## Failure controls

Each command below is expected to exit nonzero. Run them separately from the
successful case so an expected failure does not stop the comparison.

```bash
docker run --rm --network container:sr-maintenance-check-broker --memory 512m --cpus 1 \
sr-maintenance-check python /package/tests/maintenance/run.py --publish-count 4
docker run --rm --network container:sr-maintenance-check-broker --memory 512m --cpus 1 \
sr-maintenance-check python /package/tests/maintenance/run.py --legacy-cleanup-count
```

The first case must reject four delivered products instead of counting empty polls
as the fifth. The second reproduces the former `sr3 status | grep stop` count
against the actual CLI and must detect the queue left after refused cleanup.
The failed CI's HTTP 404 path is removed entirely: neither GitHub branch names
nor downloaded examples participate in this test.

## Cleanup and rollback

The script removes its private files and only its uniquely named broker resources,
including after an assertion failure. CLI and Flow subprocesses have deadlines;
the workflow also has a ten-minute timeout. Stop/remove the dedicated broker after
the runs:

```bash
docker stop sr-maintenance-check-broker
docker rm sr-maintenance-check-broker
```

Reverting the isolated CI commit restores the old runner; it does not change SR3
runtime code or deploy anything. Keep the observed logs before removing images.
Contact: Rob Jarawan. Related fork issue: #139.
Loading
Loading