Skip to content

Commit

Permalink
Refactor the tests
Browse files Browse the repository at this point in the history
This commit primarily refactors the existing forced/soft update tests
 to reduce the generation of unnecessary reports during build time.

Signed-off-by: Saeed Rezaee <[email protected]>
  • Loading branch information
SaeedRe committed Mar 8, 2024
1 parent cc584f3 commit c33756b
Show file tree
Hide file tree
Showing 12 changed files with 417 additions and 559 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import kotlin.time.Duration.Companion.seconds

class DdiClientHttpRequestsTest : AbstractHaraMessageTest() {

override val targetId: String = "DoubleToken"
private var expectedServerResponses = mutableListOf<ExpectedMessage>()

override val expectedMessagesList: MutableList<MutableList<ExpectedMessage>> by lazy {
Expand All @@ -52,6 +51,7 @@ class DdiClientHttpRequestsTest : AbstractHaraMessageTest() {
}

companion object {
const val TARGET_ID = "DoubleToken"
const val TEST_TARGET_SECURITY_TOKEN = "r2m3ixxc86a2v4q81wntpyhr78zy08we"
}

Expand Down Expand Up @@ -95,7 +95,7 @@ class DdiClientHttpRequestsTest : AbstractHaraMessageTest() {
return clientFromTargetId(
okHttpClientBuilder = okHttpClient,
targetToken = targetToken,
gatewayToken = gatewayToken).invoke(targetId)
gatewayToken = gatewayToken).invoke(TARGET_ID)
}

@Suppress("UNUSED_VARIABLE")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ import org.eclipse.hara.ddiclient.integrationtest.utils.TestUtils
import org.eclipse.hara.ddiclient.integrationtest.utils.TestUtils.endMessagesOnSuccessUpdate
import org.eclipse.hara.ddiclient.integrationtest.utils.TestUtils.messagesOnSoftUpdateAuthorization
import org.eclipse.hara.ddiclient.integrationtest.utils.TestUtils.messagesOnSuccessfullyDownloadDistribution
import org.eclipse.hara.ddiclient.integrationtest.utils.TestUtils.targetRetrievedUpdateAction
import org.testng.annotations.BeforeClass
import org.testng.annotations.Test

class HawkbitDownloadOnlyDeploymentTest : AbstractDeploymentTest() {
class DeploymentDownloadOnlyTest : AbstractDeploymentTest() {

private var actionId: Int = 0
override val targetId: String = "DownloadOnlyTest"

companion object {
const val TARGET_ID: String = "DownloadOnlyTest"
const val DISTRIBUTION_ID = 3
}

Expand All @@ -40,12 +39,12 @@ class HawkbitDownloadOnlyDeploymentTest : AbstractDeploymentTest() {
@Test(enabled = true, timeOut = 60_000, priority = 14)
fun testDownloadOnlyWhileWaitingForUpdateAuthorization() = runBlocking {

reCreateTestTargetOnServer()
reCreateTestTargetOnServer(TARGET_ID)

assignDownloadOnlyDistribution()

val client = createHaraClientWithAuthorizationPermissions(
downloadAllowed = false, updateAllowed = true)
TARGET_ID, downloadAllowed = false, updateAllowed = true)

startTheTestAndWaitForResult(client,
createTargetTestDeployment(expectedActionsAfterDownloadOnlyDeployment))
Expand All @@ -54,7 +53,7 @@ class HawkbitDownloadOnlyDeploymentTest : AbstractDeploymentTest() {
private suspend fun assignDownloadOnlyDistribution() {
val distribution = HawkbitAssignDistributionBody(DISTRIBUTION_ID,
AssignDistributionType.DOWNLOAD_ONLY, 0)
actionId = assignDistributionToTheTarget(distribution)
actionId = assignDistributionToTheTarget(TARGET_ID, distribution)
}

private fun createTargetTestDeployment(
Expand All @@ -64,12 +63,11 @@ class HawkbitDownloadOnlyDeploymentTest : AbstractDeploymentTest() {
TestUtils.test1Artifact) to TestUtils.locationOfFileNamed("test1"))

return TestUtils.TargetDeployments(
targetId = targetId,
targetId = TARGET_ID,
targetToken = "",
deploymentInfo = listOf(
TestUtils.TargetDeployments.DeploymentInfo(
actionId = actionId,
actionStatusOnStart = expectedActionOnStart,
actionStatusOnFinish = actionsOnFinish,
filesDownloadedPairedWithServerFile = filesDownloadedPairedToServerFile
)
Expand All @@ -82,9 +80,8 @@ class HawkbitDownloadOnlyDeploymentTest : AbstractDeploymentTest() {
*endMessagesOnSuccessUpdate,
*messagesOnSoftUpdateAuthorization,
*messagesOnSuccessfullyDownloadDistribution(
TestUtils.md5OfFileNamed("test1"), targetId,
TestUtils.md5OfFileNamed("test1"), TARGET_ID,
"1", "test_1"),
targetRetrievedUpdateAction,
TestUtils.firstActionWithAssignmentEntry
*TestUtils.firstActionsOnTargetDeployment
))
}
Loading

0 comments on commit c33756b

Please sign in to comment.