cbickel commented on a change in pull request #3418: support cleanup of cloudant/kafka trigger dbs URL: https://github.com/apache/incubator-openwhisk/pull/3418#discussion_r174033580
########## File path: tests/src/test/scala/whisk/core/database/test/CleanUpWhisksDbSkriptTests.scala ########## @@ -257,19 +266,262 @@ class CleanUpWhisksDbSkriptTests } // execute script - val (_, _, _, kept) = runScript(dbUrl, dbName, authDBName) + val (_, _, _, kept) = runScript(dbUrl, dbName, authDBName, "whisks") println(s"kept: $kept") // Check, that script kept documents in DB val ids = documents.keys println(s"ids: $ids") - kept should contain allElementsOf ids + kept should contain("3 doc(s) for namespace whisk.system") + + val databaseResponse = client.getAllDocs(includeDocs = Some(true)).futureValue + databaseResponse should be('right) + + val databaseDocuments = databaseResponse.right.get.fields("rows").convertTo[List[JsObject]] + + val databaseDocumentIDs = databaseDocuments.map(_.fields("id").convertTo[String]) + databaseDocumentIDs should contain allElementsOf ids + + // Delete database + client.deleteDb().futureValue + } + + it should "mark documents for deletion in cloudanttrigger if namespace does not exist" in { + // Create whisks db + val dbName = dbPrefix + "cleanup_cloudanttrigger_test_mark_for_deletion" + val client = createDatabase(dbName, None) + + // Create document/action with random namespace + val documents = Map( + ":dev_cluster:vision-cloudant-trigger" -> JsObject("dbname" -> JsString("openwhisk-darkvision-dev")), + ":stage_cluster:vision-cloudant-trigger" -> JsObject("dbname" -> JsString("openwhisk-darkvision-stage")), + ":prod_cluster:vision-cloudant-trigger" -> JsObject("dbname" -> JsString("openwhisk-darkvision-prod"))) + + documents.foreach { + case (id, document) => + client.putDoc(id, document).futureValue + } + + // execute script + val (marked, _, _, _) = runScript(dbUrl, dbName, authDBName, "cloudanttrigger") + println(s"marked: $marked") Review comment: As the marked documents are already printed twice in `runScript`, can we remove the println here? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services