You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/02/16 09:14:58 UTC

[GitHub] cbickel closed pull request #3290: Check all testfiles to actually contain the `RunWith` annotation.

cbickel closed pull request #3290: Check all testfiles to actually contain the `RunWith` annotation.
URL: https://github.com/apache/incubator-openwhisk/pull/3290
 
 
   

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/cli/test/JsonArgsForTests.scala b/tests/src/test/scala/whisk/core/cli/test/TestJsonArgs.scala
similarity index 99%
rename from tests/src/test/scala/whisk/core/cli/test/JsonArgsForTests.scala
rename to tests/src/test/scala/whisk/core/cli/test/TestJsonArgs.scala
index 9d8910ef7d..474e8209c1 100644
--- a/tests/src/test/scala/whisk/core/cli/test/JsonArgsForTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/TestJsonArgs.scala
@@ -23,7 +23,7 @@ import spray.json.JsString
 import spray.json.JsNumber
 import spray.json.JsBoolean
 
-object JsonArgsForTests {
+object TestJsonArgs {
 
   def getInvalidJSONInput =
     Seq(
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
index 970d569ab1..925c098bcb 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
@@ -45,7 +45,7 @@ import whisk.core.entity.LogLimit._
 import whisk.core.entity.MemoryLimit._
 import whisk.core.entity.TimeLimit._
 import whisk.core.entity.size.SizeInt
-import JsonArgsForTests._
+import TestJsonArgs._
 import whisk.http.Messages
 
 /**
diff --git a/tests/src/test/scala/whisk/core/loadBalancer/test/LoadBalancerDataTests.scala b/tests/src/test/scala/whisk/core/loadBalancer/test/LoadBalancerDataTests.scala
index 9afa67f575..b60989aa0a 100644
--- a/tests/src/test/scala/whisk/core/loadBalancer/test/LoadBalancerDataTests.scala
+++ b/tests/src/test/scala/whisk/core/loadBalancer/test/LoadBalancerDataTests.scala
@@ -21,6 +21,8 @@ import akka.actor.ActorSystem
 import akka.actor.Cancellable
 import com.typesafe.config.{ConfigFactory, ConfigValueFactory}
 import common.StreamLogging
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
 import org.scalatest.{FlatSpec, Matchers}
 import whisk.core.entity.{ActivationId, UUID, WhiskActivation}
 import whisk.core.loadBalancer.{ActivationEntry, DistributedLoadBalancerData, LocalLoadBalancerData}
@@ -30,6 +32,7 @@ import whisk.core.entity.InstanceId
 
 import scala.concurrent.duration._
 
+@RunWith(classOf[JUnitRunner])
 class LoadBalancerDataTests extends FlatSpec with Matchers with StreamLogging {
   final val emptyCancellable: Cancellable = new Cancellable {
     def isCancelled = false
diff --git a/tests/src/test/scala/whisk/core/loadBalancer/test/SeedNodesProviderTest.scala b/tests/src/test/scala/whisk/core/loadBalancer/test/SeedNodesProviderTests.scala
similarity index 91%
rename from tests/src/test/scala/whisk/core/loadBalancer/test/SeedNodesProviderTest.scala
rename to tests/src/test/scala/whisk/core/loadBalancer/test/SeedNodesProviderTests.scala
index 345c885a43..ef4ae850c0 100644
--- a/tests/src/test/scala/whisk/core/loadBalancer/test/SeedNodesProviderTest.scala
+++ b/tests/src/test/scala/whisk/core/loadBalancer/test/SeedNodesProviderTests.scala
@@ -18,10 +18,13 @@
 package whisk.core.loadBalancer.test
 
 import akka.actor.Address
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
 import org.scalatest.{FlatSpec, Matchers}
-import whisk.core.loadBalancer.{StaticSeedNodesProvider}
+import whisk.core.loadBalancer.StaticSeedNodesProvider
 
-class SeedNodesProviderTest extends FlatSpec with Matchers {
+@RunWith(classOf[JUnitRunner])
+class SeedNodesProviderTests extends FlatSpec with Matchers {
 
   val actorSystemName = "controller-actor-system"
   val host = "192.168.99.100"
diff --git a/tests/src/test/scala/whisk/core/loadBalancer/test/SharedDataServiceTests.scala b/tests/src/test/scala/whisk/core/loadBalancer/test/SharedDataServiceTests.scala
index 3961e539ca..b3b37a716c 100644
--- a/tests/src/test/scala/whisk/core/loadBalancer/test/SharedDataServiceTests.scala
+++ b/tests/src/test/scala/whisk/core/loadBalancer/test/SharedDataServiceTests.scala
@@ -20,27 +20,26 @@ package whisk.core.loadBalancer.test
 import akka.actor.ActorSystem
 import akka.testkit.{ImplicitSender, TestKit}
 import akka.util.Timeout
-import com.typesafe.config.ConfigValueFactory
-import com.typesafe.config.ConfigFactory
-import org.scalatest._
+import com.typesafe.config.{ConfigFactory, ConfigValueFactory}
+import org.junit.runner.RunWith
+import org.scalatest.{FlatSpecLike, _}
+import org.scalatest.junit.JUnitRunner
 import whisk.core.loadBalancer._
-import org.scalatest.FlatSpecLike
 
 import scala.concurrent.duration._
 
 // Define your test specific configuration here
 
 object TestKitConfig {
-  val config = """
-    akka.remote.netty.tcp {
-      hostname = "127.0.0.1"
-      port = 2555
-    }
-    """
+  val config = ConfigFactory.empty
+    .withValue("akka.remote.netty.tcp.hostname", ConfigValueFactory.fromAnyRef("127.0.0.1"))
+    .withValue("akka.remote.netty.tcp.port", ConfigValueFactory.fromAnyRef("2555"))
+    .withValue("akka.actor.provider", ConfigValueFactory.fromAnyRef("cluster"))
 }
 
+@RunWith(classOf[JUnitRunner])
 class SharedDataServiceTests()
-    extends TestKit(ActorSystem("ControllerCluster", ConfigFactory.parseString(TestKitConfig.config)))
+    extends TestKit(ActorSystem("ControllerCluster", TestKitConfig.config))
     with ImplicitSender
     with FlatSpecLike
     with Matchers
@@ -52,16 +51,7 @@ class SharedDataServiceTests()
 
   behavior of "SharedDataService"
 
-  val port = 2552
-  val host = "127.0.0.1"
-  val config = ConfigFactory
-    .parseString(s"akka.remote.netty.tcp.hostname=$host")
-    .withValue("akka.remote.netty.tcp.port", ConfigValueFactory.fromAnyRef(port))
-    .withValue("akka.actor.provider", ConfigValueFactory.fromAnyRef("cluster"))
-    .withFallback(ConfigFactory.load())
-
-  val s = ActorSystem("controller-actor-system", config)
-  val sharedDataService = s.actorOf(SharedDataService.props("Candidates"), name = "busyMan")
+  val sharedDataService = system.actorOf(SharedDataService.props("Candidates"), name = "busyMan")
   implicit val timeout = Timeout(5.seconds)
 
   it should "retrieve an empty map after initialization" in {
@@ -70,20 +60,20 @@ class SharedDataServiceTests()
     expectMsg(msg)
   }
   it should "increase the counter" in {
-    sharedDataService ! (IncreaseCounter("Donald", 1))
+    sharedDataService ! IncreaseCounter("Donald", 1)
     sharedDataService ! GetMap
     val msg = Map("Donald" -> 1)
     expectMsg(msg)
   }
   it should "decrease the counter" in {
-    sharedDataService ! (IncreaseCounter("Donald", 2))
-    sharedDataService ! (DecreaseCounter("Donald", 2))
+    sharedDataService ! IncreaseCounter("Donald", 2)
+    sharedDataService ! DecreaseCounter("Donald", 2)
     sharedDataService ! GetMap
     val msg = Map("Donald" -> 1)
     expectMsg(msg)
   }
   it should "receive the map with all counters" in {
-    sharedDataService ! (IncreaseCounter("Hilary", 1))
+    sharedDataService ! IncreaseCounter("Hilary", 1)
     sharedDataService ! GetMap
     val msg = Map("Hilary" -> 1, "Donald" -> 1)
     expectMsg(msg)
diff --git a/tools/travis/build.sh b/tools/travis/build.sh
index 4870acb72a..c98285f1d4 100755
--- a/tools/travis/build.sh
+++ b/tools/travis/build.sh
@@ -18,6 +18,15 @@ incubator-openwhisk-utilities/scancode/scanCode.py $ROOTDIR --config $ROOTDIR/to
 cd $ROOTDIR
 TERM=dumb ./gradlew checkScalafmtAll
 
+# lint tests to all be actually runnable
+MISSING_TESTS=$(grep -rL "RunWith" --include="*Tests.scala" tests)
+if [ -n "$MISSING_TESTS" ]
+then
+  echo "The following tests are missing the 'RunWith' annotation"
+  echo $MISSING_TESTS
+  exit 1
+fi
+
 cd $ROOTDIR/ansible
 
 ANSIBLE_CMD="ansible-playbook -i environments/local -e docker_image_prefix=testing"


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services