forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a basic unit test to verify the container-binary
Signed-off-by: Roman Mohr <[email protected]>
- Loading branch information
Showing
5 changed files
with
91 additions
and
9 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
13 changes: 13 additions & 0 deletions
13
cmd/container-disk-v2alpha/container_disk_v2alpha_suite_test.go
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,13 @@ | ||
package container_disk_v2alpha_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"testing" | ||
) | ||
|
||
func TestContainerDiskV2alpha(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "ContainerDiskV2alpha Suite") | ||
} |
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,42 @@ | ||
package container_disk_v2alpha_test | ||
|
||
import ( | ||
"flag" | ||
"io/ioutil" | ||
"net" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var containerDiskBinary string | ||
|
||
func init() { | ||
flag.StringVar(&containerDiskBinary, "container-disk-binary", "_out/cmd/container-disk-v2alpha/container-disk", "path to container disk binary") | ||
flag.Parse() | ||
containerDiskBinary = filepath.Join("../../", containerDiskBinary) | ||
} | ||
|
||
var _ = Describe("the containerDisk binary", func() { | ||
|
||
It("should be able to handle 200 connections in 5 seconds without rejecting one of them", func() { | ||
dir, err := ioutil.TempDir("", "container-disk") | ||
Expect(err).ToNot(HaveOccurred()) | ||
defer os.RemoveAll(dir) | ||
cmd := exec.Command(containerDiskBinary, "-c", filepath.Join(dir, "testsocket")) | ||
Expect(cmd.Start()).To(Succeed()) | ||
|
||
time.Sleep(1 * time.Second) | ||
for i := 0; i < 200; i++ { | ||
conn, err := net.Dial("unix", filepath.Join(dir, "testsocket.sock")) | ||
Expect(err).ToNot(HaveOccurred()) | ||
conn.Close() | ||
time.Sleep(25 * time.Millisecond) | ||
} | ||
Expect(cmd.Process.Kill()).To(Succeed()) | ||
}) | ||
}) |
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