Skip to content

Commit

Permalink
Merge pull request #1267 from atlanhq/APP-4737
Browse files Browse the repository at this point in the history
Fixes parallel integration tests with domains and products
  • Loading branch information
cmgrote authored Jan 30, 2025
2 parents dbfcbd9 + 00f372a commit 7e5246e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright 2023 Atlan Pte. Ltd. */
package com.atlan.pkg

import co.elastic.clients.elasticsearch._types.SortOrder
import com.atlan.AtlanClient
import com.atlan.exception.ConflictException
import com.atlan.model.assets.Asset
Expand Down Expand Up @@ -479,20 +480,22 @@ abstract class PackageTest(
*
* @param domainName of the domain
*/
fun removeDomainAndProduct(domainName: String) {
val domains =
fun removeDomainAndChildren(domainName: String) {
val domain =
DataDomain
.select(client)
.where(DataDomain.NAME.eq(domainName))
.whereNot(DataDomain.PARENT_DOMAIN_QUALIFIED_NAME.hasAnyValue())
.stream()
.toList()
.firstOrNull()
try {
if (domains.isNotEmpty()) {
if (domain != null) {
// find all the products under the domain
val productGuids =
DataProduct
.select(client)
.where(DataProduct.PARENT_DOMAIN_QUALIFIED_NAME.eq(domains[0].qualifiedName))
.where(DataProduct.PARENT_DOMAIN_QUALIFIED_NAME.startsWith(domain.qualifiedName))
.stream()
.map { it.guid }
.toList()
Expand All @@ -501,23 +504,19 @@ abstract class PackageTest(
}

// find all subdomains under the domain
val subDomainNames =
val subdomains =
DataDomain
.select(client)
.where(DataDomain.PARENT_DOMAIN_QUALIFIED_NAME.eq(domains[0].qualifiedName))
.where(DataDomain.PARENT_DOMAIN_QUALIFIED_NAME.startsWith(domain.qualifiedName))
.sort(DataDomain.QUALIFIED_NAME.order(SortOrder.Desc))
.stream()
.map { it.name }
.map { it.guid }
.toList()
if (subDomainNames.isNotEmpty()) {
subDomainNames.forEach {
removeDomainAndProduct(it)
}
}

// delete the domain
domains.forEach { domain ->
client.assets.delete(domain.guid, AtlanDeleteType.HARD)
subdomains.forEach { subdomain ->
client.assets.delete(subdomain, AtlanDeleteType.HARD)
}
client.assets.delete(domain.guid, AtlanDeleteType.HARD)
}
} catch (e: Exception) {
logger.error(e) { "Unable to remove domain: $domainName" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import kotlin.test.assertEquals
class ImpactReportCSVTest : PackageTest("irc") {
override val logger = Utils.getLogger(this.javaClass.name)

private val dataDomain = makeUnique("g1")
private val dataDomain = makeUnique("cd1")
private val files =
listOf(
"debug.log",
Expand All @@ -47,7 +47,7 @@ class ImpactReportCSVTest : PackageTest("irc") {
}

override fun teardown() {
removeDomainAndProduct(dataDomain)
removeDomainAndChildren(dataDomain)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import kotlin.test.Test
class ImpactReportTest : PackageTest("ir") {
override val logger = Utils.getLogger(this.javaClass.name)

private val dataDomain = makeUnique("g1")
private val dataDomain = makeUnique("d1")
private val files =
listOf(
"debug.log",
Expand All @@ -37,7 +37,7 @@ class ImpactReportTest : PackageTest("ir") {
}

override fun teardown() {
removeDomainAndProduct(dataDomain)
removeDomainAndChildren(dataDomain)
}

@Test(groups = ["mdir.create"])
Expand Down

0 comments on commit 7e5246e

Please sign in to comment.