Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bwc update #604

Merged
merged 6 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions opensearch-observability/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,15 @@ testClusters.integTest {
setting 'path.repo', repo.absolutePath
}

String bwcVersion = "1.1.0-SNAPSHOT"
String bwcVersion = "1.2.0-SNAPSHOT"
String baseName = "obsBwcCluster"
String bwcFilePath = "src/test/kotlin/org/opensearch/observability/resources/bwc/"

2.times {i ->
testClusters {
"${baseName}$i" {
testDistribution = "ARCHIVE"
versions = ["1.1.0",opensearch_version]
versions = ["1.2.0",opensearch_version]
numberOfNodes = 3
plugin(provider(new Callable<RegularFile>(){
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ package org.opensearch.observability.bwc

import org.junit.Assert
import org.opensearch.common.settings.Settings
import org.opensearch.observability.ObservabilityPlugin.Companion.BASE_NOTEBOOKS_URI
import org.opensearch.observability.ObservabilityPlugin.Companion.BASE_OBSERVABILITY_URI
import org.opensearch.observability.PluginRestTestCase
import org.opensearch.observability.constructNotebookRequest
import org.opensearch.observability.constructOperationalPanelRequest
import org.opensearch.observability.constructSavedQueryRequest
import org.opensearch.observability.constructSavedVisualizationRequest
import org.opensearch.observability.jsonify
import org.opensearch.rest.RestRequest
import org.opensearch.rest.RestStatus
import java.util.List
Expand Down Expand Up @@ -70,18 +73,16 @@ class TABackwardCompatibilityIT : PluginRestTestCase() {
val pluginNames = plugins.map { plugin -> plugin["name"] }.toSet()
return when (CLUSTER_TYPE) {
ClusterType.OLD -> {
assertTrue(pluginNames.contains("opensearch-notebooks"))
createNotebook()
assertTrue(pluginNames.contains("opensearch-observability"))
createObsObjects()
}
ClusterType.MIXED -> {
assertTrue(pluginNames.contains("opensearch-observability"))
if (System.getProperty("tests.rest.bwcsuite_round") != "third") {
verifyNotebooksExists("$BASE_NOTEBOOKS_URI/notebooks")
} else verifyNotebooksExists("$BASE_OBSERVABILITY_URI/object")
verifyObsObjectExists()
}
ClusterType.UPGRADED -> {
assertTrue(pluginNames.contains("opensearch-observability"))
verifyNotebooksExists("$BASE_OBSERVABILITY_URI/object")
verifyObsObjectExists()
}
}
break
Expand All @@ -102,27 +103,115 @@ class TABackwardCompatibilityIT : PluginRestTestCase() {
}
}

private fun createObsObjects() {
createNotebook()
createSavedQuery()
createSavedVisualization()
createOperationalPanel()
}

private fun verifyObsObjectExists() {
verifyNotebooksExists()
verifySavedQueryExists()
verifySavedVisualizationExists()
verifyOperationalPanelExists()
}

private fun createNotebook() {
val createRequest = constructNotebookRequest()
val createResponse = executeRequest(
RestRequest.Method.POST.name,
"$BASE_NOTEBOOKS_URI/notebook",
"$BASE_OBSERVABILITY_URI/object",
createRequest,
RestStatus.OK.status
)
val id = createResponse.get("notebookId").asString
val id = createResponse.get("objectId").asString
Assert.assertNotNull("Id should be generated", id)
Thread.sleep(100)
}

private fun verifyNotebooksExists(uri: String) {
private fun createSavedQuery() {
val createRequest = jsonify(constructSavedQueryRequest())
createRequest.addProperty("objectId", "testId")

val createResponse = executeRequest(
RestRequest.Method.POST.name,
"$BASE_OBSERVABILITY_URI/object",
createRequest.toString(),
RestStatus.OK.status
)
val id = createResponse.get("objectId").asString
Assert.assertEquals("testId", id)
Thread.sleep(100)
}

private fun createSavedVisualization() {
val createRequest = constructSavedVisualizationRequest()
val createResponse = executeRequest(
RestRequest.Method.POST.name,
"$BASE_OBSERVABILITY_URI/object",
createRequest,
RestStatus.OK.status
)
val id = createResponse.get("objectId").asString
Assert.assertNotNull("Id should be generated", id)
Thread.sleep(100)
}

private fun createOperationalPanel() {
val createRequest = constructOperationalPanelRequest()
val createResponse = executeRequest(
RestRequest.Method.POST.name,
"$BASE_OBSERVABILITY_URI/object",
createRequest,
RestStatus.OK.status
)
val id = createResponse.get("objectId").asString
Assert.assertNotNull("Id should be generated", id)
Thread.sleep(100)
}

private fun verifyNotebooksExists() {
val listNotebooks = executeRequest(
RestRequest.Method.GET.name,
"$uri",
"$BASE_OBSERVABILITY_URI/object?objectType=notebook",
"",
RestStatus.OK.status
)
val totalHits = listNotebooks.get("totalHits").asInt
assertTrue("Actual notebooks counts ($totalHits) should be equal to (1)", totalHits == 1)
}

private fun verifySavedQueryExists() {
val listSavedQuery = executeRequest(
RestRequest.Method.GET.name,
"$BASE_OBSERVABILITY_URI/object?objectType=savedQuery",
"",
RestStatus.OK.status
)
val totalHits = listSavedQuery.get("totalHits").asInt
assertTrue("Actual saved query counts ($totalHits) should be equal to (1)", totalHits == 1)
}

private fun verifySavedVisualizationExists() {
val listSavedVisualization = executeRequest(
RestRequest.Method.GET.name,
"$BASE_OBSERVABILITY_URI/object?objectType=savedVisualization",
"",
RestStatus.OK.status
)
val totalHits = listSavedVisualization.get("totalHits").asInt
assertTrue("Actual saved visualization counts ($totalHits) should be equal to (1)", totalHits == 1)
}

private fun verifyOperationalPanelExists() {
val listOperationalPanel = executeRequest(
RestRequest.Method.GET.name,
"$BASE_OBSERVABILITY_URI/object?objectType=operationalPanel",
"",
RestStatus.OK.status
)
val totalHits = listOperationalPanel.get("totalHits").asInt
assertTrue("Actual saved visualization counts ($totalHits) should be equal to (1)", totalHits == 1)
}
}
Binary file not shown.