rabbah commented on a change in pull request #4790: Config runtime URL: https://github.com/apache/openwhisk/pull/4790#discussion_r371009731
########## File path: tests/src/test/scala/org/apache/openwhisk/operation/RuntimeConfiguration.scala ########## @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.openwhisk.operation + +import akka.http.scaladsl.Http +import akka.http.scaladsl.model.headers.{Authorization, BasicHttpCredentials} +import akka.http.scaladsl.model.{ContentTypes, HttpEntity, HttpMethods, HttpRequest, StatusCodes} +import akka.http.scaladsl.unmarshalling.Unmarshal +import akka.stream.ActorMaterializer +import common._ +import common.rest.HttpConnection +import org.apache.openwhisk.core.connector.PrewarmContainerDataList +import org.apache.openwhisk.core.connector.PrewarmContainerDataProtocol._ +import org.junit.runner.RunWith +import org.scalatest.Matchers +import org.scalatest.concurrent.ScalaFutures +import org.scalatest.junit.JUnitRunner +import spray.json._ +import system.rest.RestUtil + +import scala.concurrent.duration._ +import scala.util.Random + +@RunWith(classOf[JUnitRunner]) +class RuntimeConfigurationTests + extends TestHelpers + with RestUtil + with Matchers + with ScalaFutures + with WskActorSystem + with StreamLogging { + + implicit val materializer = ActorMaterializer() + + val kind = "nodejs:10" + val memory = 128 + var count = new Random().nextInt(3) + 1 + + def getRuntimes = { + s""" { + "runtimes": { + "nodejs": [{ + "kind": "${kind}", + "default": true, + "image": { + "prefix": "openwhisk", + "name": "action-nodejs-v10", + "tag": "nightly" + }, + "deprecated": false, + "attached": { + "attachmentName": "codefile", + "attachmentType": "text/plain" + }, + "stemCells": [{ + "count": ${count}, + "memory": "${memory} MB" + }] + }] + } + }""" + } + + val invokerProtocol = WhiskProperties.getInvokerProtocol + val invokerAddress = WhiskProperties.getBaseInvokerAddress + val invokerUsername = WhiskProperties.getInvokerUsername + val invokerPassword = WhiskProperties.getInvokerPassword + val invokerAuthHeader = Authorization(BasicHttpCredentials(invokerUsername, invokerPassword)) + + val controllerProtocol = WhiskProperties.getControllerProtocol + val controllerAddress = WhiskProperties.getBaseControllerAddress + val controllerUsername = WhiskProperties.getControllerUsername + val controllerPassword = WhiskProperties.getControllerPassword + val controllerAuthHeader = Authorization(BasicHttpCredentials(controllerUsername, controllerPassword)) + + val getRuntimeUrl = s"${invokerProtocol}://${invokerAddress}/getRuntime" + val invokerChangeRuntimeUrl = s"${invokerProtocol}://${invokerAddress}/config/runtime" + val controllerChangeRuntimeUrl = + s"${controllerProtocol}://${controllerAddress}/config/runtime" + + it should "change assigned invoker node's runtime config directly" in { + //Change config + Http() + .singleRequest( + HttpRequest( + method = HttpMethods.POST, + uri = s"${invokerChangeRuntimeUrl}", + headers = List(invokerAuthHeader), + entity = HttpEntity(ContentTypes.`text/plain(UTF-8)`, getRuntimes)), + connectionContext = HttpConnection.getContext(invokerProtocol)) + .map { response => + response.status shouldBe StatusCodes.OK + } + + Thread.sleep(5.seconds.toMillis) Review comment: why? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to 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
