Skip to content

Commit f80019e

Browse files
remove timestamp nested tests from runner, solution and workspace
1 parent 7a67988 commit f80019e

File tree

4 files changed

+250
-287
lines changed

4 files changed

+250
-287
lines changed

organization/src/integrationTest/kotlin/com/cosmotech/organization/service/OrganizationServiceIntegrationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,7 @@ class OrganizationServiceIntegrationTest : CsmRedisTestBase() {
21392139
val organizationSaved =
21402140
organizationApiService.createOrganization(
21412141
makeSimpleOrganizationCreateRequest("organization"))
2142-
assertTrue(organizationSaved.createInfo.timestamp > startTime)
2142+
assertTrue(organizationSaved.createInfo.timestamp >= startTime)
21432143
assertEquals(organizationSaved.createInfo, organizationSaved.updateInfo)
21442144

21452145
val updateTime = Instant.now().toEpochMilli()

runner/src/integrationTest/kotlin/com/cosmotech/runner/service/RunnerServiceIntegrationTest.kt

Lines changed: 61 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ import kotlin.test.assertNull
6666
import kotlin.test.assertTrue
6767
import org.junit.jupiter.api.BeforeAll
6868
import org.junit.jupiter.api.BeforeEach
69-
import org.junit.jupiter.api.Nested
7069
import org.junit.jupiter.api.Test
7170
import org.junit.jupiter.api.assertDoesNotThrow
7271
import org.junit.jupiter.api.assertThrows
@@ -110,6 +109,7 @@ class RunnerServiceIntegrationTest : CsmRedisTestBase() {
110109
@Autowired lateinit var csmPlatformProperties: CsmPlatformProperties
111110

112111
private var containerRegistryService: ContainerRegistryService = mockk(relaxed = true)
112+
private var startTime: Long = 0
113113

114114
lateinit var connector: Connector
115115
lateinit var dataset: Dataset
@@ -166,6 +166,8 @@ class RunnerServiceIntegrationTest : CsmRedisTestBase() {
166166
rediSearchIndexer.createIndexFor(Workspace::class.java)
167167
rediSearchIndexer.createIndexFor(Runner::class.java)
168168

169+
startTime = Instant.now().toEpochMilli()
170+
169171
connector = makeConnector("Connector")
170172
connectorSaved = connectorApiService.registerConnector(connector)
171173

@@ -1068,90 +1070,73 @@ class RunnerServiceIntegrationTest : CsmRedisTestBase() {
10681070
}
10691071
}
10701072

1071-
@Nested
1072-
inner class RunnerTimeStampsTest() {
1073-
private var startTime: Long = 0
1074-
1075-
@BeforeEach
1076-
fun init() {
1077-
startTime = Instant.now().toEpochMilli()
1078-
organizationSaved =
1079-
organizationApiService.createOrganization(makeOrganizationCreateRequest("organization"))
1080-
solutionSaved = solutionApiService.createSolution(organizationSaved.id, makeSolution())
1081-
datasetSaved = datasetApiService.createDataset(organizationSaved.id, makeDataset())
1082-
workspaceSaved =
1083-
workspaceApiService.createWorkspace(organizationSaved.id, makeWorkspaceCreateRequest())
1084-
runnerSaved =
1085-
runnerApiService.createRunner(
1086-
organizationSaved.id, workspaceSaved.id, makeRunnerCreateRequest())
1087-
}
1073+
@Test
1074+
fun `assert timestamps are functional for base CRUD`() {
1075+
runnerSaved =
1076+
runnerApiService.createRunner(
1077+
organizationSaved.id, workspaceSaved.id, makeRunnerCreateRequest())
1078+
assertTrue(runnerSaved.createInfo.timestamp > startTime)
1079+
assertEquals(runnerSaved.createInfo, runnerSaved.updateInfo)
10881080

1089-
@Test
1090-
fun `assert timestamps are functional for base CRUD`() {
1091-
assertTrue(runnerSaved.createInfo.timestamp > startTime)
1092-
assertEquals(runnerSaved.createInfo, runnerSaved.updateInfo)
1093-
1094-
val updateTime = Instant.now().toEpochMilli()
1095-
val runnerUpdated =
1096-
runnerApiService.updateRunner(
1097-
organizationSaved.id,
1098-
workspaceSaved.id,
1099-
runnerSaved.id,
1100-
RunnerUpdateRequest("runnerUpdated"))
1101-
1102-
assertTrue { updateTime < runnerUpdated.updateInfo.timestamp }
1103-
assertEquals(runnerSaved.createInfo, runnerUpdated.createInfo)
1104-
assertTrue { runnerSaved.createInfo.timestamp < runnerUpdated.updateInfo.timestamp }
1105-
assertTrue { runnerSaved.updateInfo.timestamp < runnerUpdated.updateInfo.timestamp }
1106-
1107-
val runnerFetched =
1108-
runnerApiService.getRunner(organizationSaved.id, workspaceSaved.id, runnerSaved.id)
1109-
1110-
assertEquals(runnerUpdated.createInfo, runnerFetched.createInfo)
1111-
assertEquals(runnerUpdated.updateInfo, runnerFetched.updateInfo)
1112-
}
1081+
val updateTime = Instant.now().toEpochMilli()
1082+
val runnerUpdated =
1083+
runnerApiService.updateRunner(
1084+
organizationSaved.id,
1085+
workspaceSaved.id,
1086+
runnerSaved.id,
1087+
RunnerUpdateRequest("runnerUpdated"))
11131088

1114-
@Test
1115-
fun `assert timestamps are functional for RBAC CRUD`() {
1116-
runnerApiService.createRunnerAccessControl(
1117-
organizationSaved.id,
1118-
workspaceSaved.id,
1119-
runnerSaved.id,
1120-
RunnerAccessControl("newUser", ROLE_VIEWER))
1121-
val rbacAdded =
1122-
runnerApiService.getRunner(organizationSaved.id, workspaceSaved.id, runnerSaved.id)
1089+
assertTrue { updateTime < runnerUpdated.updateInfo.timestamp }
1090+
assertEquals(runnerSaved.createInfo, runnerUpdated.createInfo)
1091+
assertTrue { runnerSaved.createInfo.timestamp < runnerUpdated.updateInfo.timestamp }
1092+
assertTrue { runnerSaved.updateInfo.timestamp < runnerUpdated.updateInfo.timestamp }
11231093

1124-
assertEquals(runnerSaved.createInfo, rbacAdded.createInfo)
1125-
assertTrue { runnerSaved.updateInfo.timestamp < rbacAdded.updateInfo.timestamp }
1094+
val runnerFetched =
1095+
runnerApiService.getRunner(organizationSaved.id, workspaceSaved.id, runnerSaved.id)
11261096

1127-
runnerApiService.getRunnerAccessControl(
1128-
organizationSaved.id, workspaceSaved.id, runnerSaved.id, "newUser")
1129-
val rbacFetched =
1130-
runnerApiService.getRunner(organizationSaved.id, workspaceSaved.id, runnerSaved.id)
1097+
assertEquals(runnerUpdated.createInfo, runnerFetched.createInfo)
1098+
assertEquals(runnerUpdated.updateInfo, runnerFetched.updateInfo)
1099+
}
11311100

1132-
assertEquals(rbacAdded.createInfo, rbacFetched.createInfo)
1133-
assertEquals(rbacAdded.updateInfo, rbacFetched.updateInfo)
1101+
@Test
1102+
fun `assert timestamps are functional for RBAC CRUD`() {
1103+
runnerSaved =
1104+
runnerApiService.createRunner(
1105+
organizationSaved.id, workspaceSaved.id, makeRunnerCreateRequest())
1106+
runnerApiService.createRunnerAccessControl(
1107+
organizationSaved.id,
1108+
workspaceSaved.id,
1109+
runnerSaved.id,
1110+
RunnerAccessControl("newUser", ROLE_VIEWER))
1111+
val rbacAdded =
1112+
runnerApiService.getRunner(organizationSaved.id, workspaceSaved.id, runnerSaved.id)
11341113

1135-
runnerApiService.updateRunnerAccessControl(
1136-
organizationSaved.id,
1137-
workspaceSaved.id,
1138-
runnerSaved.id,
1139-
"newUser",
1140-
RunnerRole(ROLE_VIEWER))
1141-
val rbacUpdated =
1142-
runnerApiService.getRunner(organizationSaved.id, workspaceSaved.id, runnerSaved.id)
1114+
assertEquals(runnerSaved.createInfo, rbacAdded.createInfo)
1115+
assertTrue { runnerSaved.updateInfo.timestamp < rbacAdded.updateInfo.timestamp }
11431116

1144-
assertEquals(rbacFetched.createInfo, rbacUpdated.createInfo)
1145-
assertTrue { rbacFetched.updateInfo.timestamp < rbacUpdated.updateInfo.timestamp }
1117+
runnerApiService.getRunnerAccessControl(
1118+
organizationSaved.id, workspaceSaved.id, runnerSaved.id, "newUser")
1119+
val rbacFetched =
1120+
runnerApiService.getRunner(organizationSaved.id, workspaceSaved.id, runnerSaved.id)
11461121

1147-
runnerApiService.deleteRunnerAccessControl(
1148-
organizationSaved.id, workspaceSaved.id, runnerSaved.id, "newUser")
1149-
val rbacDeleted =
1150-
runnerApiService.getRunner(organizationSaved.id, workspaceSaved.id, runnerSaved.id)
1122+
assertEquals(rbacAdded.createInfo, rbacFetched.createInfo)
1123+
assertEquals(rbacAdded.updateInfo, rbacFetched.updateInfo)
11511124

1152-
assertEquals(rbacUpdated.createInfo, rbacDeleted.createInfo)
1153-
assertTrue { rbacUpdated.updateInfo.timestamp < rbacDeleted.updateInfo.timestamp }
1154-
}
1125+
runnerApiService.updateRunnerAccessControl(
1126+
organizationSaved.id, workspaceSaved.id, runnerSaved.id, "newUser", RunnerRole(ROLE_VIEWER))
1127+
val rbacUpdated =
1128+
runnerApiService.getRunner(organizationSaved.id, workspaceSaved.id, runnerSaved.id)
1129+
1130+
assertEquals(rbacFetched.createInfo, rbacUpdated.createInfo)
1131+
assertTrue { rbacFetched.updateInfo.timestamp < rbacUpdated.updateInfo.timestamp }
1132+
1133+
runnerApiService.deleteRunnerAccessControl(
1134+
organizationSaved.id, workspaceSaved.id, runnerSaved.id, "newUser")
1135+
val rbacDeleted =
1136+
runnerApiService.getRunner(organizationSaved.id, workspaceSaved.id, runnerSaved.id)
1137+
1138+
assertEquals(rbacUpdated.createInfo, rbacDeleted.createInfo)
1139+
assertTrue { rbacUpdated.updateInfo.timestamp < rbacDeleted.updateInfo.timestamp }
11551140
}
11561141

11571142
private fun makeConnector(name: String = "name"): Connector {

0 commit comments

Comments
 (0)