environment scripting for import-office-tables
This commit is contained in:
parent
033a86f10d
commit
ff2671ff92
20
.aliases
20
.aliases
@ -1,4 +1,8 @@
|
|||||||
|
# For using the alias import-office-tables, # copy these exports to .environment (ignored by git)
|
||||||
|
# and amend them according to your external DB:
|
||||||
|
export HSADMINNG_POSTGRES_JDBC_URL=
|
||||||
export HSADMINNG_POSTGRES_ADMIN_USERNAME=admin
|
export HSADMINNG_POSTGRES_ADMIN_USERNAME=admin
|
||||||
|
export HSADMINNG_POSTGRES_ADMIN_PASSWORD=
|
||||||
export HSADMINNG_POSTGRES_RESTRICTED_USERNAME=restricted
|
export HSADMINNG_POSTGRES_RESTRICTED_USERNAME=restricted
|
||||||
|
|
||||||
gradleWrapper () {
|
gradleWrapper () {
|
||||||
@ -39,9 +43,22 @@ postgresAutodoc () {
|
|||||||
dot -Tsvg build/postgres-autodoc.neato >build/postgres-autodoc-rbac.svg && \
|
dot -Tsvg build/postgres-autodoc.neato >build/postgres-autodoc-rbac.svg && \
|
||||||
echo "generated $PWD/build/postgres-autodoc-rbac.svg"
|
echo "generated $PWD/build/postgres-autodoc-rbac.svg"
|
||||||
}
|
}
|
||||||
|
|
||||||
alias postgres-autodoc=postgresAutodoc
|
alias postgres-autodoc=postgresAutodoc
|
||||||
|
|
||||||
|
function importOfficeTables() {
|
||||||
|
export HSADMINNG_POSTGRES_JDBC=jdbc:postgresql://localhost:5432/postgres
|
||||||
|
export HSADMINNG_POSTGRES_ADMIN_USERNAME=hsh99_admin
|
||||||
|
export HSADMINNG_POSTGRES_ADMIN_PASSWORD=password
|
||||||
|
export HSADMINNG_POSTGRES_RESTRICTED_USERNAME=hsh99_restricted
|
||||||
|
|
||||||
|
if [ -f .environment ]; then
|
||||||
|
source .environment
|
||||||
|
fi
|
||||||
|
|
||||||
|
./gradlew test --tests ImportOfficeTables -x pitest
|
||||||
|
}
|
||||||
|
alias import-office-tables=importOfficeTables
|
||||||
|
|
||||||
alias podman-start='systemctl --user enable --now podman.socket && systemctl --user status podman.socket && ls -la /run/user/$UID/podman/podman.sock'
|
alias podman-start='systemctl --user enable --now podman.socket && systemctl --user status podman.socket && ls -la /run/user/$UID/podman/podman.sock'
|
||||||
alias podman-stop='systemctl --user disable --now podman.socket && systemctl --user status podman.socket && ls -la /run/user/$UID/podman/podman.sock'
|
alias podman-stop='systemctl --user disable --now podman.socket && systemctl --user status podman.socket && ls -la /run/user/$UID/podman/podman.sock'
|
||||||
alias podman-use='export DOCKER_HOST="unix:///run/user/$UID/podman/podman.sock"; export TESTCONTAINERS_RYUK_DISABLED=true'
|
alias podman-use='export DOCKER_HOST="unix:///run/user/$UID/podman/podman.sock"; export TESTCONTAINERS_RYUK_DISABLED=true'
|
||||||
@ -56,3 +73,4 @@ alias pg-sql-backup='docker exec -i hsadmin-ng-postgres /usr/bin/pg_dump --clean
|
|||||||
alias pg-sql-restore='gunzip --stdout | docker exec -i hsadmin-ng-postgres psql -U postgres -d postgres'
|
alias pg-sql-restore='gunzip --stdout | docker exec -i hsadmin-ng-postgres psql -U postgres -d postgres'
|
||||||
|
|
||||||
alias fp='grep -r '@Accepts' src | sed -e 's/^.*@/@/g' | sort -u | wc -l'
|
alias fp='grep -r '@Accepts' src | sed -e 's/^.*@/@/g' | sort -u | wc -l'
|
||||||
|
|
||||||
|
@ -237,6 +237,12 @@ test {
|
|||||||
excludes = [
|
excludes = [
|
||||||
'net.hostsharing.hsadminng.**.generated.**',
|
'net.hostsharing.hsadminng.**.generated.**',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
test {
|
||||||
|
systemProperty "my_variable", System.getenv("MY_VARIABLE")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
jacocoTestReport {
|
jacocoTestReport {
|
||||||
dependsOn test
|
dependsOn test
|
||||||
|
@ -58,35 +58,42 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* When run on a Hostsharing database, it needs the following settings (hsh99_... just examples).
|
* When run on a Hostsharing database, it needs the following settings (hsh99_... just examples).
|
||||||
*
|
*
|
||||||
* In a real hostsharing environment, these are created via (the old) hsadmin:
|
* In a real Hostsharing environment, these are created via (the old) hsadmin:
|
||||||
*
|
|
||||||
* CREATE USER hsh99_admin WITH PASSWORD 'password';
|
|
||||||
* CREATE DATABASE hsh99_hsadminng ENCODING 'UTF8' TEMPLATE template0;
|
|
||||||
* REVOKE ALL ON DATABASE hsh99_hsadminng FROM public; -- why does hsadmin do that?
|
|
||||||
* ALTER DATABASE hsh99_hsadminng OWNER TO hsh99_admin;
|
|
||||||
*
|
|
||||||
* CREATE USER hsh99_restricted WITH PASSWORD 'password';
|
|
||||||
* GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public to hsh99_restricted;
|
|
||||||
|
|
||||||
* Additionally we need these settings (because the Hostsharing DB-Admin has no CREATE right):
|
CREATE USER hsh99_admin WITH PASSWORD 'password';
|
||||||
|
CREATE DATABASE hsh99_hsadminng ENCODING 'UTF8' TEMPLATE template0;
|
||||||
|
REVOKE ALL ON DATABASE hsh99_hsadminng FROM public; -- why does hsadmin do that?
|
||||||
|
ALTER DATABASE hsh99_hsadminng OWNER TO hsh99_admin;
|
||||||
|
|
||||||
|
CREATE USER hsh99_restricted WITH PASSWORD 'password';
|
||||||
|
|
||||||
|
\c hsh99_hsadminng
|
||||||
|
|
||||||
|
GRANT ALL PRIVILEGES ON SCHEMA public to hsh99_admin;
|
||||||
|
|
||||||
|
* Additionally, we need these settings (because the Hostsharing DB-Admin has no CREATE right):
|
||||||
|
|
||||||
|
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||||
|
|
||||||
|
-- maybe something like that is needed for the 2nd user
|
||||||
|
-- GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public to hsh99_restricted;
|
||||||
|
|
||||||
|
* Then copy this to a file named .environment (excluded from git):
|
||||||
|
|
||||||
|
export HSADMINNG_POSTGRES_JDBC_URL=jdbc:postgresql://localhost:6432/hsh99_hsadminng
|
||||||
|
export HSADMINNG_POSTGRES_ADMIN_USERNAME=hsh99_admin
|
||||||
|
export HSADMINNG_POSTGRES_ADMIN_PASSWORD=password
|
||||||
|
export HSADMINNG_POSTGRES_RESTRICTED_USERNAME=hsh99_restricted
|
||||||
|
|
||||||
|
* Then, import the office data, uncomment the @Diabled and then run:
|
||||||
*
|
*
|
||||||
* CREATE EXTENSION IF EXISTS "uuid-ossp";
|
* import-office-tables # comes from .aliases file
|
||||||
*
|
|
||||||
* Then these environment variables need to be set for Liquibase:
|
|
||||||
* export HSADMIN_POSTGRES_JDBC=jdbc:postgresql://localhost:6432/hsh99_hsadminng
|
|
||||||
* export HSADMIN_POSTGRES_ADMIN_USERNAME=hsh99_admin
|
|
||||||
* export HSADMIN_POSTGRES_ADMIN_PASSWORD=password
|
|
||||||
* export HSADMIN_POSTGRES_RESTRICTED_USERNAME=hsh99_restricted
|
|
||||||
*
|
|
||||||
* Then, to run the import, uncomment the @Diabled and then run:
|
|
||||||
*
|
|
||||||
* gw test -tests ImportOfficeTables -x check
|
|
||||||
*/
|
*/
|
||||||
//@Disabled
|
@Disabled
|
||||||
@DataJpaTest(properties = {
|
@DataJpaTest(properties = {
|
||||||
"spring.datasource.url=${HSADMIN_POSTGRES_JDBC:jdbc:tc:postgresql:15.5-bookworm:///spring_boot_testcontainers}",
|
"spring.datasource.url=${HSADMINNG_POSTGRES_JDBC_URL:jdbc:tc:postgresql:15.5-bookworm:///spring_boot_testcontainers}",
|
||||||
"spring.datasource.username=${HSADMIN_POSTGRES_ADMIN_USERNAME:admin}",
|
"spring.datasource.username=${HSADMINNG_POSTGRES_ADMIN_USERNAME:admin}",
|
||||||
"spring.datasource.password=${HSADMIN_POSTGRES_ADMIN_PASSWORD:password}"
|
"spring.datasource.password=${HSADMINNG_POSTGRES_ADMIN_PASSWORD:password}"
|
||||||
})
|
})
|
||||||
@Import({ Context.class, JpaAttempt.class })
|
@Import({ Context.class, JpaAttempt.class })
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||||
@ -120,6 +127,12 @@ public class ImportOfficeTables extends ContextBasedTest {
|
|||||||
@MockBean
|
@MockBean
|
||||||
HttpServletRequest request;
|
HttpServletRequest request;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(0)
|
||||||
|
void preconditions() {
|
||||||
|
assertThat(jdbcUrl).isEqualTo("jdbc:postgresql://localhost:5432/postgres");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1)
|
@Order(1)
|
||||||
void importBusinessPartners() {
|
void importBusinessPartners() {
|
||||||
|
Loading…
Reference in New Issue
Block a user