import-hosting-domain-assets #84

Merged
hsh-michaelhoennig merged 12 commits from import-hosting-domain-assets into master 2024-08-08 10:40:35 +02:00
2 changed files with 89 additions and 1 deletions
Showing only changes of commit 91cb3c7c35 - Show all commits

View File

@ -40,6 +40,11 @@ import static java.util.Optional.ofNullable;
import static java.util.stream.Collectors.toMap;
import static java.util.stream.Collectors.toSet;
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.CLOUD_SERVER;
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.DOMAIN_DNS_SETUP;
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.DOMAIN_HTTP_SETUP;
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.DOMAIN_MBOX_SETUP;
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.DOMAIN_SETUP;
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.DOMAIN_SMTP_SETUP;
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.EMAIL_ALIAS;
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.IPV4_NUMBER;
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_SERVER;
@ -112,6 +117,12 @@ public class ImportHostingAssets extends ImportOfficeData {
static final Integer DBINSTANCE_ID_OFFSET = 6000000;
static final Integer DBUSER_ID_OFFSET = 7000000;
static final Integer DB_ID_OFFSET = 8000000;
static final Integer DOMAIN_OFFSET = 10000000;
static final Integer DOMAIN_SETUP_OFFSET = 10000000;
static final Integer DOMAIN_DNS_SETUP_OFFSET = 11000000;
static final Integer DOMAIN_HTTP_SETUP_OFFSET = 12000000;
static final Integer DOMAIN_MBOX_SETUP_OFFSET = 13000000;
static final Integer DOMAIN_SMTP_SETUP_OFFSET = 14000000;
record Hive(int hive_id, String hive_name, int inet_addr_id, AtomicReference<HsHostingAssetRealEntity> serverRef) {}
@ -438,6 +449,33 @@ public class ImportHostingAssets extends ImportOfficeData {
""");
}
@Test
@Order(16010)
void importDomains() {
try (Reader reader = resourceReader(MIGRATION_DATA_PATH + "/hosting/domain.csv")) {
final var lines = readAllLines(reader);
importDomains(justHeader(lines), withoutHeader(lines));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Test
@Order(16019)
void verifyDomains() {
assumeThatWeAreImportingControlledTestData();
assertThat(firstOfEachType(5, DOMAIN_SETUP, DOMAIN_DNS_SETUP, DOMAIN_HTTP_SETUP, DOMAIN_MBOX_SETUP, DOMAIN_SMTP_SETUP)).isEqualToIgnoringWhitespace("""
{
10004530=HsHostingAssetRealEntity(DOMAIN_SETUP, l-u-g.de, l-u-g.de),
10004531=HsHostingAssetRealEntity(DOMAIN_SETUP, l-u-g.org, l-u-g.org),
10004532=HsHostingAssetRealEntity(DOMAIN_SETUP, linuxfanboysngirls.de, linuxfanboysngirls.de),
10004534=HsHostingAssetRealEntity(DOMAIN_SETUP, lug-mars.de, lug-mars.de),
10004581=HsHostingAssetRealEntity(DOMAIN_SETUP, 1981.isonweb.de, 1981.isonweb.de)
}
""");
}
// --------------------------------------------------------------------------------------------
@Test
@ -576,6 +614,14 @@ public class ImportHostingAssets extends ImportOfficeData {
persistHostingAssetsOfType(PGSQL_DATABASE, MARIADB_DATABASE);
}
@Test
@Order(19300)
@Commit
void persistDomainSetups() {
System.out.println("PERSISTING domain setups to database '" + jdbcUrl + "' as user '" + postgresAdminUser + "'");
persistHostingAssetsOfType(DOMAIN_SETUP);
}
@Test
@Order(19900)
void verifyPersistedUnixUsersWithUserId() {
@ -612,7 +658,7 @@ public class ImportHostingAssets extends ImportOfficeData {
@Order(19920)
void verifyHostingAssetsAreActuallyPersisted() {
final var haCount = (Integer) em.createNativeQuery("SELECT count(*) FROM hs_hosting_asset", Integer.class).getSingleResult();
assertThat(haCount).isGreaterThan(isImportingControlledTestData() ? 30 : 10000);
assertThat(haCount).isGreaterThan(isImportingControlledTestData() ? 40 : 15000);
}
// ============================================================================================
@ -1040,6 +1086,37 @@ public class ImportHostingAssets extends ImportOfficeData {
});
}
private void importDomains(final String[] header, final List<String[]> records) {
final var columns = new Columns(header);
records.stream()
.map(this::trimAll)
.map(row -> new Record(columns, row))
.forEach(rec -> {
final var database_id = rec.getInteger("domain_id");
final var domain_name = rec.getString("domain_name");
// final var domain_since = rec.getString("domain_since");
// final var domain_dns_master = rec.getString("domain_dns_master");
final var owner = rec.getString("domain_owner");
final var valid_subdomain_names = rec.getString("valid_subdomain_names");
final var passenger_python = rec.getString("passenger_python");
final var passenger_nodejs = rec.getString("passenger_nodejs");
final var passenger_ruby = rec.getString("passenger_ruby");
final var fcgi_php_bin = rec.getString("fcgi_php_bin");
final var domainoptions = rec.getString("domainoptions");
final var dbAsset = HsHostingAssetRealEntity.builder()
.type(DOMAIN_SETUP)
// FIXME .parentAsset(parentDomainSetupAsset)
.identifier(domain_name)
.caption(domain_name)
.config(ofEntries(
// nothing here
))
.build();
hostingAssets.put(DOMAIN_OFFSET + database_id, dbAsset);
});
}
// ============================================================================================
<V> V returning(

View File

@ -0,0 +1,11 @@
domain_id;domain_name;domain_since;domain_dns_master;domain_owner;valid_subdomain_names;passenger_python;passenger_nodejs;passenger_ruby;fcgi_php_bin;domainoptions
4530;l-u-g.de;2013-09-10;dns.hostsharing.net;5803;*;/usr/bin/python3;/usr/bin/node;/usr/bin/ruby;/usr/lib/cgi-bin/php;greylisting,multiviews,indexes,htdocsfallback,includes,cgi,fastcgi,passenger
4531;l-u-g.org;2013-09-10;dns.hostsharing.net;5803;*;/usr/bin/python3;/usr/bin/node;/usr/bin/ruby;/usr/lib/cgi-bin/php;greylisting,multiviews,indexes,htdocsfallback,includes,cgi,fastcgi,passenger
4532;linuxfanboysngirls.de;2013-09-10;dns.hostsharing.net;5809;*;/usr/bin/python3;/usr/bin/node;/usr/bin/ruby;/usr/lib/cgi-bin/php;greylisting,multiviews,indexes,htdocsfallback,includes,cgi,fastcgi,passenger
4534;lug-mars.de;2013-09-10;dns.hostsharing.net;5809;www;/usr/bin/python3;/usr/bin/node;/usr/bin/ruby;/usr/lib/cgi-bin/php;greylisting,letsencrypt,multiviews,indexes,htdocsfallback,includes,cgi,fastcgi,passenger
4581;1981.isonweb.de;2013-09-17;dns.hostsharing.net;5964;*;/usr/bin/python3;/usr/bin/node;/usr/bin/ruby;/usr/lib/cgi-bin/php;greylisting,multiviews,indexes,htdocsfallback,includes,cgi,fastcgi,passenger
4587;mellis.de;2013-09-17;dns.hostsharing.net;5964;www,michael,test,photos,static,input;/usr/bin/python3;/usr/bin/node;/usr/bin/ruby;/usr/lib/cgi-bin/php;htdocsfallback,indexes,includes,letsencrypt,multiviews,cgi,fastcgi,passenger
4589;isonweb.de;2013-09-17;dns.hostsharing.net;5964;*;/usr/bin/python3;/usr/bin/node;/usr/bin/ruby;/usr/lib/cgi-bin/php;htdocsfallback,indexes,includes,letsencrypt,multiviews,cgi,fastcgi,passenger
4600;waera.de;2013-09-17;dns.hostsharing.net;5964;*;/usr/bin/python3;/usr/bin/node;/usr/bin/ruby;/usr/lib/cgi-bin/php;greylisting,multiviews,indexes,htdocsfallback,includes,cgi,fastcgi,passenger
4604;xn--wra-qla.de;2013-09-17;dns.hostsharing.net;5964;*;/usr/bin/python3;/usr/bin/node;/usr/bin/ruby;/usr/lib/cgi-bin/php;greylisting,multiviews,indexes,htdocsfallback,includes,cgi,fastcgi,passenger
27662;dph-netzwerk.de;2021-06-02;h93.hostsharing.net;169596;*;/usr/bin/python3;/usr/bin/node;/usr/bin/ruby;/usr/lib/cgi-bin/php;htdocsfallback,indexes,autoconfig,greylisting,includes,letsencrypt,multiviews,cgi,fastcgi,passenger
1 domain_id domain_name domain_since domain_dns_master domain_owner valid_subdomain_names passenger_python passenger_nodejs passenger_ruby fcgi_php_bin domainoptions
2 4530 l-u-g.de 2013-09-10 dns.hostsharing.net 5803 * /usr/bin/python3 /usr/bin/node /usr/bin/ruby /usr/lib/cgi-bin/php greylisting,multiviews,indexes,htdocsfallback,includes,cgi,fastcgi,passenger
3 4531 l-u-g.org 2013-09-10 dns.hostsharing.net 5803 * /usr/bin/python3 /usr/bin/node /usr/bin/ruby /usr/lib/cgi-bin/php greylisting,multiviews,indexes,htdocsfallback,includes,cgi,fastcgi,passenger
4 4532 linuxfanboysngirls.de 2013-09-10 dns.hostsharing.net 5809 * /usr/bin/python3 /usr/bin/node /usr/bin/ruby /usr/lib/cgi-bin/php greylisting,multiviews,indexes,htdocsfallback,includes,cgi,fastcgi,passenger
5 4534 lug-mars.de 2013-09-10 dns.hostsharing.net 5809 www /usr/bin/python3 /usr/bin/node /usr/bin/ruby /usr/lib/cgi-bin/php greylisting,letsencrypt,multiviews,indexes,htdocsfallback,includes,cgi,fastcgi,passenger
6 4581 1981.isonweb.de 2013-09-17 dns.hostsharing.net 5964 * /usr/bin/python3 /usr/bin/node /usr/bin/ruby /usr/lib/cgi-bin/php greylisting,multiviews,indexes,htdocsfallback,includes,cgi,fastcgi,passenger
7 4587 mellis.de 2013-09-17 dns.hostsharing.net 5964 www,michael,test,photos,static,input /usr/bin/python3 /usr/bin/node /usr/bin/ruby /usr/lib/cgi-bin/php htdocsfallback,indexes,includes,letsencrypt,multiviews,cgi,fastcgi,passenger
8 4589 isonweb.de 2013-09-17 dns.hostsharing.net 5964 * /usr/bin/python3 /usr/bin/node /usr/bin/ruby /usr/lib/cgi-bin/php htdocsfallback,indexes,includes,letsencrypt,multiviews,cgi,fastcgi,passenger
9 4600 waera.de 2013-09-17 dns.hostsharing.net 5964 * /usr/bin/python3 /usr/bin/node /usr/bin/ruby /usr/lib/cgi-bin/php greylisting,multiviews,indexes,htdocsfallback,includes,cgi,fastcgi,passenger
10 4604 xn--wra-qla.de 2013-09-17 dns.hostsharing.net 5964 * /usr/bin/python3 /usr/bin/node /usr/bin/ruby /usr/lib/cgi-bin/php greylisting,multiviews,indexes,htdocsfallback,includes,cgi,fastcgi,passenger
11 27662 dph-netzwerk.de 2021-06-02 h93.hostsharing.net 169596 * /usr/bin/python3 /usr/bin/node /usr/bin/ruby /usr/lib/cgi-bin/php htdocsfallback,indexes,autoconfig,greylisting,includes,letsencrypt,multiviews,cgi,fastcgi,passenger