markusthoemmes closed pull request #4004: Enable running basic system tests
without requiring whisk.properties
URL: https://github.com/apache/incubator-openwhisk/pull/4004
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/.travis.yml b/.travis.yml
index b9056cdb23..5f06f6cc21 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -68,11 +68,11 @@ jobs:
- script:
- ./tools/travis/runUnitTests.sh
- ./tools/travis/checkAndUploadLogs.sh unit db
- env: DESCRIPTION="Unit Tests"
+ name: "Unit Tests"
- script:
- ./tools/travis/runSystemTests.sh
- ./tools/travis/checkAndUploadLogs.sh system
- env: DESCRIPTION="System Tests"
+ name: "System Tests"
- script:
- ./tests/performance/preparation/deploy.sh
- TERM=dumb ./tests/performance/wrk_tests/latency.sh
"https://172.17.0.1:10001" "$(cat ansible/files/auth.guest)" 2m
@@ -82,5 +82,4 @@ jobs:
- OPENWHISK_HOST="172.17.0.1" API_KEY="$(cat
ansible/files/auth.guest)" CONNECTIONS="100" REQUESTS_PER_SEC="1" ./gradlew
gatlingRun-BlockingInvokeOneActionSimulation
# The following configuration does not make much sense. But we do not
have enough users. But it's good to verify, that the test is still working.
- OPENWHISK_HOST="172.17.0.1" USERS="1" REQUESTS_PER_SEC="1" ./gradlew
gatlingRun-ColdBlockingInvokeSimulation
- env:
- - DESCRIPTION="Execute wrk-performance test suite."
+ name: "Performance Tests"
diff --git a/tests/README.md b/tests/README.md
index e2c37eb9a4..a6fbb91566 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -34,3 +34,17 @@ To just run the unit tests
$ ansible-playbook -i ansible/environments/local ansible/properties.yml
$ ./gradlew tests:testUnit
+
+## Running System Basic Tests
+
+To just run system basic test against an existing running setup you can pass
on the server details and auth via system properties
+
+ $ ./gradlew :tests:testSystemBasic
-Dwhisk.auth="23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP"
-Dwhisk.server=https://localhost -Dopenwhisk.home=`pwd`
+
+Here
+
+* `whisk.auth` - Auth key for a test user account. For a setup using default
credentials it can be `guest` key. (env `WHISK_AUTH`)
+* `whisk.server` - Edge Host Url of the OpenWhisk setup. (env `WHISK_SERVER`)
+* `opnewhisk.home` - Base directory of your OpenWhisk source tree. (env
`OPENWHISK_HOME`)
+
+If required you can relax the SSL check by passing `-Dwhisk.ssl.relax=true`.
All these properties can also be provided via env variables.
diff --git a/tests/build.gradle b/tests/build.gradle
index 15dd333b5d..4be83cad58 100644
--- a/tests/build.gradle
+++ b/tests/build.gradle
@@ -83,6 +83,11 @@ ext.testSets = [
],
"LEAN" : [
"excludes" : leanExcludes
+ ],
+ "REQUIRE_SYSTEM_BASIC" : [
+ "includes" : [
+ "system/basic/**"
+ ]
]
]
@@ -117,6 +122,11 @@ task testLean(type: Test) {
include getPattern(testSetName, "includes")
}
+task testSystemBasic(type: Test) {
+ exclude getPattern("REQUIRE_SYSTEM_BASIC", "excludes")
+ include getPattern("REQUIRE_SYSTEM_BASIC", "includes")
+}
+
task testUnit(type: Test) {
systemProperty("whisk.spi.ArtifactStoreProvider",
"whisk.core.database.memory.MemoryArtifactStoreProvider")
exclude getPattern("REQUIRE_ONLY_DB", "excludes")
@@ -177,11 +187,14 @@ task deleteKeystore(type: Delete) {
}
task createKeystore(dependsOn: deleteKeystore) {
doLast {
- Properties props = new Properties()
- props.load(new FileInputStream(file('../whisk.properties')))
- keystorePath.parentFile.mkdirs()
- def cmd = ['keytool', '-import', '-alias', 'Whisk', '-noprompt',
'-trustcacerts', '-file', file(props['whisk.ssl.cert']), '-keystore',
keystorePath, '-storepass', 'openwhisk']
- cmd.execute().waitForProcessOutput(System.out, System.err)
+ def propsFile = file('../whisk.properties')
+ if (propsFile.exists()) {
+ Properties props = new Properties()
+ props.load(new FileInputStream(propsFile))
+ keystorePath.parentFile.mkdirs()
+ def cmd = ['keytool', '-import', '-alias', 'Whisk', '-noprompt',
'-trustcacerts', '-file', file(props['whisk.ssl.cert']), '-keystore',
keystorePath, '-storepass', 'openwhisk']
+ cmd.execute().waitForProcessOutput(System.out, System.err)
+ }
}
}
diff --git a/tests/src/test/scala/common/WhiskProperties.java
b/tests/src/test/scala/common/WhiskProperties.java
index 4971797046..c1a316cb8b 100644
--- a/tests/src/test/scala/common/WhiskProperties.java
+++ b/tests/src/test/scala/common/WhiskProperties.java
@@ -31,6 +31,16 @@
*/
public class WhiskProperties {
+ /**
+ * System property key which refers to OpenWhisk Edge Host url
+ */
+ private static final String WHISK_SERVER = "whisk.server";
+
+ /**
+ * System property key which refers to authentication key to be used for
testing
+ */
+ private static final String WHISK_AUTH = "whisk.auth";
+
/**
* The name of the properties file.
*/
@@ -87,14 +97,19 @@
assertTrue("could not determine openwhisk home", wskdir != null);
- File wskpropsFile = new File(wskdir, WHISK_PROPS_FILE);
- assertTrue(String.format("'%s' does not exists but required",
wskpropsFile), wskpropsFile.exists());
+ if (isWhiskPropertiesRequired()) {
+ File wskpropsFile = new File(wskdir, WHISK_PROPS_FILE);
+ assertTrue(String.format("'%s' does not exists but required",
wskpropsFile), wskpropsFile.exists());
- // loads properties from file
- whiskProperties = loadProperties(wskpropsFile);
+ // loads properties from file
+ whiskProperties = loadProperties(wskpropsFile);
- // set whisk home from read properties
- whiskHome = whiskProperties.getProperty("openwhisk.home");
+ // set whisk home from read properties
+ whiskHome = whiskProperties.getProperty("openwhisk.home");
+ } else {
+ whiskProperties = new Properties();
+ whiskHome = wskdir;
+ }
System.out.format("test router? %s\n", testRouter);
}
@@ -157,6 +172,10 @@ public static int numberOfInvokers() {
return getInvokerHosts().length;
}
+ public static boolean isSSLCheckRelaxed() {
+ return Boolean.valueOf(getPropFromSystemOrEnv("whisk.ssl.relax"));
+ }
+
public static String getSslCertificateChallenge() {
return whiskProperties.getProperty("whisk.ssl.challenge");
}
@@ -166,6 +185,10 @@ public static String getSslCertificateChallenge() {
* host.
*/
public static String getEdgeHost() {
+ String server = getPropFromSystemOrEnv(WHISK_SERVER);
+ if (server != null) {
+ return server;
+ }
return testRouter ? getRouterHost() :
whiskProperties.getProperty("edge.host");
}
@@ -284,6 +307,17 @@ public static String readAuthKey(File filename) {
}
}
+ /**
+ * Returns auth key to be used for testing
+ */
+ public static String getAuthKeyForTesting() {
+ String authKey = getPropFromSystemOrEnv(WHISK_AUTH);
+ if (authKey == null) {
+ authKey = readAuthKey(getAuthFileForTesting());
+ }
+ return authKey;
+ }
+
/**
* @return the path to a file holding the VCAP_SERVICES used during junit
* testing
@@ -358,4 +392,20 @@ protected static Properties loadProperties(File propsFile)
{
}
return props;
}
+
+ private static boolean isWhiskPropertiesRequired() {
+ return getPropFromSystemOrEnv(WHISK_SERVER) == null;
+ }
+
+ private static String getPropFromSystemOrEnv(String key) {
+ String value = System.getProperty(key);
+ if (value == null) {
+ value = System.getenv(toEnvName(key));
+ }
+ return value;
+ }
+
+ private static String toEnvName(String p) {
+ return p.replace('.', '_').toUpperCase();
+ }
}
diff --git a/tests/src/test/scala/common/WskOperations.scala
b/tests/src/test/scala/common/WskOperations.scala
index a36745c5be..bd089d0955 100644
--- a/tests/src/test/scala/common/WskOperations.scala
+++ b/tests/src/test/scala/common/WskOperations.scala
@@ -32,7 +32,7 @@ import whisk.core.entity.ByteSize
import scala.util.Try
case class WskProps(
- authKey: String =
WhiskProperties.readAuthKey(WhiskProperties.getAuthFileForTesting),
+ authKey: String = WhiskProperties.getAuthKeyForTesting,
cert: String =
WhiskProperties.getFileRelativeToWhiskHome("ansible/roles/nginx/files/openwhisk-client-cert.pem").getAbsolutePath,
key: String =
diff --git a/tests/src/test/scala/system/basic/WskConductorTests.scala
b/tests/src/test/scala/system/basic/WskConductorTests.scala
index f708b4f5c7..0c8d3180ac 100644
--- a/tests/src/test/scala/system/basic/WskConductorTests.scala
+++ b/tests/src/test/scala/system/basic/WskConductorTests.scala
@@ -41,8 +41,7 @@ class WskConductorTests extends TestHelpers with
WskTestHelpers with JsHelpers w
val invalid = "invalid#Action"
val missing = "missingAction"
- val whiskConfig = new WhiskConfig(Map(WhiskConfig.actionSequenceMaxLimit ->
null))
- assert(whiskConfig.isValid)
+ val whiskConfig = new WhiskConfig(Map(WhiskConfig.actionSequenceMaxLimit ->
"50"))
val limit = whiskConfig.actionSequenceLimit.toInt
behavior of "Whisk conductor actions"
diff --git a/tests/src/test/scala/system/rest/RestUtil.scala
b/tests/src/test/scala/system/rest/RestUtil.scala
index b844039da8..a33814cc31 100644
--- a/tests/src/test/scala/system/rest/RestUtil.scala
+++ b/tests/src/test/scala/system/rest/RestUtil.scala
@@ -17,12 +17,12 @@
package system.rest
-import scala.util.Try
+import akka.http.scaladsl.model.Uri
+import scala.util.Try
import com.jayway.restassured.RestAssured
import com.jayway.restassured.config.RestAssuredConfig
import com.jayway.restassured.config.SSLConfig
-
import common.WhiskProperties
import spray.json._
@@ -31,16 +31,18 @@ import spray.json._
*/
trait RestUtil {
- private val skipKeyStore = false // set this to true for convenient local
testing
+ private val skipKeyStore = WhiskProperties.isSSLCheckRelaxed
private val trustStorePassword = WhiskProperties.getSslCertificateChallenge
// force RestAssured to allow all hosts in SSL certificates
- protected val sslconfig = {
- new RestAssuredConfig().sslConfig(if (!skipKeyStore) {
- new SSLConfig().keystore("keystore",
trustStorePassword).allowAllHostnames()
+ val sslconfig = {
+ val inner = new SSLConfig().allowAllHostnames()
+ val config = if (!skipKeyStore && trustStorePassword != null) {
+ inner.keystore("keystore", trustStorePassword)
} else {
- new SSLConfig().relaxedHTTPSValidation().allowAllHostnames()
- })
+ inner.relaxedHTTPSValidation()
+ }
+ new RestAssuredConfig().sslConfig(config)
}
/**
@@ -54,9 +56,17 @@ trait RestUtil {
* @return the URL and port for the whisk service using the main router or
the edge router ip address
*/
def getServiceURL(): String = {
- val apiPort = WhiskProperties.getEdgeHostApiPort()
- val protocol = if (apiPort == 443) "https" else "http"
- protocol + "://" + WhiskProperties.getEdgeHost() + ":" + apiPort
+ val host = WhiskProperties.getEdgeHost
+ val uri = Uri(host)
+ //Ensure that port is explicitly include in the returned URL
+ val absolute = if (uri.isAbsolute) {
+ uri.withPort(uri.effectivePort)
+ } else {
+ val apiPort = WhiskProperties.getEdgeHostApiPort
+ val protocol = if (apiPort == 443) "https" else "http"
+ Uri.from(scheme = protocol, host = host, port = apiPort)
+ }
+ absolute.toString()
}
/**
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services