trustification / trustify

Apache License 2.0
8 stars 15 forks source link

Failing tests when updating pg-emb to 0.13 #501

Closed helio-frota closed 3 days ago

helio-frota commented 5 days ago

When running the tests we can see something like:

Setting up the test database: ArchiveError(IoError(HTTP status client error (403 Forbidden) 
for url (https://api.github.com/repos/theseus-rs/postgresql-binaries/releases?page=3&per_page=100)))
jcrossley3 commented 4 days ago

Pretty sure you're being rate-limited by github. This happens to me whenever I run cargo test more than a few times, even on older versions of pg-emb. There ought to be some way to prevent it from querying github for the releases, I think.

helio-frota commented 4 days ago

that's weird, today this is the first time I run the command (after read your comment)

this is the full output

running 17 tests
test sbom::graph::tests::ingest_sboms ... ok
test sbom::graph::tests::transitive_dependency_of ... ok
test sbom::test::perf::ingest_spdx_large ... ignored
test sbom::graph::tests::sbom_vulnerabilities ... FAILED
test sbom::graph::tests::ingest_and_locate_sboms_describing_cpes ... FAILED
test sbom::reingest::syft_rerun ... FAILED
test sbom::test::spdx::test_parse_spdx ... FAILED
test sbom::reingest::nhc ... FAILED
test sbom::test::spdx::parse_spdx_quarkus ... FAILED
test sbom::reingest::nhc_same ... FAILED
test sbom::graph::tests::ingest_and_fetch_sboms_describing_purls ... FAILED
test sbom::test::perf::ingest_spdx_medium ... FAILED
test sbom::test::cyclonedx::test_parse_cyclonedx ... FAILED
test sbom::reingest::nhc_same_content ... ok
test sbom::graph::tests::ingest_package_relates_to_package_dependency_of ... ok
test csaf::perf::ingest ... ok
test sbom::reingest::quarkus ... ok

failures:

---- sbom::graph::tests::sbom_vulnerabilities stdout ----
thread 'sbom::graph::tests::sbom_vulnerabilities' panicked at /home/heliofrota/Desktop/tc/trustify/common/src/db/test.rs:56:18:
Setting up the test database: ArchiveError(IoError(HTTP status client error (403 Forbidden) for url (https://api.github.com/repos/theseus-rs/postgresql-binaries/releases?page=4&per_page=100)))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- sbom::graph::tests::ingest_and_locate_sboms_describing_cpes stdout ----
thread 'sbom::graph::tests::ingest_and_locate_sboms_describing_cpes' panicked at /home/heliofrota/Desktop/tc/trustify/common/src/db/test.rs:56:18:
Setting up the test database: ArchiveError(IoError(HTTP status client error (403 Forbidden) for url (https://api.github.com/repos/theseus-rs/postgresql-binaries/releases?page=3&per_page=100)))

---- sbom::reingest::syft_rerun stdout ----
thread 'sbom::reingest::syft_rerun' panicked at /home/heliofrota/Desktop/tc/trustify/common/src/db/test.rs:56:18:
Setting up the test database: ArchiveError(IoError(HTTP status client error (403 Forbidden) for url (https://api.github.com/repos/theseus-rs/postgresql-binaries/releases?page=4&per_page=100)))

---- sbom::test::spdx::test_parse_spdx stdout ----
thread 'sbom::test::spdx::test_parse_spdx' panicked at /home/heliofrota/Desktop/tc/trustify/common/src/db/test.rs:56:18:
Setting up the test database: ArchiveError(IoError(HTTP status client error (403 Forbidden) for url (https://api.github.com/repos/theseus-rs/postgresql-binaries/releases?page=1&per_page=100)))

---- sbom::reingest::nhc stdout ----
thread 'sbom::reingest::nhc' panicked at /home/heliofrota/Desktop/tc/trustify/common/src/db/test.rs:56:18:
Setting up the test database: ArchiveError(IoError(HTTP status client error (403 Forbidden) for url (https://api.github.com/repos/theseus-rs/postgresql-binaries/releases?page=3&per_page=100)))

---- sbom::test::spdx::parse_spdx_quarkus stdout ----
thread 'sbom::test::spdx::parse_spdx_quarkus' panicked at /home/heliofrota/Desktop/tc/trustify/common/src/db/test.rs:56:18:
Setting up the test database: ArchiveError(IoError(HTTP status client error (403 Forbidden) for url (https://api.github.com/repos/theseus-rs/postgresql-binaries/releases?page=1&per_page=100)))

---- sbom::reingest::nhc_same stdout ----
thread 'sbom::reingest::nhc_same' panicked at /home/heliofrota/Desktop/tc/trustify/common/src/db/test.rs:56:18:
Setting up the test database: ArchiveError(IoError(HTTP status client error (403 Forbidden) for url (https://api.github.com/repos/theseus-rs/postgresql-binaries/releases?page=4&per_page=100)))

---- sbom::graph::tests::ingest_and_fetch_sboms_describing_purls stdout ----
thread 'sbom::graph::tests::ingest_and_fetch_sboms_describing_purls' panicked at /home/heliofrota/Desktop/tc/trustify/common/src/db/test.rs:56:18:
Setting up the test database: ArchiveError(IoError(HTTP status client error (403 Forbidden) for url (https://api.github.com/repos/theseus-rs/postgresql-binaries/releases?page=3&per_page=100)))

---- sbom::test::perf::ingest_spdx_medium stdout ----
thread 'sbom::test::perf::ingest_spdx_medium' panicked at /home/heliofrota/Desktop/tc/trustify/common/src/db/test.rs:56:18:
Setting up the test database: ArchiveError(IoError(HTTP status client error (403 Forbidden) for url (https://api.github.com/repos/theseus-rs/postgresql-binaries/releases?page=2&per_page=100)))

---- sbom::test::cyclonedx::test_parse_cyclonedx stdout ----
thread 'sbom::test::cyclonedx::test_parse_cyclonedx' panicked at /home/heliofrota/Desktop/tc/trustify/common/src/db/test.rs:56:18:
Setting up the test database: ArchiveError(IoError(HTTP status client error (403 Forbidden) for url (https://api.github.com/repos/theseus-rs/postgresql-binaries/releases?page=2&per_page=100)))

failures:
    sbom::graph::tests::ingest_and_fetch_sboms_describing_purls
    sbom::graph::tests::ingest_and_locate_sboms_describing_cpes
    sbom::graph::tests::sbom_vulnerabilities
    sbom::reingest::nhc
    sbom::reingest::nhc_same
    sbom::reingest::syft_rerun
    sbom::test::cyclonedx::test_parse_cyclonedx
    sbom::test::perf::ingest_spdx_medium
    sbom::test::spdx::parse_spdx_quarkus
    sbom::test::spdx::test_parse_spdx

test result: FAILED. 6 passed; 10 failed; 1 ignored; 0 measured; 0 filtered out; finished in 21.60s

error: test failed, to rerun pass `-p trustify-integration-tests --lib`
helio-frota commented 4 days ago

using that xz PR #496

and

diff --git a/Cargo.toml b/Cargo.toml
index 4dc52ec..a733c49 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -76,8 +76,8 @@ osv = { version = "0.2.0", default-features = false }
 packageurl = "0.3.0"
 parking_lot = "0.12"
 pem = "3"
-postgresql_archive = "0.10.1"
-postgresql_embedded = "0.10.1"
+postgresql_archive = "0.13.0"
+postgresql_embedded = "0.13.0"
 prometheus = "0.13.3"
 rand = "0.8.5"                                                        # for testing
 regex = "1.10.3"
diff --git a/common/src/db/test.rs b/common/src/db/test.rs
index feda76e..f7dbe71 100644
--- a/common/src/db/test.rs
+++ b/common/src/db/test.rs
@@ -1,6 +1,6 @@
 use std::env;

-use postgresql_archive::Version;
+use postgresql_archive::{Version, VersionReq};
 use postgresql_embedded::{PostgreSQL, Settings};
 use std::str::FromStr;
 use tempfile::TempDir;
@@ -43,12 +43,13 @@ impl AsyncTestContext for TrustifyContext {
             password: "trustify".to_string(),
             temporary: true,
             installation_dir,
+            version: VersionReq::parse("16.3.0").expect("valid psql version"),
             ..Default::default()
         };

         let postgresql = async {
-            let version = Version::from_str("16.3.0").expect("valid psql version");
-            let mut postgresql = PostgreSQL::new(version, settings);
+            //let version = Version::from_str("16.3.0").expect("valid psql version");
+            let mut postgresql = PostgreSQL::new(settings);
             postgresql
                 .setup()
                 .await
diff --git a/trustd/src/db.rs b/trustd/src/db.rs
index d439a71..5b490dc 100644
--- a/trustd/src/db.rs
+++ b/trustd/src/db.rs
@@ -1,4 +1,4 @@
-use postgresql_embedded::PostgreSQL;
+use postgresql_embedded::{PostgreSQL, VersionReq};
 use std::collections::HashMap;
 use std::env;
 use std::fs::create_dir_all;
@@ -80,9 +80,10 @@ impl Run {
             timeout: Some(Duration::from_secs(30)),
             configuration,
             data_dir,
+            version: VersionReq::parse("16.3.0").expect("foo"),
             ..Default::default()
         };
-        let mut postgresql = PostgreSQL::new(PostgreSQL::default_version(), settings);
+        let mut postgresql = PostgreSQL::new(settings);
         postgresql.setup().await?;
         postgresql.start().await?;
helio-frota commented 4 days ago

/me copied the test error from yesterday's chat during this issue creation

2024-07-03_13-07

helio-frota commented 4 days ago

pm-mode works :+1:

helio-frota commented 4 days ago

2024-07-03_15-48

jcrossley3 commented 4 days ago

https://github.com/theseus-rs/postgresql-embedded/issues/102