From afdc6f71fe4af5205cd4e08a448e3d1e66f00180 Mon Sep 17 00:00:00 2001 From: Adam Jordens Date: Wed, 19 Jun 2019 13:17:04 -0700 Subject: [PATCH] feat(sql): Support ENTITY_TAGS writes to primary and previous storage services feat(sql): Support ENTITY_TAGS reads against primary This removes the last bit of special casing of ENTITY_TAGS and how we read/write them. --- .../front50/model/CompositeStorageService.kt | 19 +------------------ .../model/CompositeStorageServiceTests.kt | 12 ++++++++---- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/front50-sql/src/main/kotlin/com/netflix/spinnaker/front50/model/CompositeStorageService.kt b/front50-sql/src/main/kotlin/com/netflix/spinnaker/front50/model/CompositeStorageService.kt index 8c8386d4b..517024179 100644 --- a/front50-sql/src/main/kotlin/com/netflix/spinnaker/front50/model/CompositeStorageService.kt +++ b/front50-sql/src/main/kotlin/com/netflix/spinnaker/front50/model/CompositeStorageService.kt @@ -76,11 +76,6 @@ class CompositeStorageService( } override fun loadObject(objectType: ObjectType?, objectKey: String?): T { - if (objectType == ObjectType.ENTITY_TAGS) { - // entity tags are currently unsupported in SQL - return previous.loadObject(objectType, objectKey) - } - var exception: Exception? = null if (isPrimaryReadEnabled()) { @@ -105,11 +100,6 @@ class CompositeStorageService( } override fun loadObjects(objectType: ObjectType, objectKeys: List): List { - if (objectType == ObjectType.ENTITY_TAGS) { - // entity tags are currently unsupported in SQL - return previous.loadObjects(objectType, objectKeys) - } - var exception: Exception? = null if (isPrimaryReadEnabled()) { @@ -156,10 +146,7 @@ class CompositeStorageService( } try { - if (objectType != ObjectType.ENTITY_TAGS) { - // entity tags are currently unsupported in SQL - primary.storeObject(objectType, objectKey, item) - } + primary.storeObject(objectType, objectKey, item) } catch (e: Exception) { log.error( "{}.storeObject({}, {}) failed", @@ -174,10 +161,6 @@ class CompositeStorageService( } override fun listObjectKeys(objectType: ObjectType?): Map { - if (objectType == ObjectType.ENTITY_TAGS) { - return previous.listObjectKeys(objectType) - } - val objectKeys = mutableMapOf() if (isPreviousReadEnabled()) { diff --git a/front50-sql/src/test/kotlin/com/netflix/spinnaker/front50/model/CompositeStorageServiceTests.kt b/front50-sql/src/test/kotlin/com/netflix/spinnaker/front50/model/CompositeStorageServiceTests.kt index eab2719cb..4c3556938 100644 --- a/front50-sql/src/test/kotlin/com/netflix/spinnaker/front50/model/CompositeStorageServiceTests.kt +++ b/front50-sql/src/test/kotlin/com/netflix/spinnaker/front50/model/CompositeStorageServiceTests.kt @@ -41,18 +41,22 @@ internal object CompositeStorageServiceTests : JUnit5Minutests { } context("loadObject()") { - test("should always load EntityTags from 'previous'") { + test("should always load EntityTags from 'primary'") { every { - previous.loadObject(ObjectType.ENTITY_TAGS, "id-entitytags001") + primary.loadObject(ObjectType.ENTITY_TAGS, "id-entitytags001") } returns EntityTags().apply { id = "id-entitytags001" } + every { + dynamicConfigService.getConfig(Boolean::class.java, any(), any()) + } returns true + expectThat( subject.loadObject(ObjectType.ENTITY_TAGS, "id-entitytags001").id ).isEqualTo("id-entitytags001") verifyAll { - primary wasNot Called - previous.loadObject(ObjectType.ENTITY_TAGS, "id-entitytags001") + primary.loadObject(ObjectType.ENTITY_TAGS, "id-entitytags001") + previous wasNot Called } }