This is an automated email from the ASF dual-hosted git repository.
markusthoemmes pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new b00a3be Enable running basic system tests without requiring
whisk.properties. (#4004)
b00a3be is described below
commit b00a3be2b62743a74773c86fb3b14fa7184fce58
Author: Chetan Mehrotra <[email protected]>
AuthorDate: Tue Sep 18 18:31:19 2018 +0530
Enable running basic system tests without requiring whisk.properties.
(#4004)
---
.travis.yml | 7 ++-
tests/README.md | 14 +++++
tests/build.gradle | 23 ++++++--
tests/src/test/scala/common/WhiskProperties.java | 62 +++++++++++++++++++---
tests/src/test/scala/common/WskOperations.scala | 2 +-
.../scala/system/basic/WskConductorTests.scala | 3 +-
tests/src/test/scala/system/rest/RestUtil.scala | 32 +++++++----
7 files changed, 114 insertions(+), 29 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index b9056cd..5f06f6c 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 e2c37eb..a6fbb91 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 15dd333..4be83ca 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 4971797..c1a316c 100644
--- a/tests/src/test/scala/common/WhiskProperties.java
+++ b/tests/src/test/scala/common/WhiskProperties.java
@@ -32,6 +32,16 @@ import static org.junit.Assert.assertTrue;
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.
*/
protected static final String WHISK_PROPS_FILE = "whisk.properties";
@@ -87,14 +97,19 @@ public class WhiskProperties {
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 class WhiskProperties {
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 class WhiskProperties {
* host.
*/
public static String getEdgeHost() {
+ String server = getPropFromSystemOrEnv(WHISK_SERVER);
+ if (server != null) {
+ return server;
+ }
return testRouter ? getRouterHost() :
whiskProperties.getProperty("edge.host");
}
@@ -285,6 +308,17 @@ public class WhiskProperties {
}
/**
+ * 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 @@ public class WhiskProperties {
}
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 a36745c..bd089d0 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 f708b4f..0c8d318 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 b844039..a33814c 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()
}
/**