def check_one_host_parsing(self, monkeypatch): self._vagrant_ssh_data = self.two_hosts monkeypatch.setattr( "ducktape.cluster.vagrant.VagrantCluster._vagrant_ssh_config", lambda vc: (self._vagrant_ssh_data, None)) monkeypatch.setattr("ducktape.cluster.vagrant.VagrantCluster._is_aws", lambda vc: False) monkeypatch.setattr( "ducktape.cluster.vagrant.VagrantCluster._externally_routable_ip", lambda vc, is_aws, node_account: "127.0.0.1") cluster = VagrantCluster() assert (cluster.num_available_nodes() == 2) node1, node2 = cluster.request(2) assert (node1.account.hostname == "worker1") assert (node1.account.user == "vagrant") assert ( node1.account.ssh_args.strip() == "-o 'HostName 127.0.0.1' -o 'Port 2222' -o 'UserKnownHostsFile /dev/null' -o 'StrictHostKeyChecking no' -o 'PasswordAuthentication no' -o 'IdentityFile /Users/foo/ducktape.git/.vagrant/machines/worker1/virtualbox/private_key' -o 'IdentitiesOnly yes' -o 'LogLevel FATAL'" ) assert (node1.account.ssh_hostname == '127.0.0.1') assert (node2.account.hostname == "worker2") assert (node2.account.user == "vagrant") assert ( node2.account.ssh_args.strip() == "-o 'HostName 127.0.0.2' -o 'Port 2200' -o 'UserKnownHostsFile /dev/null' -o 'StrictHostKeyChecking no' -o 'PasswordAuthentication no' -o 'IdentityFile /Users/foo/ducktape.git/.vagrant/machines/worker2/virtualbox/private_key' -o 'IdentitiesOnly yes' -o 'LogLevel FATAL'" ) assert (node2.account.ssh_hostname == '127.0.0.2')
def check_cluster_file_read(self, monkeypatch): """check the behavior of VagrantCluster when cluster_file is specified and the file exists. VagrantCluster should read cluster information from cluster_file. """ self._set_monkeypatch_attr(monkeypatch) # To verify that VagrantCluster reads cluster information from the cluster_file, the # content in the file is intentionally made different from that returned by _vagrant_ssh_config(). nodes = [] nodes.append({ "hostname": "worker2", "ssh_hostname": "127.0.0.2", "user": "******", "ssh_args": "-o 'HostName 127.0.0.2' -o 'Port 2222' -o 'UserKnownHostsFile /dev/null' -o 'StrictHostKeyChecking no' -o 'PasswordAuthentication no' -o 'IdentityFile /Users/foo/ducktape.git/.vagrant/machines/worker2/virtualbox/private_key' -o 'IdentitiesOnly yes' -o 'LogLevel FATAL'", "externally_routable_ip": "127.0.0.2" }) nodes.append({ "hostname": "worker3", "ssh_hostname": "127.0.0.3", "user": "******", "ssh_args": "-o 'HostName 127.0.0.3' -o 'Port 2223' -o 'UserKnownHostsFile /dev/null' -o 'StrictHostKeyChecking no' -o 'PasswordAuthentication no' -o 'IdentityFile /Users/foo/ducktape.git/.vagrant/machines/worker3/virtualbox/private_key' -o 'IdentitiesOnly yes' -o 'LogLevel FATAL'", "externally_routable_ip": "127.0.0.3" }) cluster_json_expected = {} cluster_json_expected["nodes"] = nodes json.dump(cluster_json_expected, open(self.cluster_file, 'w+'), indent=2, separators=(',', ': '), sort_keys=True) cluster = VagrantCluster(cluster_file=self.cluster_file) os.remove(self.cluster_file) assert len(cluster) == 2 assert cluster.num_available_nodes() == 2 node1, node2 = cluster.request(2) assert node1.account.hostname == "worker2" assert node1.account.user == "vagrant" assert node1.account.ssh_args.strip() == "-o 'HostName 127.0.0.2' -o 'Port 2222' -o 'UserKnownHostsFile /dev/null' -o 'StrictHostKeyChecking no' -o 'PasswordAuthentication no' -o 'IdentityFile /Users/foo/ducktape.git/.vagrant/machines/worker2/virtualbox/private_key' -o 'IdentitiesOnly yes' -o 'LogLevel FATAL'" assert node1.account.ssh_hostname == '127.0.0.2' assert node2.account.hostname == "worker3" assert node2.account.user == "vagrant" assert node2.account.ssh_args.strip() == "-o 'HostName 127.0.0.3' -o 'Port 2223' -o 'UserKnownHostsFile /dev/null' -o 'StrictHostKeyChecking no' -o 'PasswordAuthentication no' -o 'IdentityFile /Users/foo/ducktape.git/.vagrant/machines/worker3/virtualbox/private_key' -o 'IdentitiesOnly yes' -o 'LogLevel FATAL'" assert node2.account.ssh_hostname == '127.0.0.3'
def check_one_host_parsing(self, monkeypatch): self._vagrant_ssh_data = self.two_hosts monkeypatch.setattr("ducktape.cluster.vagrant.VagrantCluster._vagrant_ssh_config", lambda vc: (self._vagrant_ssh_data, None)) monkeypatch.setattr("ducktape.cluster.vagrant.VagrantCluster._is_aws", lambda vc: False) monkeypatch.setattr("ducktape.cluster.vagrant.VagrantCluster._externally_routable_ip", lambda vc, is_aws, node_account: "127.0.0.1") cluster = VagrantCluster() assert(cluster.num_available_nodes() == 2) node1, node2 = cluster.request(2) assert(node1.account.hostname == "worker1") assert(node1.account.user == "vagrant") assert(node1.account.ssh_args.strip() == "-o 'HostName 127.0.0.1' -o 'Port 2222' -o 'UserKnownHostsFile /dev/null' -o 'StrictHostKeyChecking no' -o 'PasswordAuthentication no' -o 'IdentityFile /Users/foo/ducktape.git/.vagrant/machines/worker1/virtualbox/private_key' -o 'IdentitiesOnly yes' -o 'LogLevel FATAL'") assert(node1.account.ssh_hostname == '127.0.0.1') assert(node2.account.hostname == "worker2") assert(node2.account.user == "vagrant") assert(node2.account.ssh_args.strip() == "-o 'HostName 127.0.0.2' -o 'Port 2200' -o 'UserKnownHostsFile /dev/null' -o 'StrictHostKeyChecking no' -o 'PasswordAuthentication no' -o 'IdentityFile /Users/foo/ducktape.git/.vagrant/machines/worker2/virtualbox/private_key' -o 'IdentitiesOnly yes' -o 'LogLevel FATAL'") assert(node2.account.ssh_hostname == '127.0.0.2')
def check_one_host_parsing(self, monkeypatch): """check the behavior of VagrantCluster when cluster_file is not specified. VagrantCluster should read cluster information from _vagrant_ssh_config(). """ self._set_monkeypatch_attr(monkeypatch) cluster = VagrantCluster() assert len(cluster) == 2 assert cluster.num_available_nodes() == 2 node1, node2 = cluster.request(2) assert node1.account.hostname == "worker1" assert node1.account.user == "vagrant" assert node1.account.ssh_args.strip() == "-o 'HostName 127.0.0.1' -o 'Port 2222' -o 'UserKnownHostsFile /dev/null' -o 'StrictHostKeyChecking no' -o 'PasswordAuthentication no' -o 'IdentityFile /Users/foo/ducktape.git/.vagrant/machines/worker1/virtualbox/private_key' -o 'IdentitiesOnly yes' -o 'LogLevel FATAL'" assert node1.account.ssh_hostname == '127.0.0.1' assert node2.account.hostname == "worker2" assert node2.account.user == "vagrant" assert node2.account.ssh_args.strip() == "-o 'HostName 127.0.0.2' -o 'Port 2200' -o 'UserKnownHostsFile /dev/null' -o 'StrictHostKeyChecking no' -o 'PasswordAuthentication no' -o 'IdentityFile /Users/foo/ducktape.git/.vagrant/machines/worker2/virtualbox/private_key' -o 'IdentitiesOnly yes' -o 'LogLevel FATAL'" assert node2.account.ssh_hostname == '127.0.0.2'