-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from grafana/undef1nd/ssh-logging
`Breaking change`: Change logging to enable parsing metrics from log lines
- Loading branch information
Showing
4 changed files
with
17 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,7 +146,7 @@ func TestClient_SSHArgs(t *testing.T) { | |
result, err := sshClient.SSHFlagsFromConfig() | ||
|
||
assert.Nil(t, err) | ||
assert.Equal(t, strings.Split(fmt.Sprintf("-i %s [email protected] -p 22 -R 0 -o CertificateFile=%s -o ConnectTimeout=1 -o ServerAliveInterval=15 -o TCPKeepAlive=no -o UserKnownHostsFile=%s -vv", cfg.KeyFile, cfg.KeyFile+certSuffix, path.Join(cfg.KeyFileDir(), ssh.KnownHostsFile)), " "), result) | ||
assert.Equal(t, strings.Split(fmt.Sprintf("-i %s [email protected] -p 22 -R 0 -o CertificateFile=%s -o ConnectTimeout=1 -o ServerAliveInterval=15 -o TCPKeepAlive=no -o UserKnownHostsFile=%s -vvv", cfg.KeyFile, cfg.KeyFile+certSuffix, path.Join(cfg.KeyFileDir(), ssh.KnownHostsFile)), " "), result) | ||
}) | ||
|
||
t.Run("legacy args (deprecated)", func(t *testing.T) { | ||
|
@@ -173,7 +173,6 @@ func TestClient_SSHArgs(t *testing.T) { | |
} | ||
|
||
cfg.SSHFlags = []string{ | ||
"-vvv", | ||
"-o TestOption=2", | ||
"-o PermitRemoteOpen=host:123 host:456", | ||
"-o ConnectTimeout=3", | ||
|
@@ -198,62 +197,12 @@ func TestClient_SSHArgs(t *testing.T) { | |
"-o", "TCPKeepAlive=no", | ||
"-o", "TestOption=2", | ||
"-o", fmt.Sprintf("UserKnownHostsFile=%s", path.Join(cfg.KeyFileDir(), ssh.KnownHostsFile)), | ||
"-vv", | ||
"-vvv", | ||
} | ||
assert.Equal(t, expected, result) | ||
|
||
}) | ||
|
||
t.Run("allow updating the log verbosity", func(t *testing.T) { | ||
cfg := ssh.DefaultConfig() | ||
cfg.LogLevel = 0 | ||
|
||
sshClient := newTestClient(t, cfg, false) | ||
result, err := sshClient.SSHFlagsFromConfig() | ||
|
||
assert.Nil(t, err) | ||
expected := []string{ | ||
"-i", | ||
cfg.KeyFile, | ||
"@localhost", | ||
"-p", | ||
"22", | ||
"-R", | ||
"0", | ||
"-o", fmt.Sprintf("CertificateFile=%s", cfg.KeyFile+certSuffix), | ||
"-o", "ConnectTimeout=1", | ||
"-o", "ServerAliveInterval=15", | ||
"-o", "TCPKeepAlive=no", | ||
"-o", fmt.Sprintf("UserKnownHostsFile=%s", path.Join(cfg.KeyFileDir(), ssh.KnownHostsFile)), | ||
} | ||
assert.Equal(t, expected, result) | ||
|
||
cfg.LogLevel = 2 | ||
|
||
sshClient = newTestClient(t, cfg, false) | ||
result, err = sshClient.SSHFlagsFromConfig() | ||
|
||
assert.Nil(t, err) | ||
expected = []string{ | ||
"-i", | ||
cfg.KeyFile, | ||
"@localhost", | ||
"-p", | ||
"22", | ||
"-R", | ||
"0", | ||
"-o", fmt.Sprintf("CertificateFile=%s", cfg.KeyFile+certSuffix), | ||
"-o", "ConnectTimeout=1", | ||
"-o", "ServerAliveInterval=15", | ||
"-o", "TCPKeepAlive=no", | ||
"-o", fmt.Sprintf("UserKnownHostsFile=%s", path.Join(cfg.KeyFileDir(), ssh.KnownHostsFile)), | ||
"-vv", | ||
} | ||
assert.Equal(t, expected, result) | ||
|
||
}) | ||
|
||
t.Run("errors on invalid option flag", func(t *testing.T) { | ||
cfg := ssh.DefaultConfig() | ||
|
||
|