tz70s closed pull request #3469: Ensure clean up testspace under wskadmin test. URL: https://github.com/apache/incubator-openwhisk/pull/3469
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala b/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala index 58b1def910..05264ed300 100644 --- a/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala +++ b/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala @@ -22,6 +22,7 @@ import scala.concurrent.duration.DurationInt import org.junit.runner.RunWith import org.scalatest.Matchers import org.scalatest.junit.JUnitRunner +import org.scalatest.BeforeAndAfterAll import common.RunWskAdminCmd import common.TestHelpers @@ -33,7 +34,26 @@ import whisk.core.entity.Subject import common.TestUtils @RunWith(classOf[JUnitRunner]) -class WskAdminTests extends TestHelpers with Matchers { +class WskAdminTests extends TestHelpers with Matchers with BeforeAndAfterAll { + + override def beforeAll() = { + val wskadmin = new RunWskAdminCmd {} + val testSpaces = Seq("testspace", "testspace1", "testspace2") + testSpaces.foreach(testspace => { + val noIdentStr = s"""no identities found for namespace \"$testspace\"""" + val identities = wskadmin.cli(Seq("user", "list", "-a", testspace)) + if (identities.stdout.trim == noIdentStr) { + // nothing to clean up. + } else { + identities.stdout + .split("\n") + .foreach(ident => { + val sub = ident.split("\\s+").last + wskadmin.cli(Seq("user", "delete", sub, "-ns", testspace)) + }) + } + }) + } behavior of "Wsk Admin CLI" ---------------------------------------------------------------- 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