Skip to content
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ ENVFILE ?= .devcontainer/.env
include $(ENVFILE)
export

IS_EL8 := $(shell grep -q 'PLATFORM_ID="platform:el8"' /etc/os-release 2>/dev/null && echo "true" || echo "false")

PG_CONFIG ?= pg_config

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

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

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

start-azurite:
ifeq ($(IS_EL8),false)
docker run --rm -d \
--name azurite \
--env-file $(ENVFILE) \
Expand All @@ -111,9 +116,12 @@ start-azurite:

az storage container create -n ${AZURE_TEST_CONTAINER_NAME} --connection-string ${AZURE_STORAGE_CONNECTION_STRING}
az storage container create -n ${AZURE_TEST_CONTAINER_NAME}2 --connection-string ${AZURE_STORAGE_CONNECTION_STRING}
endif

stop-azurite:
ifeq ($(IS_EL8),false)
docker stop azurite || true
endif

start-fake-gcs:
# tusvold/fake-gcs-server is not available for ARM64, so we build it from source
Expand Down
15 changes: 15 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use std::process::Command;

fn main() {
println!("cargo::rustc-check-cfg=cfg(rhel8)");
let output = Command::new("cat")
.arg("/etc/os-release")
.output()
.expect("Failed to execute command");

let os_info = String::from_utf8(output.stdout).unwrap();

if os_info.contains("platform:el8") {
println!("cargo::rustc-cfg=rhel8");
}
}
13 changes: 12 additions & 1 deletion src/pgrx_tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::type_compat::map::Map;
use arrow::array::RecordBatch;
use arrow_schema::SchemaRef;
use parquet::arrow::ArrowWriter;
use pgrx::spi;
use pgrx::{
datum::{Time, TimeWithTimeZone},
FromDatum, IntoDatum, Spi,
Expand Down Expand Up @@ -345,8 +346,18 @@ pub(crate) fn timetz_array_to_utc_time_array(
}

pub(crate) fn extension_exists(extension_name: &str) -> bool {
let quoted_extension = spi::quote_literal(extension_name);
let query =
format!("select count(*) = 1 from pg_available_extensions where name = '{extension_name}'");
format!("select count(*) = 1 from pg_available_extensions where name = {quoted_extension}");

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

pub(crate) fn extension_version(extension_name: &str) -> String {
let quoted_extension = spi::quote_literal(extension_name);
let query = format!(
"select default_version from pg_available_extensions where name = {quoted_extension}"
);

Spi::get_one(&query).unwrap().unwrap()
}
Expand Down
10 changes: 5 additions & 5 deletions src/pgrx_tests/copy_type_roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ mod tests {

use crate::pgrx_tests::common::{
assert_double, assert_float, assert_int_text_map, assert_json, assert_jsonb,
extension_exists, timetz_array_to_utc_time_array, timetz_to_utc_time, TestResult,
TestTable, LOCAL_TEST_FILE_PATH,
extension_exists, extension_version, timetz_array_to_utc_time_array, timetz_to_utc_time,
TestResult, TestTable, LOCAL_TEST_FILE_PATH,
};
use crate::type_compat::fallback_to_text::FallbackToText;
use crate::type_compat::geometry::{
Expand Down Expand Up @@ -1038,7 +1038,7 @@ mod tests {
#[pg_test]
fn test_geometry() {
// Skip the test if postgis extension is not available
if !extension_exists("postgis") {
if !extension_exists("postgis") || *extension_version("postgis") < *"3.4" {
return;
}

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

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

Expand Down
12 changes: 12 additions & 0 deletions src/pgrx_tests/object_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ mod tests {
}

#[pg_test]
#[cfg(not(rhel8))]
fn test_s3_temporary_token() {
object_store_cache_clear();

Expand Down Expand Up @@ -340,6 +341,7 @@ mod tests {
}

#[pg_test]
#[cfg(not(rhel8))]
fn test_azure_blob_from_env() {
object_store_cache_clear();

Expand Down Expand Up @@ -367,6 +369,7 @@ mod tests {
}

#[pg_test]
#[cfg(not(rhel8))]
fn test_azure_from_config_file() {
object_store_cache_clear();

Expand Down Expand Up @@ -413,6 +416,7 @@ mod tests {
}

#[pg_test]
#[cfg(not(rhel8))]
fn test_azure_from_env_via_connection_string() {
object_store_cache_clear();

Expand Down Expand Up @@ -441,6 +445,7 @@ mod tests {
}

#[pg_test]
#[cfg(not(rhel8))]
fn test_azure_from_config_via_connection_string() {
object_store_cache_clear();

Expand Down Expand Up @@ -484,6 +489,7 @@ mod tests {

#[pg_test]
#[should_panic(expected = "Account must be specified")]
#[cfg(not(rhel8))]
fn test_azure_no_storage_account() {
object_store_cache_clear();

Expand All @@ -505,6 +511,7 @@ mod tests {

#[pg_test]
#[should_panic(expected = "403 Forbidden")]
#[cfg(not(rhel8))]
fn test_azure_wrong_storage_key() {
object_store_cache_clear();

Expand All @@ -531,6 +538,7 @@ mod tests {

#[pg_test]
#[should_panic(expected = "404 Not Found")]
#[cfg(not(rhel8))]
fn test_azure_write_wrong_container() {
object_store_cache_clear();

Expand All @@ -547,6 +555,7 @@ mod tests {
}

#[pg_test]
#[cfg(not(rhel8))]
fn test_azure_read_write_sas() {
object_store_cache_clear();

Expand Down Expand Up @@ -575,6 +584,7 @@ mod tests {

#[pg_test]
#[should_panic(expected = "403 Forbidden")]
#[cfg(not(rhel8))]
fn test_azure_read_only_sas() {
object_store_cache_clear();

Expand Down Expand Up @@ -603,6 +613,7 @@ mod tests {

#[pg_test]
#[should_panic(expected = "could not open file")]
#[cfg(not(rhel8))]
fn test_azure_unsupported_uri() {
object_store_cache_clear();

Expand Down Expand Up @@ -707,6 +718,7 @@ mod tests {
}

#[pg_test]
#[cfg(not(rhel8))]
fn test_object_store_cache() {
object_store_cache_clear();

Expand Down