Skip to content

fix(tests): Re-enable MQTT and Postgres tests #3163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,20 @@ jobs:
# run on a larger runner for more SSD/resource access
runs-on: ubuntu-22.04-4core-spin
if: ${{ github.repository_owner == 'spinframework' }}
services:
postgres:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I thought we were dockerising the Postgres instance, but maybe that's been part of the problem. Again, I'd like to get Ryan's input on making it part of the CI image instead (I'm not for or against it, I just want to hear from someone who knows this bit of the system better than I do!).

image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: spin_dev
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ component = "test"

[component.test]
source = "%{source=outbound-postgres}"
allowed_outbound_hosts = ["postgres://{{ pg_host }}:%{port=5432}"]
environment = { DB_URL = "postgres://postgres:postgres@localhost:%{port=5432}/spin_dev" }
allowed_outbound_hosts = ["postgres://{{ pg_host }}:5432"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the changes away from placeholder ports needed? I believe we did this so that test instances could be brought up on ports determined at runtime, and it would be good to keep it. If it's not working, it would be good to understand why. (But if that's involved in the flakiness, we can probably punt on it for now.) cc @rylev for thoughts and insight

environment = { DB_URL = "postgres://postgres:postgres@localhost:5432/spin_dev" }
4 changes: 2 additions & 2 deletions tests/runtime-tests/tests/outbound-postgres/spin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ component = "test"

[component.test]
source = "%{source=outbound-postgres}"
allowed_outbound_hosts = ["postgres://localhost:%{port=5432}"]
environment = { DB_URL = "postgres://postgres:postgres@localhost:%{port=5432}/spin_dev" }
allowed_outbound_hosts = ["postgres://localhost:5432"]
environment = { DB_URL = "postgres://postgres:postgres@localhost:5432/spin_dev" }
9 changes: 2 additions & 7 deletions tests/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ mod runtime_tests {
// The macro inspects the tests directory and
// generates individual tests for each one.
test_codegen_macro::codegen_runtime_tests!(
ignore: [
// This test is flaky. Often gets "Connection reset by peer" errors.
// https://github.com/spinframework/spin/issues/2265
"outbound-postgres",
"outbound-postgres-variable-permission"
]
ignore: []
);

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

#[test]
fn conformance_tests() -> anyhow::Result<()> {
let config = conformance_tests::Config::new("canary").ignore("outbound-mqtt");
let config = conformance_tests::Config::new("canary");
let conclusion = conformance_tests::run_tests(config, move |test| {
conformance::run_test(test, &spin_binary())
})?;
Expand Down
4 changes: 2 additions & 2 deletions tests/test-components/components/outbound-postgres/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ impl Component {
ensure_matches!(rowset.rows[0][2], postgres::DbValue::Time((h, m, s, ns)) if h == 4 && m == 5 && s == 6 && ns == 789_000_000);
ensure_matches!(rowset.rows[0][3], postgres::DbValue::Datetime((y, _, _, h, _, _, ns)) if y == 1989 && h == 1 && ns == 0);
ensure_matches!(rowset.rows[1][1], postgres::DbValue::Date((y, m, d)) if y == 2525 && m == 12 && d == 25);
ensure_matches!(rowset.rows[1][2], postgres::DbValue::Time((h, m, s, ns)) if h == 14 && m == 15 && s == 16 && ns == 17);
ensure_matches!(rowset.rows[1][3], postgres::DbValue::Datetime((y, _, _, h, _, _, ns)) if y == 1989 && h == 1 && ns == 4);
ensure_matches!(rowset.rows[1][2], postgres::DbValue::Time((h, m, s, ns)) if h == 14 && m == 15 && s == 16 && ns == 0);
ensure_matches!(rowset.rows[1][3], postgres::DbValue::Datetime((y, _, _, h, _, _, ns)) if y == 1989 && h == 1 && ns == 1000);

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