Beispiel #1
0
    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')
Beispiel #2
0
    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_expected = []
        node1_expected = {
            "externally_routable_ip": "127.0.0.3",
            "ssh_config": {
                "host": "worker3",
                "hostname": "127.0.0.3",
                "user": "******",
                "port": 2222,
                "password": "******",
                "identityfile": "/path/to/identfile3"
            }
        }
        nodes_expected.append(node1_expected)

        node2_expected = {
            "externally_routable_ip": "127.0.0.2",
            "ssh_config": {
                "host": "worker2",
                "hostname": "127.0.0.2",
                "user": "******",
                "port": 2223,
                "password": None,
                "identityfile": "/path/to/indentfile2"
            }
        }
        nodes_expected.append(node2_expected)

        cluster_json_expected = {}
        cluster_json_expected["nodes"] = nodes_expected
        json.dump(cluster_json_expected, open(self.cluster_file, 'w+'),
                  indent=2, separators=(',', ': '), sort_keys=True)

        # Load the cluster from the json file we just created
        cluster = VagrantCluster(cluster_file=self.cluster_file, is_type_based=False)

        assert len(cluster) == 2
        assert cluster.num_available_nodes() == 2
        node2, node3 = cluster.alloc(Service.setup_cluster_spec(num_nodes=2))

        assert node3.account.hostname == "worker2"
        assert node3.account.user == "vagrant"
        assert node3.account.ssh_hostname == '127.0.0.2'
        assert node3.account.ssh_config.to_json() == node2_expected["ssh_config"]

        assert node2.account.hostname == "worker3"
        assert node2.account.user == "vagrant"
        assert node2.account.ssh_hostname == '127.0.0.3'
        assert node2.account.ssh_config.to_json() == node1_expected["ssh_config"]
Beispiel #3
0
    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(is_type_based=False)
        assert len(cluster) == 2
        assert cluster.num_available_nodes() == 2
        node1, node2 = cluster.alloc(Service.setup_cluster_spec(num_nodes=2))

        assert node1.account.hostname == "worker1"
        assert node1.account.user == "vagrant"
        assert node1.account.ssh_hostname == '127.0.0.1'

        assert node2.account.hostname == "worker2"
        assert node2.account.user == "vagrant"
        assert node2.account.ssh_hostname == '127.0.0.2'
Beispiel #4
0
    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'
Beispiel #5
0
    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')
Beispiel #6
0
    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'