Skip to content

Commit db16723

Browse files
authored
Solve some build issues for EL8 and Postgis < 3.4 (#155)
* Add conditional skipping of azure-related tests on EL8 * Make postgis tests only run for > 3.3
1 parent 21a8e2f commit db16723

File tree

5 files changed

+52
-6
lines changed

5 files changed

+52
-6
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ ENVFILE ?= .devcontainer/.env
88
include $(ENVFILE)
99
export
1010

11+
IS_EL8 := $(shell grep -q 'PLATFORM_ID="platform:el8"' /etc/os-release 2>/dev/null && echo "true" || echo "false")
12+
1113
PG_CONFIG ?= pg_config
1214

1315
PG_MAJOR ?= $(shell $(PG_CONFIG) --version | cut -d '.' -f 1 | cut -d ' ' -f 2)
@@ -59,7 +61,9 @@ check-s3: build stop-minio start-minio
5961
cargo pgrx test pg$(PG_MAJOR) test_s3 --no-default-features
6062

6163
check-azure: build stop-azurite start-azurite
64+
ifeq ($(IS_EL8),false)
6265
cargo pgrx test pg$(PG_MAJOR) test_azure --no-default-features
66+
endif
6367

6468
check-gcs: build stop-fake-gcs start-fake-gcs
6569
cargo pgrx test pg$(PG_MAJOR) test_gcs --no-default-features
@@ -98,6 +102,7 @@ stop-minio: stop-mitmdump
98102
docker stop minio || true
99103

100104
start-azurite:
105+
ifeq ($(IS_EL8),false)
101106
docker run --rm -d \
102107
--name azurite \
103108
--env-file $(ENVFILE) \
@@ -111,9 +116,12 @@ start-azurite:
111116

112117
az storage container create -n ${AZURE_TEST_CONTAINER_NAME} --connection-string ${AZURE_STORAGE_CONNECTION_STRING}
113118
az storage container create -n ${AZURE_TEST_CONTAINER_NAME}2 --connection-string ${AZURE_STORAGE_CONNECTION_STRING}
119+
endif
114120

115121
stop-azurite:
122+
ifeq ($(IS_EL8),false)
116123
docker stop azurite || true
124+
endif
117125

118126
start-fake-gcs:
119127
# tusvold/fake-gcs-server is not available for ARM64, so we build it from source

build.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use std::process::Command;
2+
3+
fn main() {
4+
println!("cargo::rustc-check-cfg=cfg(rhel8)");
5+
let output = Command::new("cat")
6+
.arg("/etc/os-release")
7+
.output()
8+
.expect("Failed to execute command");
9+
10+
let os_info = String::from_utf8(output.stdout).unwrap();
11+
12+
if os_info.contains("platform:el8") {
13+
println!("cargo::rustc-cfg=rhel8");
14+
}
15+
}

src/pgrx_tests/common.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::type_compat::map::Map;
88
use arrow::array::RecordBatch;
99
use arrow_schema::SchemaRef;
1010
use parquet::arrow::ArrowWriter;
11+
use pgrx::spi;
1112
use pgrx::{
1213
datum::{Time, TimeWithTimeZone},
1314
FromDatum, IntoDatum, Spi,
@@ -345,8 +346,18 @@ pub(crate) fn timetz_array_to_utc_time_array(
345346
}
346347

347348
pub(crate) fn extension_exists(extension_name: &str) -> bool {
349+
let quoted_extension = spi::quote_literal(extension_name);
348350
let query =
349-
format!("select count(*) = 1 from pg_available_extensions where name = '{extension_name}'");
351+
format!("select count(*) = 1 from pg_available_extensions where name = {quoted_extension}");
352+
353+
Spi::get_one(&query).unwrap().unwrap()
354+
}
355+
356+
pub(crate) fn extension_version(extension_name: &str) -> String {
357+
let quoted_extension = spi::quote_literal(extension_name);
358+
let query = format!(
359+
"select default_version from pg_available_extensions where name = {quoted_extension}"
360+
);
350361

351362
Spi::get_one(&query).unwrap().unwrap()
352363
}

src/pgrx_tests/copy_type_roundtrip.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ mod tests {
44

55
use crate::pgrx_tests::common::{
66
assert_double, assert_float, assert_int_text_map, assert_json, assert_jsonb,
7-
extension_exists, timetz_array_to_utc_time_array, timetz_to_utc_time, TestResult,
8-
TestTable, LOCAL_TEST_FILE_PATH,
7+
extension_exists, extension_version, timetz_array_to_utc_time_array, timetz_to_utc_time,
8+
TestResult, TestTable, LOCAL_TEST_FILE_PATH,
99
};
1010
use crate::type_compat::fallback_to_text::FallbackToText;
1111
use crate::type_compat::geometry::{
@@ -1038,7 +1038,7 @@ mod tests {
10381038
#[pg_test]
10391039
fn test_geometry() {
10401040
// Skip the test if postgis extension is not available
1041-
if !extension_exists("postgis") {
1041+
if !extension_exists("postgis") || *extension_version("postgis") < *"3.4" {
10421042
return;
10431043
}
10441044

@@ -1056,7 +1056,7 @@ mod tests {
10561056
#[pg_test]
10571057
fn test_geometry_array() {
10581058
// Skip the test if postgis extension is not available
1059-
if !extension_exists("postgis") {
1059+
if !extension_exists("postgis") || *extension_version("postgis") < *"3.4" {
10601060
return;
10611061
}
10621062

@@ -1071,7 +1071,7 @@ mod tests {
10711071
#[pg_test]
10721072
fn test_geometry_geoparquet_metadata() {
10731073
// Skip the test if postgis extension is not available
1074-
if !extension_exists("postgis") {
1074+
if !extension_exists("postgis") || *extension_version("postgis") < *"3.4" {
10751075
return;
10761076
}
10771077

src/pgrx_tests/object_store.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ mod tests {
258258
}
259259

260260
#[pg_test]
261+
#[cfg(not(rhel8))]
261262
fn test_s3_temporary_token() {
262263
object_store_cache_clear();
263264

@@ -340,6 +341,7 @@ mod tests {
340341
}
341342

342343
#[pg_test]
344+
#[cfg(not(rhel8))]
343345
fn test_azure_blob_from_env() {
344346
object_store_cache_clear();
345347

@@ -367,6 +369,7 @@ mod tests {
367369
}
368370

369371
#[pg_test]
372+
#[cfg(not(rhel8))]
370373
fn test_azure_from_config_file() {
371374
object_store_cache_clear();
372375

@@ -413,6 +416,7 @@ mod tests {
413416
}
414417

415418
#[pg_test]
419+
#[cfg(not(rhel8))]
416420
fn test_azure_from_env_via_connection_string() {
417421
object_store_cache_clear();
418422

@@ -441,6 +445,7 @@ mod tests {
441445
}
442446

443447
#[pg_test]
448+
#[cfg(not(rhel8))]
444449
fn test_azure_from_config_via_connection_string() {
445450
object_store_cache_clear();
446451

@@ -484,6 +489,7 @@ mod tests {
484489

485490
#[pg_test]
486491
#[should_panic(expected = "Account must be specified")]
492+
#[cfg(not(rhel8))]
487493
fn test_azure_no_storage_account() {
488494
object_store_cache_clear();
489495

@@ -505,6 +511,7 @@ mod tests {
505511

506512
#[pg_test]
507513
#[should_panic(expected = "403 Forbidden")]
514+
#[cfg(not(rhel8))]
508515
fn test_azure_wrong_storage_key() {
509516
object_store_cache_clear();
510517

@@ -531,6 +538,7 @@ mod tests {
531538

532539
#[pg_test]
533540
#[should_panic(expected = "404 Not Found")]
541+
#[cfg(not(rhel8))]
534542
fn test_azure_write_wrong_container() {
535543
object_store_cache_clear();
536544

@@ -547,6 +555,7 @@ mod tests {
547555
}
548556

549557
#[pg_test]
558+
#[cfg(not(rhel8))]
550559
fn test_azure_read_write_sas() {
551560
object_store_cache_clear();
552561

@@ -575,6 +584,7 @@ mod tests {
575584

576585
#[pg_test]
577586
#[should_panic(expected = "403 Forbidden")]
587+
#[cfg(not(rhel8))]
578588
fn test_azure_read_only_sas() {
579589
object_store_cache_clear();
580590

@@ -603,6 +613,7 @@ mod tests {
603613

604614
#[pg_test]
605615
#[should_panic(expected = "could not open file")]
616+
#[cfg(not(rhel8))]
606617
fn test_azure_unsupported_uri() {
607618
object_store_cache_clear();
608619

@@ -707,6 +718,7 @@ mod tests {
707718
}
708719

709720
#[pg_test]
721+
#[cfg(not(rhel8))]
710722
fn test_object_store_cache() {
711723
object_store_cache_clear();
712724

0 commit comments

Comments
 (0)