-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SecComms: Fix flaky tests #2154
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,6 +208,9 @@ func TestPpssh(t *testing.T) { | |
} | ||
|
||
s := test.HttpServer("7105") | ||
if s == nil { | ||
t.Error("Failed - not create server") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
} | ||
|
||
clientSshPeer.Ready() | ||
clientSshPeer.Wait() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,18 +4,14 @@ import ( | |
"context" | ||
"crypto/rand" | ||
"crypto/rsa" | ||
"errors" | ||
"io/fs" | ||
"net" | ||
"sync" | ||
"testing" | ||
"time" | ||
|
||
"github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/pkg/podnetwork/tuntest" | ||
"github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/pkg/securecomms/sshutil" | ||
"github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/securecomms/test" | ||
"github.com/google/uuid" | ||
"github.com/vishvananda/netlink" | ||
"github.com/vishvananda/netns" | ||
"golang.org/x/crypto/ssh" | ||
) | ||
|
||
|
@@ -113,6 +109,9 @@ func TestSshProxy(t *testing.T) { | |
serverSshPeer.Ready() | ||
|
||
s := test.HttpServer("7020") | ||
if s == nil { | ||
t.Error("Failed - not create server") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, as it's in lots of places I think find and replace will be easier than me commenting everywhere. |
||
} | ||
success := test.HttpClient("http://127.0.0.1:7010") | ||
if !success { | ||
t.Error("Failed - not successful") | ||
|
@@ -136,32 +135,8 @@ func TestSshProxyWithNamespace(t *testing.T) { | |
|
||
clientSshPeer, serverSshPeer := getPeers(t) | ||
|
||
namespace := uuid.NewString() | ||
nsPath := "/run/netns/" + namespace | ||
// Create a new network namespace | ||
newns, err := netns.NewNamed(namespace) | ||
if err != nil && !errors.Is(err, fs.ErrExist) { | ||
if errors.Is(err, fs.ErrPermission) { | ||
t.Skip("Skip due to missing permissions - run privileged!") | ||
} | ||
t.Errorf("netns.NewNamed(%s) returned err %s", namespace, err.Error()) | ||
} | ||
defer func() { | ||
newns.Close() | ||
if err := netns.DeleteNamed(namespace); err != nil { | ||
t.Errorf("failed to delete a named network namespace %s: %v", namespace, err) | ||
} | ||
}() | ||
|
||
link, err := netlink.LinkByName("lo") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// bring the interface up | ||
if err := netlink.LinkSetUp(link); err != nil { | ||
t.Fatal(err) | ||
} | ||
ns, namespace := tuntest.NewNamedNS(t, "test-TestSshProxyWithNamespace") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these the right variable names as I assumed that |
||
defer tuntest.DeleteNamedNS(t, ns) | ||
|
||
outbounds := Outbounds{} | ||
if err := outbounds.AddTags([]string{"ATTESTATION_PHASE:ABC:127.0.0.1:7020", " "}); err != nil { | ||
|
@@ -182,7 +157,11 @@ func TestSshProxyWithNamespace(t *testing.T) { | |
serverSshPeer.Ready() | ||
|
||
s := test.HttpServer("7020") | ||
success := test.HttpClientInNamespace("http://127.0.0.1:7010", nsPath) | ||
if s == nil { | ||
t.Error("Failed - not create server") | ||
return | ||
} | ||
success := test.HttpClientInNamespace("http://127.0.0.1:7010", ns.Path()) | ||
if !success { | ||
t.Error("Failed - not successful") | ||
return | ||
|
@@ -225,6 +204,9 @@ func TestSshProxyReverse(t *testing.T) { | |
serverSshPeer.Ready() | ||
|
||
s := test.HttpServer("7001") | ||
if s == nil { | ||
t.Error("Failed - not create server") | ||
} | ||
success := test.HttpClient("http://127.0.0.1:7011") | ||
if !success { | ||
t.Error("Failed - not successful") | ||
|
@@ -264,6 +246,9 @@ func TestSshProxyReverseKBS(t *testing.T) { | |
serverSshPeer.Ready() | ||
|
||
s := test.HttpServer("7002") | ||
if s == nil { | ||
t.Error("Failed - not create server") | ||
} | ||
success := test.HttpClient("http://127.0.0.1:7012") | ||
if !success { | ||
t.Error("Failed - not successful") | ||
|
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.
Is this supposed to be
Failed - could not create server
?