8 Commits

Author SHA1 Message Date
hasslesstech 564fe329f3 Merge remote-tracking branch 'github/lab1_huranets' into lab1_huranets
Test Agent / test-agent-run (push) Successful in 5m49s
2026-02-24 21:00:15 +02:00
hasslesstech 29196ba400 test
Test Agent / test-agent-run (push) Successful in 5m47s
2026-02-24 14:55:54 +02:00
bacant150 72e9f65b27 Add mosquitto runtime folders to gitignore
Test Agent / test-agent-run (push) Successful in 5m23s
2026-02-24 14:47:21 +02:00
bacant150 2b6bed70d8 Fix timestamp field in AggregatedData 2026-02-24 14:47:21 +02:00
bacant150 21ee14ccd1 Реалізовую базовий FileReader та переношу sleep до FileDatasource.read() 2026-02-24 14:47:17 +02:00
hasslesstech b330180909 lab1: add CI/CD testing
Test Agent / test-agent-run (push) Successful in 5m24s
2026-02-24 10:16:28 +02:00
VladiusVostokus b2c7427af0 Merge pull request #1 from Rhinemann/lab1_shved
updated compose file
2026-02-23 16:10:12 +00:00
Rhinemann e45faeb281 updated compose file 2026-02-22 11:22:19 +01:00
7 changed files with 77 additions and 6 deletions
+25
View File
@@ -0,0 +1,25 @@
name: Test Agent
on: [push, workflow_dispatch]
jobs:
test-agent-run:
runs-on: arch-x86_64
steps:
- name: Fetch the repository
run: git clone --branch ${{ gitea.ref_name }} --depth 1 ${{ gitea.server_url }}/${{ gitea.repository }}
- name: Build containers
run: docker-compose -f docker-compose-test.yaml build
working-directory: sem8-iot-test/agent/docker
- name: Start MQTT broker
run: docker-compose -f docker-compose-test.yaml up -d mqtt
working-directory: sem8-iot-test/agent/docker
- name: Start agent
run: docker-compose -f docker-compose-test.yaml run fake_agent
working-directory: sem8-iot-test/agent/docker
- name: Clean up
if: always()
run: docker-compose -f docker-compose-test.yaml down
working-directory: sem8-iot-test/agent/docker
+34
View File
@@ -0,0 +1,34 @@
version: "3.3"
#name: "road_vision"
services:
mqtt:
image: eclipse-mosquitto
container_name: mqtt
volumes:
- ./mosquitto:/mosquitto
- ./mosquitto/data:/mosquitto/data
- ./mosquitto/log:/mosquitto/log
ports:
- 1883:1883
- 9001:9001
networks:
mqtt_network:
fake_agent:
container_name: agent
build: ../
depends_on:
- mqtt
environment:
MQTT_BROKER_HOST: "mqtt"
MQTT_BROKER_PORT: 1883
MQTT_TOPIC: "agent_data_topic"
DELAY: 0.1
MAX_SENDS: 30
networks:
mqtt_network:
networks:
mqtt_network:
+2 -2
View File
@@ -1,5 +1,5 @@
version: "3.9" version: "3.3"
name: "road_vision" #name: "road_vision"
services: services:
mqtt: mqtt:
image: eclipse-mosquitto image: eclipse-mosquitto
+3
View File
@@ -16,3 +16,6 @@ MQTT_TOPIC = os.environ.get("MQTT_TOPIC") or "agent"
# Delay for sending data to mqtt in seconds # Delay for sending data to mqtt in seconds
DELAY = try_parse(float, os.environ.get("DELAY")) or 1 DELAY = try_parse(float, os.environ.get("DELAY")) or 1
# Testing switches for CI/CD
MAX_SENDS = try_parse(int, os.environ.get("MAX_SENDS"))
+1 -1
View File
@@ -229,4 +229,4 @@ class FileDatasource:
float(s) float(s)
return True return True
except Exception: except Exception:
return False return False
+11 -3
View File
@@ -22,9 +22,13 @@ def connect_mqtt(broker, port):
return client return client
def publish(client, topic, datasource): def publish(client, topic, datasource, max_sends = None):
datasource.startReading() datasource.startReading()
i = 0
while True: while True:
i += 1
data = datasource.read() data = datasource.read()
msg = AggregatedDataSchema().dumps(data) msg = AggregatedDataSchema().dumps(data)
result = client.publish(topic, msg) result = client.publish(topic, msg)
@@ -32,6 +36,10 @@ def publish(client, topic, datasource):
if status != 0: if status != 0:
print(f"Failed to send message to topic {topic}") print(f"Failed to send message to topic {topic}")
if max_sends and i >= max_sends:
# display test success
exit(0)
def run(): def run():
# Prepare mqtt client # Prepare mqtt client
@@ -39,8 +47,8 @@ def run():
# Prepare datasource # Prepare datasource
datasource = FileDatasource("data/accelerometer.csv", "data/gps.csv") datasource = FileDatasource("data/accelerometer.csv", "data/gps.csv")
# Infinity publish data # Infinity publish data
publish(client, config.MQTT_TOPIC, datasource) publish(client, config.MQTT_TOPIC, datasource, getattr(config, "MAX_SENDS", None))
if __name__ == "__main__": if __name__ == "__main__":
run() run()
+1
View File
@@ -13,6 +13,7 @@ services:
- 19001:9001 - 19001:9001
networks: networks:
mqtt_network: mqtt_network:
user: 1000:1000
edge: edge: