@@ -24,12 +24,15 @@ import akka.http.scaladsl.unmarshalling.Unmarshal
24
24
import akka .stream .ActorMaterializer
25
25
import common ._
26
26
import common .rest .HttpConnection
27
+ import org .apache .openwhisk .common .ControllerCredentials
27
28
import org .apache .openwhisk .core .connector .PrewarmContainerDataList
28
29
import org .apache .openwhisk .core .connector .PrewarmContainerDataProtocol ._
29
30
import org .junit .runner .RunWith
30
31
import org .scalatest .Matchers
31
32
import org .scalatest .concurrent .ScalaFutures
32
33
import org .scalatest .junit .JUnitRunner
34
+ import pureconfig .loadConfigOrThrow
35
+ import pureconfig .generic .auto ._
33
36
import spray .json ._
34
37
import system .rest .RestUtil
35
38
@@ -76,56 +79,21 @@ class RuntimeConfigurationTests
76
79
} """
77
80
}
78
81
79
- val invokerProtocol = WhiskProperties .getInvokerProtocol
82
+ val invokerProtocol = loadConfigOrThrow[ String ]( " whisk.invoker.protocol " )
80
83
val invokerAddress = WhiskProperties .getBaseInvokerAddress
81
- val invokerUsername = WhiskProperties .getInvokerUsername
82
- val invokerPassword = WhiskProperties .getInvokerPassword
83
- val invokerAuthHeader = Authorization (BasicHttpCredentials (invokerUsername, invokerPassword))
84
84
85
- val controllerProtocol = WhiskProperties .getControllerProtocol
85
+ val controllerProtocol = loadConfigOrThrow[ String ]( " whisk.controller.protocol " )
86
86
val controllerAddress = WhiskProperties .getBaseControllerAddress
87
- val controllerUsername = WhiskProperties .getControllerUsername
88
- val controllerPassword = WhiskProperties .getControllerPassword
89
- val controllerAuthHeader = Authorization ( BasicHttpCredentials (controllerUsername, controllerPassword ))
87
+ val controllerCredentials = loadConfigOrThrow[ ControllerCredentials ]( " whisk.credentials.controller " )
88
+ val controllerAuthHeader = Authorization (
89
+ BasicHttpCredentials (controllerCredentials.username, controllerCredentials.password ))
90
90
91
91
val getRuntimeUrl = s " ${invokerProtocol}:// ${invokerAddress}/getRuntime "
92
92
val invokerChangeRuntimeUrl = s " ${invokerProtocol}:// ${invokerAddress}/config/runtime "
93
93
val controllerChangeRuntimeUrl =
94
94
s " ${controllerProtocol}:// ${controllerAddress}/config/runtime "
95
95
96
- it should " change assigned invoker node's runtime config directly" in {
97
- // Change config
98
- Http ()
99
- .singleRequest(
100
- HttpRequest (
101
- method = HttpMethods .POST ,
102
- uri = s " ${invokerChangeRuntimeUrl}" ,
103
- headers = List (invokerAuthHeader),
104
- entity = HttpEntity (ContentTypes .`text/plain(UTF-8)`, getRuntimes)),
105
- connectionContext = HttpConnection .getContext(invokerProtocol))
106
- .map { response =>
107
- response.status shouldBe StatusCodes .OK
108
- }
109
-
110
- Thread .sleep(5 .seconds.toMillis)
111
-
112
- // Cal the prewarm container number whether right
113
- Http ()
114
- .singleRequest(
115
- HttpRequest (method = HttpMethods .GET , uri = s " ${getRuntimeUrl}" , headers = List (invokerAuthHeader)),
116
- connectionContext = HttpConnection .getContext(invokerProtocol))
117
- .map { response =>
118
- response.status shouldBe StatusCodes .OK
119
- val prewarmContainerDataList =
120
- Unmarshal (response).to[String ].futureValue.parseJson.convertTo[PrewarmContainerDataList ]
121
- val nodejs10ContainerData = prewarmContainerDataList.items.filter { prewarmContainerData =>
122
- prewarmContainerData.kind == kind && prewarmContainerData.memory == memory
123
- }
124
- nodejs10ContainerData.head.number shouldBe count
125
- }
126
- }
127
-
128
- it should " change all managed invokers's prewarm config via controller" in {
96
+ it should " change all managed invokers's prewarm config" in {
129
97
// Change runtime config
130
98
Http ()
131
99
.singleRequest(
@@ -136,15 +104,16 @@ class RuntimeConfigurationTests
136
104
entity = HttpEntity (ContentTypes .`text/plain(UTF-8)`, getRuntimes)),
137
105
connectionContext = HttpConnection .getContext(controllerProtocol))
138
106
.map { response =>
139
- response.status shouldBe StatusCodes .OK
107
+ response.status shouldBe StatusCodes .Accepted
140
108
}
141
109
110
+ // Make sure previous http post call successfully
142
111
Thread .sleep(5 .seconds.toMillis)
143
112
144
113
// Cal the prewarm container number whether right
145
114
Http ()
146
115
.singleRequest(
147
- HttpRequest (method = HttpMethods .GET , uri = s " ${getRuntimeUrl}" , headers = List (invokerAuthHeader) ),
116
+ HttpRequest (method = HttpMethods .GET , uri = s " ${getRuntimeUrl}" ),
148
117
connectionContext = HttpConnection .getContext(invokerProtocol))
149
118
.map { response =>
150
119
response.status shouldBe StatusCodes .OK
0 commit comments