Skip to content

Commit e9a0850

Browse files
fix(tests): Re-enable MQTT and Postgres tests
Signed-off-by: Karan <[email protected]>
1 parent 92bb6c5 commit e9a0850

File tree

5 files changed

+34
-13
lines changed

5 files changed

+34
-13
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,32 @@ jobs:
191191
# run on a larger runner for more SSD/resource access
192192
runs-on: ubuntu-22.04-4core-spin
193193
if: ${{ github.repository_owner == 'spinframework' }}
194+
services:
195+
postgres:
196+
image: postgres:15
197+
env:
198+
POSTGRES_USER: postgres
199+
POSTGRES_PASSWORD: postgres
200+
POSTGRES_DB: spin_dev
201+
ports:
202+
- 5432:5432
203+
options: >-
204+
--health-cmd pg_isready
205+
--health-interval 10s
206+
--health-timeout 5s
207+
--health-retries 5
208+
mqtt:
209+
image: eclipse-mosquitto:2
210+
env:
211+
MQTT_USERNAME: username
212+
MQTT_PASSWORD: password
213+
ports:
214+
- 1883:1883
215+
options: >-
216+
--health-cmd "timeout -t 5 mosquitto_sub -t test/topic -v -E"
217+
--health-interval 10s
218+
--health-timeout 5s
219+
--health-retries 5
194220
steps:
195221
- uses: actions/checkout@v3
196222

tests/runtime-tests/tests/outbound-postgres-variable-permission/spin.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ component = "test"
1414

1515
[component.test]
1616
source = "%{source=outbound-postgres}"
17-
allowed_outbound_hosts = ["postgres://{{ pg_host }}:%{port=5432}"]
18-
environment = { DB_URL = "postgres://postgres:postgres@localhost:%{port=5432}/spin_dev" }
17+
allowed_outbound_hosts = ["postgres://{{ pg_host }}:5432"]
18+
environment = { DB_URL = "postgres://postgres:postgres@localhost:5432/spin_dev" }

tests/runtime-tests/tests/outbound-postgres/spin.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ component = "test"
1111

1212
[component.test]
1313
source = "%{source=outbound-postgres}"
14-
allowed_outbound_hosts = ["postgres://localhost:%{port=5432}"]
15-
environment = { DB_URL = "postgres://postgres:postgres@localhost:%{port=5432}/spin_dev" }
14+
allowed_outbound_hosts = ["postgres://localhost:5432"]
15+
environment = { DB_URL = "postgres://postgres:postgres@localhost:5432/spin_dev" }

tests/runtime.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ mod runtime_tests {
77
// The macro inspects the tests directory and
88
// generates individual tests for each one.
99
test_codegen_macro::codegen_runtime_tests!(
10-
ignore: [
11-
// This test is flaky. Often gets "Connection reset by peer" errors.
12-
// https://github.com/spinframework/spin/issues/2265
13-
"outbound-postgres",
14-
"outbound-postgres-variable-permission"
15-
]
10+
ignore: []
1611
);
1712

1813
fn run(test_path: PathBuf) {
@@ -28,7 +23,7 @@ mod runtime_tests {
2823

2924
#[test]
3025
fn conformance_tests() -> anyhow::Result<()> {
31-
let config = conformance_tests::Config::new("canary").ignore("outbound-mqtt");
26+
let config = conformance_tests::Config::new("canary");
3227
let conclusion = conformance_tests::run_tests(config, move |test| {
3328
conformance::run_test(test, &spin_binary())
3429
})?;

tests/test-components/components/outbound-postgres/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ impl Component {
3232
ensure_matches!(rowset.rows[0][2], postgres::DbValue::Time((h, m, s, ns)) if h == 4 && m == 5 && s == 6 && ns == 789_000_000);
3333
ensure_matches!(rowset.rows[0][3], postgres::DbValue::Datetime((y, _, _, h, _, _, ns)) if y == 1989 && h == 1 && ns == 0);
3434
ensure_matches!(rowset.rows[1][1], postgres::DbValue::Date((y, m, d)) if y == 2525 && m == 12 && d == 25);
35-
ensure_matches!(rowset.rows[1][2], postgres::DbValue::Time((h, m, s, ns)) if h == 14 && m == 15 && s == 16 && ns == 17);
36-
ensure_matches!(rowset.rows[1][3], postgres::DbValue::Datetime((y, _, _, h, _, _, ns)) if y == 1989 && h == 1 && ns == 4);
35+
ensure_matches!(rowset.rows[1][2], postgres::DbValue::Time((h, m, s, ns)) if h == 14 && m == 15 && s == 16 && ns == 0);
36+
ensure_matches!(rowset.rows[1][3], postgres::DbValue::Datetime((y, _, _, h, _, _, ns)) if y == 1989 && h == 1 && ns == 1000);
3737

3838
let rowset = ensure_ok!(nullable(&conn));
3939
ensure!(rowset.rows.iter().all(|r| r.len() == 1));

0 commit comments

Comments
 (0)