various changes
This commit is contained in:
@@ -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