def check_dns_function(): config = configuration.Config.load_from_project() workers = [node for node in config.nodes if node.kind == "worker"] if len(workers) < 1: command.fail("expected at least one worker node") worker = random.choice(workers) print("trying dns functionality test with", worker) container_command = "nslookup kubernetes.default.svc.hyades.local 172.28.0.2" server_command = [ "rkt", "run", "homeworld.mit.edu/debian", "--exec", "/bin/bash", "--", "-c", setup.escape_shell(container_command) ] results = subprocess.check_output([ "ssh", "root@%s.%s" % (worker.hostname, config.external_domain), "--" ] + server_command) last_line = results.replace(b"\r\n", b"\n").replace(b"\0", b'').strip().split(b"\n")[-1] if not last_line.endswith(b"Address: 172.28.0.1"): command.fail("unexpected last line: %s" % repr(last_line.decode())) print("dns-addon seems to work!")
def talk(): if not event.wait(25): command.fail( "timed out while waiting for IPv4 address of listener") address = found_address[0] if address is None: command.fail("no address was specified by listener") container_command = "ping -c 1 %s && echo 'PING RESULT SUCCESS' || echo 'PING RESULT FAIL'" % address server_command = [ "rkt", "run", "--net=rkt.kubernetes.io", "homeworld.mit.edu/debian", "--exec", "/bin/bash", "--", "-c", setup.escape_shell(container_command) ] results = subprocess.check_output([ "ssh", "root@%s.%s" % (worker_talker.hostname, config.external_domain), "--" ] + server_command) last_line = results.replace(b"\r\n", b"\n").replace( b"\0", b'').strip().split(b"\n")[-1] if b"PING RESULT FAIL" in last_line: command.fail( "was not able to ping the target container; is flannel working?" ) elif b"PING RESULT SUCCESS" not in last_line: command.fail("could not launch container to test flannel properly") return True
def check_aci_pull(): config = configuration.Config.load_from_project() workers = [node for node in config.nodes if node.kind == "worker"] if not workers: command.fail("expected nonzero number of worker nodes") worker = random.choice(workers) print("trying container pulling on: %s" % worker) container_command = "ping -c 1 8.8.8.8 && echo 'PING RESULT SUCCESS' || echo 'PING RESULT FAIL'" server_command = [ "rkt", "run", "--pull-policy=update", "homeworld.mit.edu/debian", "--exec", "/bin/bash", "--", "-c", setup.escape_shell(container_command) ] results = subprocess.check_output([ "ssh", "root@%s.%s" % (worker.hostname, config.external_domain), "--" ] + server_command) last_line = results.replace(b"\r\n", b"\n").replace(b"\0", b'').strip().split(b"\n")[-1] if b"PING RESULT FAIL" in last_line: if b"PING RESULT SUCCESS" in last_line: command.fail( "should not have seen both success and failure markers in last line" ) command.fail( "cluster network probably not up (could not ping 8.8.8.8)") elif b"PING RESULT SUCCESS" not in last_line: command.fail( "container does not seem to have launched properly; container launches are likely broken (line = %s)" % repr(last_line)) print("container seems to be launched, with the correct network!")
def listen(): try: container_command = "ip -o addr show dev eth0 to 172.18/16 primary && sleep 15" server_command = [ "rkt", "run", "--net=rkt.kubernetes.io", "homeworld.mit.edu/debian", "--", "-c", setup.escape_shell(container_command) ] cmd = [ "ssh", "root@%s.%s" % (worker_listener.hostname, config.external_domain), "--" ] + server_command with subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=1, universal_newlines=True) as process: stdout = process.stdout.readline() if "scope" not in stdout: command.fail( "could not find scope line in ip addr output (%s)" % repr(stdout)) parts = stdout.split(" ") if "inet" not in parts: command.fail( "could not find inet address in ip addr output") address = parts[parts.index("inet") + 1] if not address.endswith("/24"): command.fail( "expected address that ended in /24, not '%s'" % address) address = address[:-3] if address.count(".") != 3: command.fail("expected valid IPv4 address, not '%s'" % address) if not address.replace(".", "").isdigit(): command.fail("expected valid IPv4 address, not '%s'" % address) found_address[0] = address event.set() process.communicate(timeout=20) finally: event.set() return True