|
13 | 13 | import tempfile |
14 | 14 | from typing import Dict |
15 | 15 |
|
| 16 | +from kubernetes import client, config |
16 | 17 | from test_framework.authproxy import AuthServiceProxy |
17 | 18 | from test_framework.p2p import NetworkThread |
18 | 19 | from test_framework.test_framework import ( |
|
23 | 24 | from test_framework.test_node import TestNode |
24 | 25 | from test_framework.util import PortSeed, get_rpc_proxy |
25 | 26 |
|
26 | | -WARNET_FILE = "/shared/warnet.json" |
27 | | - |
28 | 27 | # hard-coded deterministic lnd credentials |
29 | 28 | ADMIN_MACAROON_HEX = "0201036c6e6402f801030a1062beabbf2a614b112128afa0c0b4fdd61201301a160a0761646472657373120472656164120577726974651a130a04696e666f120472656164120577726974651a170a08696e766f69636573120472656164120577726974651a210a086d616361726f6f6e120867656e6572617465120472656164120577726974651a160a076d657373616765120472656164120577726974651a170a086f6666636861696e120472656164120577726974651a160a076f6e636861696e120472656164120577726974651a140a057065657273120472656164120577726974651a180a067369676e6572120867656e657261746512047265616400000620b17be53e367290871681055d0de15587f6d1cd47d1248fe2662ae27f62cfbdc6" |
30 | 29 | # Don't worry about lnd's self-signed certificates |
31 | 30 | INSECURE_CONTEXT = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) |
32 | 31 | INSECURE_CONTEXT.check_hostname = False |
33 | 32 | INSECURE_CONTEXT.verify_mode = ssl.CERT_NONE |
34 | 33 |
|
35 | | -try: |
36 | | - with open(WARNET_FILE) as file: |
37 | | - WARNET = json.load(file) |
38 | | -except Exception: |
39 | | - WARNET = [] |
| 34 | +# Figure out what namespace we are in |
| 35 | +with open("/var/run/secrets/kubernetes.io/serviceaccount/namespace") as f: |
| 36 | + NAMESPACE = f.read().strip() |
| 37 | + |
| 38 | +# Use the in-cluster k8s client to determine what pods we have access to |
| 39 | +config.load_incluster_config() |
| 40 | +sclient = client.CoreV1Api() |
| 41 | +pods = sclient.list_namespaced_pod(namespace=NAMESPACE) |
| 42 | + |
| 43 | +WARNET = [] |
| 44 | +for pod in pods.items: |
| 45 | + if "mission" not in pod.metadata.labels or pod.metadata.labels["mission"] != "tank": |
| 46 | + continue |
| 47 | + |
| 48 | + WARNET.append( |
| 49 | + { |
| 50 | + "tank": pod.metadata.name, |
| 51 | + "chain": pod.metadata.labels["chain"], |
| 52 | + "rpc_host": pod.status.pod_ip, |
| 53 | + "rpc_port": int(pod.metadata.labels["RPCPort"]), |
| 54 | + "rpc_user": "user", |
| 55 | + "rpc_password": pod.metadata.labels["rpcpassword"], |
| 56 | + } |
| 57 | + ) |
40 | 58 |
|
41 | 59 |
|
42 | 60 | # Ensure that all RPC calls are made with brand new http connections |
@@ -160,7 +178,6 @@ def setup(self): |
160 | 178 | coveragedir=self.options.coveragedir, |
161 | 179 | ) |
162 | 180 | node.rpc_connected = True |
163 | | - node.init_peers = tank["init_peers"] |
164 | 181 |
|
165 | 182 | # Tank might not even have an ln node, that's |
166 | 183 | # not our problem, it'll just 404 if scenario tries |
|
0 commit comments