Skip to content

Instantly share code, notes, and snippets.

@ngotzmann
Created September 13, 2025 08:06
Show Gist options
  • Select an option

  • Save ngotzmann/e57a6bf0ee1e682dd6c4eae626aa7dff to your computer and use it in GitHub Desktop.

Select an option

Save ngotzmann/e57a6bf0ee1e682dd6c4eae626aa7dff to your computer and use it in GitHub Desktop.
function checkNodeConnection(config: any, ungroupedConfig: any) {
expect(config).to.not.be.null;
expect(ungroupedConfig).to.not.be.null;
config.hosts.forEach((h) => {
config.hosts.forEach((hostToPing) => {
validateHostCanPingHosts(
{
host: h.host_name as string,
port: ungroupedConfig.ssh_port as number,
user: ungroupedConfig.ssh_user as string,
sshKey: ungroupedConfig.ssh_key as string,
sshKeyPassphrase: ungroupedConfig.ssh_passphrase as string
} as SshConfig,
hostToPing.host_name
);
});
});
}
function validateHostCanPingHosts(config: SshConfig, hostToPing: string) {
const ssh = establishSSHConnection(config);
const result = ssh.run(
`ping -c 3 -W 3 ${hostToPing} >/dev/null 2>&1 && echo "success" || echo "failed"`
);
expect(result).to.include('success');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment