Skip to content

Commit d4ca193

Browse files
committed
feat(tests): add bricks index test and YAML data for bricks
1 parent 18e0cca commit d4ca193

File tree

2 files changed

+141
-146
lines changed

2 files changed

+141
-146
lines changed

internal/orchestrator/bricksindex/bricks_index_test.go

Lines changed: 8 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -20,150 +20,12 @@ import (
2020
"testing"
2121

2222
"github.com/arduino/go-paths-helper"
23-
yaml "github.com/goccy/go-yaml"
2423
"github.com/stretchr/testify/require"
2524
)
2625

27-
func TestBricksIndex(t *testing.T) {
28-
x := `bricks:
29-
- id: arduino:image_classification
30-
name: Image Classification
31-
description: "Brick for image classification using a pre-trained model. It processes\
32-
\ images and returns the predicted class label and confidence score.\nBrick is\
33-
\ designed to work with pre-trained models provided by framework or with custom\
34-
\ image classification models trained on Edge Impulse platform. \n"
35-
require_container: true
36-
require_model: true
37-
ports: []
38-
model_name: mobilenet-image-classification
39-
variables:
40-
- name: CUSTOM_MODEL_PATH
41-
default_value: /opt/models/ei/
42-
description: path to the custom model directory
43-
- name: EI_CLASSIFICATION_MODEL
44-
default_value: /models/ootb/ei/mobilenet-v2-224px.eim
45-
description: path to the model file
46-
- id: arduino:camera_scanner
47-
name: Camera Scanner
48-
description: Scans a camera for barcodes and QR codes
49-
require_container: false
50-
require_model: false
51-
ports: []
52-
- id: arduino:streamlit_ui
53-
name: Streamlit UI
54-
description: A simplified user interface based on Streamlit and Python.
55-
require_container: false
56-
require_model: false
57-
ports:
58-
- 7000
59-
- id: arduino:keyword_spotter
60-
name: Keyword Spotter
61-
description: 'Brick for keyword spotting using a pre-trained model. It processes
62-
audio input to detect specific keywords or phrases.
63-
64-
Brick is designed to work with pre-trained models provided by framework or with
65-
custom audio classification models trained on Edge Impulse platform.
66-
67-
'
68-
require_container: true
69-
require_model: true
70-
ports: []
71-
model_name: keyword-spotting-hello-world
72-
variables:
73-
- name: CUSTOM_MODEL_PATH
74-
default_value: /opt/models/ei/
75-
description: path to the custom model directory
76-
- name: EI_KEYWORK_SPOTTING_MODEL
77-
default_value: /models/ootb/ei/keyword-spotting-hello-world.eim
78-
description: path to the model file
79-
- id: arduino:mqtt
80-
name: MQTT Connector
81-
description: MQTT connector module. Acts as a client for receiving and publishing
82-
messages to an MQTT broker.
83-
require_container: false
84-
require_model: false
85-
ports: []
86-
- id: arduino:web_ui
87-
name: Web UI
88-
description: A user interface based on HTML and JavaScript that can rely on additional
89-
APIs and a WebSocket exposed by a web server.
90-
require_container: false
91-
require_model: false
92-
ports:
93-
- 7000
94-
- id: arduino:dbstorage_tsstore
95-
name: Database Storage - Time Series Store
96-
description: Simplified time series database storage layer for Arduino sensor samples
97-
built on top of InfluxDB.
98-
require_container: true
99-
require_model: false
100-
ports: []
101-
variables:
102-
- name: APP_HOME
103-
default_value: .
104-
- name: DB_PASSWORD
105-
default_value: Arduino15
106-
description: Database password
107-
- name: DB_USERNAME
108-
default_value: admin
109-
description: Edge Impulse project API key
110-
- name: INFLUXDB_ADMIN_TOKEN
111-
default_value: 392edbf2-b8a2-481f-979d-3f188b2c05f0
112-
description: InfluxDB admin token
113-
- id: arduino:dbstorage_sqlstore
114-
name: Database Storage - SQLStore
115-
description: Simplified database storage layer for Arduino sensor data using SQLite
116-
local database.
117-
require_container: false
118-
require_model: false
119-
ports: []
120-
- id: arduino:object_detection
121-
name: Object Detection
122-
description: "Brick for object detection using a pre-trained model. It processes\
123-
\ images and returns the predicted class label, bounding-boxes and confidence\
124-
\ score.\nBrick is designed to work with pre-trained models provided by framework\
125-
\ or with custom object detection models trained on Edge Impulse platform. \n"
126-
require_container: true
127-
require_model: true
128-
ports: []
129-
model_name: yolox-object-detection
130-
variables:
131-
- name: CUSTOM_MODEL_PATH
132-
default_value: /opt/models/ei/
133-
description: path to the custom model directory
134-
- name: EI_OBJ_DETECTION_MODEL
135-
default_value: /models/ootb/ei/yolo-x-nano.eim
136-
description: path to the model file
137-
- id: arduino:weather_forecast
138-
name: Weather Forecast
139-
description: Online weather forecast module for Arduino using open-meteo.com geolocation
140-
and weather APIs. Requires an internet connection.
141-
require_container: false
142-
require_model: false
143-
ports: []
144-
- id: arduino:visual_anomaly_detection
145-
name: Visual Anomaly Detection
146-
description: "Brick for visual anomaly detection using a pre-trained model. It processes\
147-
\ images and returns detected anomalies and bounding-boxes.\nBrick is designed\
148-
\ to work with pre-trained models provided by framework or with custom object\
149-
\ detection models trained on Edge Impulse platform. \n"
150-
require_container: true
151-
require_model: true
152-
ports: []
153-
model_name: concreate-crack-anomaly-detection
154-
variables:
155-
- name: CUSTOM_MODEL_PATH
156-
default_value: /opt/models/ei/
157-
description: path to the custom model directory
158-
- name: EI_V_ANOMALY_DETECTION_MODEL
159-
default_value: /models/ootb/ei/concrete-crack-anomaly-detection.eim
160-
description: path to the model file
161-
`
162-
163-
var index BricksIndex
164-
err := yaml.Unmarshal([]byte(x), &index)
26+
func TestGenerateBricksIndexFromFile(t *testing.T) {
27+
index, err := GenerateBricksIndexFromFile(paths.New("testdata"))
16528
require.NoError(t, err)
166-
require.Len(t, index.Bricks, 11)
16729

16830
// Check if ports are correctly set
16931
b, found := index.FindBrickByID("arduino:web_ui")
@@ -195,13 +57,13 @@ func TestBricksIndexYAMLFormats(t *testing.T) {
19557
expectedBricks []Brick
19658
}{
19759
{
198-
// TODO: the validator of the brick-list must not allow this
60+
// TODO: add a validator fo the bricks-list to validate the field
19961
name: "missing bricks field does not cuase error",
20062
yamlContent: `other_field: value`,
20163
expectedBricks: nil,
20264
},
20365
{
204-
name: "bad YAML format - invalid indentation",
66+
name: "bad YAML format invalid indentation",
20567
yamlContent: `bricks:
20668
- id: arduino:test_brick
20769
name: Test Brick
@@ -214,22 +76,22 @@ func TestBricksIndexYAMLFormats(t *testing.T) {
21476
expectedBricks: []Brick{},
21577
},
21678
{
217-
name: "bad YAML format - unclosed quotes",
79+
name: "bad YAML format unclosed quotes",
21880
yamlContent: `bricks:
21981
- id: "arduino:test_brick
22082
name: Test Brick
22183
description: A test brick`,
22284
expectedError: "could not find end character of double-quoted text",
22385
},
22486
{
225-
name: "bad YAML format - missing colon",
87+
name: "bad YAML format missing colon",
22688
yamlContent: `bricks:
22789
- id arduino:test_brick
22890
name: Test Brick`,
22991
expectedError: "unexpected key name",
23092
},
23193
{
232-
name: "bad YAML format - invalid syntax",
94+
name: "bad YAML format invalid syntax",
23395
yamlContent: `bricks:
23496
- id: arduino:test_brick
23597
name: Test Brick
@@ -238,7 +100,7 @@ func TestBricksIndexYAMLFormats(t *testing.T) {
238100
expectedError: "sequence end token ']' not found",
239101
},
240102
{
241-
name: "bad YAML format - tab characters",
103+
name: "bad YAML format tab characters",
242104
yamlContent: "bricks:\n\t- id: arduino:test_brick\n\t name: Test Brick",
243105
expectedError: "found character '\t' that cannot start any token",
244106
},
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
bricks:
2+
- id: arduino:image_classification
3+
name: Image Classification
4+
description: "Brick for image classification using a pre-trained model. It processes\
5+
\ images and returns the predicted class label and confidence score.\nBrick is\
6+
\ designed to work with pre-trained models provided by framework or with custom\
7+
\ image classification models trained on Edge Impulse platform. \n"
8+
require_container: true
9+
require_model: true
10+
ports: []
11+
model_name: mobilenet-image-classification
12+
variables:
13+
- name: CUSTOM_MODEL_PATH
14+
default_value: /opt/models/ei/
15+
description: path to the custom model directory
16+
- name: EI_CLASSIFICATION_MODEL
17+
default_value: /models/ootb/ei/mobilenet-v2-224px.eim
18+
description: path to the model file
19+
- id: arduino:camera_scanner
20+
name: Camera Scanner
21+
description: Scans a camera for barcodes and QR codes
22+
require_container: false
23+
require_model: false
24+
ports: []
25+
- id: arduino:streamlit_ui
26+
name: Streamlit UI
27+
description: A simplified user interface based on Streamlit and Python.
28+
require_container: false
29+
require_model: false
30+
ports:
31+
- 7000
32+
- id: arduino:keyword_spotter
33+
name: Keyword Spotter
34+
description: 'Brick for keyword spotting using a pre-trained model. It processes
35+
audio input to detect specific keywords or phrases.
36+
37+
Brick is designed to work with pre-trained models provided by framework or with
38+
custom audio classification models trained on Edge Impulse platform.
39+
40+
'
41+
require_container: true
42+
require_model: true
43+
ports: []
44+
model_name: keyword-spotting-hello-world
45+
variables:
46+
- name: CUSTOM_MODEL_PATH
47+
default_value: /opt/models/ei/
48+
description: path to the custom model directory
49+
- name: EI_KEYWORK_SPOTTING_MODEL
50+
default_value: /models/ootb/ei/keyword-spotting-hello-world.eim
51+
description: path to the model file
52+
- id: arduino:mqtt
53+
name: MQTT Connector
54+
description: MQTT connector module. Acts as a client for receiving and publishing
55+
messages to an MQTT broker.
56+
require_container: false
57+
require_model: false
58+
ports: []
59+
- id: arduino:web_ui
60+
name: Web UI
61+
description: A user interface based on HTML and JavaScript that can rely on additional
62+
APIs and a WebSocket exposed by a web server.
63+
require_container: false
64+
require_model: false
65+
ports:
66+
- 7000
67+
- id: arduino:dbstorage_tsstore
68+
name: Database Storage - Time Series Store
69+
description: Simplified time series database storage layer for Arduino sensor samples
70+
built on top of InfluxDB.
71+
require_container: true
72+
require_model: false
73+
ports: []
74+
variables:
75+
- name: APP_HOME
76+
default_value: .
77+
- name: DB_PASSWORD
78+
default_value: Arduino15
79+
description: Database password
80+
- name: DB_USERNAME
81+
default_value: admin
82+
description: Edge Impulse project API key
83+
- name: INFLUXDB_ADMIN_TOKEN
84+
default_value: 392edbf2-b8a2-481f-979d-3f188b2c05f0
85+
description: InfluxDB admin token
86+
- id: arduino:dbstorage_sqlstore
87+
name: Database Storage - SQLStore
88+
description: Simplified database storage layer for Arduino sensor data using SQLite
89+
local database.
90+
require_container: false
91+
require_model: false
92+
ports: []
93+
- id: arduino:object_detection
94+
name: Object Detection
95+
description: "Brick for object detection using a pre-trained model. It processes\
96+
\ images and returns the predicted class label, bounding-boxes and confidence\
97+
\ score.\nBrick is designed to work with pre-trained models provided by framework\
98+
\ or with custom object detection models trained on Edge Impulse platform. \n"
99+
require_container: true
100+
require_model: true
101+
ports: []
102+
model_name: yolox-object-detection
103+
variables:
104+
- name: CUSTOM_MODEL_PATH
105+
default_value: /opt/models/ei/
106+
description: path to the custom model directory
107+
- name: EI_OBJ_DETECTION_MODEL
108+
default_value: /models/ootb/ei/yolo-x-nano.eim
109+
description: path to the model file
110+
- id: arduino:weather_forecast
111+
name: Weather Forecast
112+
description: Online weather forecast module for Arduino using open-meteo.com geolocation
113+
and weather APIs. Requires an internet connection.
114+
require_container: false
115+
require_model: false
116+
ports: []
117+
- id: arduino:visual_anomaly_detection
118+
name: Visual Anomaly Detection
119+
description: "Brick for visual anomaly detection using a pre-trained model. It processes\
120+
\ images and returns detected anomalies and bounding-boxes.\nBrick is designed\
121+
\ to work with pre-trained models provided by framework or with custom object\
122+
\ detection models trained on Edge Impulse platform. \n"
123+
require_container: true
124+
require_model: true
125+
ports: []
126+
model_name: concreate-crack-anomaly-detection
127+
variables:
128+
- name: CUSTOM_MODEL_PATH
129+
default_value: /opt/models/ei/
130+
description: path to the custom model directory
131+
- name: EI_V_ANOMALY_DETECTION_MODEL
132+
default_value: /models/ootb/ei/concrete-crack-anomaly-detection.eim
133+
description: path to the model file

0 commit comments

Comments
 (0)