Skip to content

Commit b0278f8

Browse files
fix(tests): Re-enable MQTT and Postgres tests
Signed-off-by: Karan <karanlokchandani@protonmail.com>
1 parent 92bb6c5 commit b0278f8

File tree

5 files changed

+42
-28
lines changed

5 files changed

+42
-28
lines changed

.github/workflows/build.yml

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ jobs:
2525
runs-on: "ubuntu-22.04"
2626
if: ${{ github.event_name == 'pull_request' }}
2727
steps:
28-
- name: 'Checkout Repository'
28+
- name: "Checkout Repository"
2929
uses: actions/checkout@v4
30-
- name: 'Dependency Review'
30+
- name: "Dependency Review"
3131
uses: actions/dependency-review-action@v4
3232

3333
lint-rust:
@@ -83,14 +83,8 @@ jobs:
8383
strategy:
8484
matrix:
8585
config:
86-
- {
87-
arch: "aarch64",
88-
target: "aarch64-unknown-linux-musl"
89-
}
90-
- {
91-
arch: "amd64",
92-
target: "x86_64-unknown-linux-musl"
93-
}
86+
- { arch: "aarch64", target: "aarch64-unknown-linux-musl" }
87+
- { arch: "amd64", target: "x86_64-unknown-linux-musl" }
9488
steps:
9589
- uses: actions/checkout@v3
9690

@@ -141,7 +135,6 @@ jobs:
141135
name: spin-${{ matrix.os }}
142136
path: target/release/spin${{ matrix.os == 'windows-latest' && '.exe' || '' }}
143137

144-
145138
test-spin:
146139
name: Test Spin
147140
runs-on: ${{ matrix.runner }}
@@ -191,6 +184,32 @@ jobs:
191184
# run on a larger runner for more SSD/resource access
192185
runs-on: ubuntu-22.04-4core-spin
193186
if: ${{ github.repository_owner == 'spinframework' }}
187+
services:
188+
postgres:
189+
image: postgres:15
190+
env:
191+
POSTGRES_USER: postgres
192+
POSTGRES_PASSWORD: postgres
193+
POSTGRES_DB: spin_dev
194+
ports:
195+
- 5432:5432
196+
options: >-
197+
--health-cmd pg_isready
198+
--health-interval 10s
199+
--health-timeout 5s
200+
--health-retries 5
201+
mqtt:
202+
image: eclipse-mosquitto:2
203+
env:
204+
MQTT_USERNAME: username
205+
MQTT_PASSWORD: password
206+
ports:
207+
- 1883:1883
208+
options: >-
209+
--health-cmd "timeout -t 5 mosquitto_sub -t test/topic -v -E"
210+
--health-interval 10s
211+
--health-timeout 5s
212+
--health-retries 5
194213
steps:
195214
- uses: actions/checkout@v3
196215

@@ -200,14 +219,14 @@ jobs:
200219
- uses: goto-bus-stop/setup-zig@v2
201220
- uses: actions/setup-go@v4
202221
with:
203-
go-version: '1.23'
204-
cache-dependency-path: "**/go.sum" # To suppress warning: https://github.com/actions/setup-go/issues/427
222+
go-version: "1.23"
223+
cache-dependency-path: "**/go.sum" # To suppress warning: https://github.com/actions/setup-go/issues/427
205224
- uses: acifani/setup-tinygo@v2
206225
with:
207-
tinygo-version: '0.37.0'
226+
tinygo-version: "0.37.0"
208227
- uses: actions/setup-node@v3
209228
with:
210-
node-version: '22.x'
229+
node-version: "22.x"
211230
- name: Install Grain
212231
run: |
213232
wget https://github.com/grain-lang/grain/releases/download/grain-v0.6.6/grain-linux-x64

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)