This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 302
tests: added "fleetctl --tunnel" tests #1492
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ece468e
tests: added "fleetctl --tunnel" tests
kayrus ea415ad
fleetctl: fixed incorrect "[email protected]" behavior
kayrus 2e4317a
tests: updated ssh tests
kayrus 3367bc7
tests: removed previously declared FleetctlTunnel* functions
kayrus 2d184fa
tests: implemented insertBin function
kayrus 586eea8
tests: added handleEndpointFlag function
kayrus 51fba0b
tests: reimplemented "WriteFile"
kayrus 3f3daa2
tests: use loop to generate units' args slice
kayrus fd6b2f6
tests: a couple of tiny improvements
kayrus 84c80b4
fleetctl: renamed agentForwardingEnabled into authAgentReqSent
kayrus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[Service] | ||
ExecStart=/bin/bash -c "while true; do echo Hello, World %i!; sleep 1; done" |
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Copyright 2016 CoreOS, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package functional | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"strings" | ||
"syscall" | ||
"testing" | ||
|
||
"github.com/coreos/fleet/functional/platform" | ||
) | ||
|
||
// Start three units using ssh tunnel | ||
func TestTunnelScheduleBatchUnits(t *testing.T) { | ||
cluster, err := platform.NewNspawnCluster("smoke") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer cluster.Destroy() | ||
|
||
members, err := platform.CreateNClusterMembers(cluster, 3) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
m0 := members[0] | ||
_, err = cluster.WaitForNMachines(m0, 3) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
tmp, err := ioutil.TempFile(os.TempDir(), "known-hosts") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
tmp.Close() | ||
defer syscall.Unlink(tmp.Name()) | ||
|
||
khFile := tmp.Name() | ||
|
||
// Launch one unit | ||
if stdout, stderr, err := cluster.FleetctlWithInput(m0, "yes", | ||
fmt.Sprintf("--tunnel=%s", m0.IP()), | ||
"--strict-host-key-checking=true", | ||
fmt.Sprintf("--known-hosts-file=%s", khFile), | ||
"start", | ||
"fixtures/units/hello.service"); err != nil { | ||
t.Fatalf("Unable to submit one unit using ssh tunnel: \nstdout: %s\nstderr: %s\nerr: %v", stdout, stderr, err) | ||
} else if strings.Contains(stderr, "Error") { | ||
t.Fatalf("Failed to correctly submit unit using ssh tunnel: \nstdout: %s\nstderr: %s\nerr: %v", stdout, stderr, err) | ||
} | ||
|
||
// Combine all parameters and units in one args slice | ||
args := []string{ | ||
fmt.Sprintf("--tunnel=%s", m0.IP()), | ||
"--strict-host-key-checking=true", | ||
fmt.Sprintf("--known-hosts-file=%s", khFile), | ||
"start", | ||
} | ||
for i := 1; i <= 10; i++ { | ||
args = append(args, fmt.Sprintf("fixtures/units/hello@%d.service", i)) | ||
} | ||
|
||
// Launch a batch of units | ||
if stdout, stderr, err := cluster.Fleetctl(m0, args...); err != nil { | ||
t.Fatalf("Unable to submit batch of units using ssh tunnel: \nstdout: %s\nstderr: %s\nerr: %v", stdout, stderr, err) | ||
} else if strings.Contains(stderr, "Error") { | ||
t.Fatalf("Failed to correctly submit batch of units using ssh tunnel: \nstdout: %s\nstderr: %s\nerr: %v", stdout, stderr, err) | ||
} | ||
|
||
_, err = cluster.WaitForNActiveUnits(m0, 11) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -30,10 +30,14 @@ import ( | |
type SSHForwardingClient struct { | ||
agentForwarding bool | ||
*gossh.Client | ||
agentForwardingEnabled bool | ||
} | ||
|
||
func (s *SSHForwardingClient) ForwardAgentAuthentication(session *gossh.Session) error { | ||
if s.agentForwarding { | ||
if s.agentForwarding && !s.agentForwardingEnabled { | ||
// We are allowed to send "[email protected]" request only once per channel | ||
// otherwise ssh daemon replies with the "SSH2_MSG_CHANNEL_FAILURE 100" | ||
s.agentForwardingEnabled = true | ||
return gosshagent.RequestAgentForwarding(session) | ||
} | ||
return nil | ||
|
@@ -50,7 +54,7 @@ func newSSHForwardingClient(client *gossh.Client, agentForwarding bool) (*SSHFor | |
return nil, err | ||
} | ||
|
||
return &SSHForwardingClient{agentForwarding, client}, nil | ||
return &SSHForwardingClient{agentForwarding, client, false}, nil | ||
} | ||
|
||
// makeSession initializes a gossh.Session connected to the invoking process's stdout/stderr/stdout. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, one minor: could you please rename this to: authAgentReqSent or agentForwardingSent , but not Enabled, and also put some code comment: "Used to check if we have already sent the request to the ssh channel".