Rename env variables (#10336)

This commit is contained in:
AdRiley 2024-06-28 11:38:22 +01:00 committed by GitHub
parent 3f6a3347b8
commit 132039a838
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 36 additions and 36 deletions

View File

@ -31,10 +31,10 @@ pub mod env {
}
pub mod tests {
ide_ci::define_env_var! {
ENSO_DATABASE_TEST_DB_NAME, String;
ENSO_DATABASE_TEST_HOST, String;
ENSO_DATABASE_TEST_DB_USER, String;
ENSO_DATABASE_TEST_DB_PASSWORD, String;
ENSO_POSTGRES_DATABASE, String;
ENSO_POSTGRES_HOST, String;
ENSO_POSTGRES_USER, String;
ENSO_POSTGRES_PASSWORD, String;
}
}
}
@ -85,22 +85,22 @@ impl Configuration {
}
pub fn set_enso_test_env(&self) -> Result {
env::tests::ENSO_DATABASE_TEST_DB_NAME.set(&self.database_name)?;
env::tests::ENSO_DATABASE_TEST_HOST.set(&match &self.endpoint {
env::tests::ENSO_POSTGRES_DATABASE.set(&self.database_name)?;
env::tests::ENSO_POSTGRES_HOST.set(&match &self.endpoint {
EndpointConfiguration::Host { port } => format!("localhost:{port}"),
EndpointConfiguration::Container { .. } =>
format!("localhost:{POSTGRES_CONTAINER_DEFAULT_PORT}"),
})?;
env::tests::ENSO_DATABASE_TEST_DB_USER.set(&self.user)?;
env::tests::ENSO_DATABASE_TEST_DB_PASSWORD.set(&self.password)?;
env::tests::ENSO_POSTGRES_USER.set(&self.user)?;
env::tests::ENSO_POSTGRES_PASSWORD.set(&self.password)?;
Ok(())
}
pub fn clear_enso_test_env(&self) {
env::tests::ENSO_DATABASE_TEST_DB_NAME.remove();
env::tests::ENSO_DATABASE_TEST_HOST.remove();
env::tests::ENSO_DATABASE_TEST_DB_USER.remove();
env::tests::ENSO_DATABASE_TEST_DB_PASSWORD.remove();
env::tests::ENSO_POSTGRES_DATABASE.remove();
env::tests::ENSO_POSTGRES_HOST.remove();
env::tests::ENSO_POSTGRES_USER.remove();
env::tests::ENSO_POSTGRES_PASSWORD.remove();
}
pub async fn cleanup(&self) -> Result {

View File

@ -39,7 +39,7 @@ DNS.2 = $pgipaddress
EOF
docker build --build-arg host_name=${pghostname} -t postgres-ssl .
docker run -d --name postgres-ssl -p 5432:5432 -e POSTGRES_PASSWORD=$ENSO_DATABASE_TEST_DB_PASSWORD postgres-ssl
docker run -d --name postgres-ssl -p 5432:5432 -e POSTGRES_PASSWORD=$ENSO_POSTGRES_PASSWORD postgres-ssl
docker cp postgres-ssl:/openssl/rootCA.crt ../../data/transient/rootCA.crt
rm csr.conf

View File

@ -657,13 +657,13 @@ supported_replace_params =
Set.from_vector <| e0 + e1 + e2 + e3 + e4
add_table_specs suite_builder =
db_name = Environment.get "ENSO_DATABASE_TEST_DB_NAME"
db_host_port = (Environment.get "ENSO_DATABASE_TEST_HOST").if_nothing "localhost" . split ':'
db_name = Environment.get "ENSO_POSTGRES_DATABASE"
db_host_port = (Environment.get "ENSO_POSTGRES_HOST").if_nothing "localhost" . split ':'
db_host = db_host_port.at 0
db_port = if db_host_port.length == 1 then 5432 else Integer.parse (db_host_port.at 1)
db_user = Environment.get "ENSO_DATABASE_TEST_DB_USER"
db_password = Environment.get "ENSO_DATABASE_TEST_DB_PASSWORD"
ca_cert_file = Environment.get "ENSO_DATABASE_TEST_CA_CERT_FILE"
db_user = Environment.get "ENSO_POSTGRES_USER"
db_password = Environment.get "ENSO_POSTGRES_PASSWORD"
ca_cert_file = Environment.get "ENSO_POSTGRES_CA_CERT_FILE"
ssl_pending = if ca_cert_file.is_nothing then "PostgreSQL SSL test not configured." else Nothing
@ -685,7 +685,7 @@ add_table_specs suite_builder =
group_builder.specify "should connect be able to verify the host name against the certificate" <|
Database.connect (Postgres db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=(SSL_Mode.Full_Verification ca_cert_file)) . should_succeed
alternate_host = Environment.get "ENSO_DATABASE_TEST_ALTERNATE_HOST" . if_nothing <|
alternate_host = Environment.get "ENSO_POSTGRES_ALTERNATE_HOST" . if_nothing <|
if db_host == "127.0.0.1" then "localhost" else Nothing
pending_alternate = if alternate_host.is_nothing then "Alternative host name not configured." else Nothing
group_builder.specify "should fail to connect with alternate host name not valid in certificate" pending=pending_alternate <|
@ -728,12 +728,12 @@ with_secret name value callback =
Panic.with_finalizer secret.delete (callback secret)
get_configured_connection_details =
db_name = Environment.get "ENSO_DATABASE_TEST_DB_NAME"
db_host_port = (Environment.get "ENSO_DATABASE_TEST_HOST").if_nothing "localhost" . split ':'
db_name = Environment.get "ENSO_POSTGRES_DATABASE"
db_host_port = (Environment.get "ENSO_POSTGRES_HOST").if_nothing "localhost" . split ':'
db_host = db_host_port.at 0
db_port = if db_host_port.length == 1 then 5432 else Integer.parse (db_host_port.at 1)
db_user = Environment.get "ENSO_DATABASE_TEST_DB_USER"
db_password = Environment.get "ENSO_DATABASE_TEST_DB_PASSWORD"
db_user = Environment.get "ENSO_POSTGRES_USER"
db_password = Environment.get "ENSO_POSTGRES_PASSWORD"
if db_name.is_nothing then Nothing else
Postgres db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password)

View File

@ -12,22 +12,22 @@ empty database.
Environment variables are used to pass the test configuration to the test
runner. To enable testing the PostgreSQL backend, a variable
`ENSO_DATABASE_TEST_DB_NAME` has to be defined and contain the name of the empty
`ENSO_POSTGRES_DATABASE` has to be defined and contain the name of the empty
database that should be used for testing.
Depending on the authentication configuration of the database, the username and
password may not need to be provided, but the set-up was only tested with
password-based authentication schemes so this approach is recommended. To
configure the credentials for testing, set `ENSO_DATABASE_TEST_DB_USER` and
`ENSO_DATABASE_TEST_DB_PASSWORD`. As keeping passwords in an environment
variable may not be the safest thing to do, it is much recommended using a
separate database account with low privileges for testing - the only privileges
that are necessary is the ability to create, modify, query and drop tables in
the `ENSO_DATABASE_TEST_DB_NAME` database.
configure the credentials for testing, set `ENSO_POSTGRES_USER` and
`ENSO_POSTGRES_PASSWORD`. As keeping passwords in an environment variable may
not be the safest thing to do, it is much recommended using a separate database
account with low privileges for testing - the only privileges that are necessary
is the ability to create, modify, query and drop tables in the
`ENSO_POSTGRES_DATABASE` database.
If the database server is remote, `ENSO_DATABASE_TEST_HOST` may be set to tell
the test suite where to connect. If that variable is not set, the test suite
will attempt to connect to a local server.
If the database server is remote, `ENSO_POSTGRES_HOST` may be set to tell the
test suite where to connect. If that variable is not set, the test suite will
attempt to connect to a local server.
### Setup via Docker
@ -42,13 +42,13 @@ docker run -it -e POSTGRES_PASSWORD=pwd -p 5432:5432 postgres
### Testing SSL connectivity
The SSL connection by providing a root certificate file. The path to this is
specified in `ENSO_DATABASE_TEST_CA_CERT_FILE`. If this is set then the
different SSL modes will be tested.
specified in `ENSO_POSTGRES_CA_CERT_FILE`. If this is set then the different SSL
modes will be tested.
If connecting to `127.0.0.1` then the test suite will attempt to connect to
`localhost` with in full verification mode to confirm that it fails. If there is
an alternative hostname for this test it can be supplied in
`ENSO_DATABASE_TEST_ALTERNATE_HOST`.
`ENSO_POSTGRES_ALTERNATE_HOST`.
### Testing Redshift connectivity