various changes
This commit is contained in:
@@ -52,6 +52,7 @@ class K8sNodeInitDeployerTest extends Specification {
|
||||
spec.metadata.namespace == 'default'
|
||||
spec.spec.nodeName == 'node-a'
|
||||
spec.spec.restartPolicy == 'Never'
|
||||
spec.spec.hostNetwork == true
|
||||
|
||||
def container = spec.spec.containers[0]
|
||||
container.name == 'nf-init-node-a'
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package recreationaltech.plugin
|
||||
|
||||
import spock.lang.Specification
|
||||
|
||||
class K8sRuntimeEstimatorTest extends Specification {
|
||||
|
||||
def 'does extract a function' () {
|
||||
given:
|
||||
def observations = [a: [new Tuple2(0, 0), new Tuple2(100, 100)]]
|
||||
def estimator = new K8sRuntimeEstimator(observations)
|
||||
|
||||
when:
|
||||
def estimation = estimator.estimate("a", 1234)
|
||||
|
||||
then:
|
||||
estimation != Double.POSITIVE_INFINITY
|
||||
estimation == 1234.0
|
||||
}
|
||||
|
||||
def 'can extract a function from single measurement' () {
|
||||
given:
|
||||
def observations = [a: [new Tuple2(100, 100)]]
|
||||
def estimator = new K8sRuntimeEstimator(observations)
|
||||
|
||||
when:
|
||||
def estimation = estimator.estimate("a", 1234)
|
||||
|
||||
then:
|
||||
estimation == 100.0 /* Single measurement implies constant runtime */
|
||||
}
|
||||
|
||||
def 'unknown function returns positive infinity' () {
|
||||
given:
|
||||
def observations = [] as HashMap<String, ArrayList>
|
||||
def estimator = new K8sRuntimeEstimator(observations)
|
||||
|
||||
when:
|
||||
def estimation = estimator.estimate("b", 1234)
|
||||
|
||||
then:
|
||||
estimation == Double.POSITIVE_INFINITY
|
||||
}
|
||||
|
||||
def 'extracts function from multiple measurements' () {
|
||||
given:
|
||||
def observations = [a: [new Tuple2(10, 15), new Tuple2(20, 34), new Tuple2(30, 46)]]
|
||||
def estimator = new K8sRuntimeEstimator(observations)
|
||||
|
||||
when:
|
||||
def estimation = estimator.estimate("a", 40)
|
||||
|
||||
then:
|
||||
estimation != Double.POSITIVE_INFINITY
|
||||
}
|
||||
}
|
||||
@@ -1139,6 +1139,61 @@ class K8sClientTest extends Specification {
|
||||
result.metadata.name == 'test-node'
|
||||
}
|
||||
|
||||
def 'should get node external IP with ExternalIP address' () {
|
||||
given:
|
||||
def JSON = '''
|
||||
{
|
||||
"kind": "Node",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "test-node"
|
||||
},
|
||||
"status": {
|
||||
"addresses": [
|
||||
{"type": "InternalIP", "address": "192.168.1.100"},
|
||||
{"type": "ExternalIP", "address": "203.0.113.10"}
|
||||
]
|
||||
}
|
||||
}
|
||||
'''
|
||||
|
||||
def client = Spy(K8sClient)
|
||||
final NODE_NAME = 'test-node'
|
||||
|
||||
when:
|
||||
def result = client.getNodeExternalIp(NODE_NAME)
|
||||
then:
|
||||
1 * client.nodeDescribe(NODE_NAME) >> new K8sResponseJson(JSON)
|
||||
result == '203.0.113.10'
|
||||
}
|
||||
|
||||
def 'should get node external IP fallback to InternalIP' () {
|
||||
given:
|
||||
def JSON = '''
|
||||
{
|
||||
"kind": "Node",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "test-node"
|
||||
},
|
||||
"status": {
|
||||
"addresses": [
|
||||
{"type": "InternalIP", "address": "192.168.1.100"}
|
||||
]
|
||||
}
|
||||
}
|
||||
'''
|
||||
|
||||
def client = Spy(K8sClient)
|
||||
final NODE_NAME = 'test-node'
|
||||
|
||||
when:
|
||||
def result = client.getNodeExternalIp(NODE_NAME)
|
||||
then:
|
||||
1 * client.nodeDescribe(NODE_NAME) >> new K8sResponseJson(JSON)
|
||||
result == '192.168.1.100'
|
||||
}
|
||||
|
||||
def 'should get node CPU capacity' () {
|
||||
given:
|
||||
def JSON = '''
|
||||
|
||||
Reference in New Issue
Block a user