Skip to content

Commit

Permalink
Updates on Action Metrics
Browse files Browse the repository at this point in the history
Signed-off-by: harycash <harycash@amazon.com>
  • Loading branch information
harycash committed Jul 3, 2024
1 parent f0c9cb4 commit 197f439
Showing 1 changed file with 1 addition and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,19 @@ import com.nhaarman.mockitokotlin2.doReturn
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.whenever
import kotlinx.coroutines.runBlocking
import org.junit.Before
import org.mockito.ArgumentMatchers.anyString
import org.opensearch.action.support.master.AcknowledgedResponse
import org.opensearch.client.AdminClient
import org.opensearch.client.Client
import org.opensearch.client.IndicesAdminClient
import org.opensearch.cluster.service.ClusterService
import org.opensearch.common.settings.Settings
import org.opensearch.core.action.ActionListener
import org.opensearch.indexmanagement.indexstatemanagement.ManagedIndexRunner
import org.opensearch.indexmanagement.indexstatemanagement.step.readwrite.SetReadWriteStep
import org.opensearch.indexmanagement.spi.indexstatemanagement.Step
import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics
import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData
import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepContext
import org.opensearch.jobscheduler.spi.utils.LockService
import org.opensearch.script.ScriptService
import org.opensearch.telemetry.metrics.Counter
import org.opensearch.telemetry.metrics.MetricsRegistry
import org.opensearch.test.OpenSearchTestCase
import org.opensearch.transport.RemoteTransportException

Expand All @@ -38,17 +32,6 @@ class SetReadWriteStepTests : OpenSearchTestCase() {
private val scriptService: ScriptService = mock()
private val settings: Settings = Settings.EMPTY
private val lockService: LockService = LockService(mock(), clusterService)
private lateinit var metricsRegistry: MetricsRegistry

@Before
fun setup() {
metricsRegistry = mock()
whenever(metricsRegistry.createCounter(anyString(), anyString(), anyString())).thenAnswer {
mock<Counter>()
}
IndexManagementActionsMetrics.instance.initialize(metricsRegistry)
ManagedIndexRunner.registerIndexManagementActionMetrics(IndexManagementActionsMetrics.instance)
}

fun `test read write step sets step status to failed when not acknowledged`() {
val setReadWriteResponse = AcknowledgedResponse(false)
Expand Down Expand Up @@ -110,4 +93,4 @@ class SetReadWriteStepTests : OpenSearchTestCase() {
}.whenever(this.mock).updateSettings(any(), any())
}
}
}
}

0 comments on commit 197f439

Please sign in to comment.