executor and logging pkg

This commit is contained in:
Alex Dadgar
2017-07-21 12:14:54 -07:00
parent e7e6c6858a
commit d4e35815a1
5 changed files with 19 additions and 0 deletions

View File

@@ -60,6 +60,7 @@ func testExecutorContextWithChroot(t *testing.T) (*ExecutorContext, *allocdir.Al
}
func TestExecutor_IsolationAndConstraints(t *testing.T) {
t.Parallel()
testutil.ExecCompatible(t)
execCmd := ExecCommand{Cmd: "/bin/ls", Args: []string{"-F", "/", "/etc/"}}
@@ -139,6 +140,7 @@ ld.so.conf.d/`
}
func TestExecutor_ClientCleanup(t *testing.T) {
t.Parallel()
testutil.ExecCompatible(t)
ctx, allocDir := testExecutorContextWithChroot(t)

View File

@@ -63,6 +63,7 @@ func testExecutorContext(t *testing.T) (*ExecutorContext, *allocdir.AllocDir) {
}
func TestExecutor_Start_Invalid(t *testing.T) {
t.Parallel()
invalid := "/bin/foobar"
execCmd := ExecCommand{Cmd: invalid, Args: []string{"1"}}
ctx, allocDir := testExecutorContext(t)
@@ -79,6 +80,7 @@ func TestExecutor_Start_Invalid(t *testing.T) {
}
func TestExecutor_Start_Wait_Failure_Code(t *testing.T) {
t.Parallel()
execCmd := ExecCommand{Cmd: "/bin/sleep", Args: []string{"fail"}}
ctx, allocDir := testExecutorContext(t)
defer allocDir.Destroy()
@@ -106,6 +108,7 @@ func TestExecutor_Start_Wait_Failure_Code(t *testing.T) {
}
func TestExecutor_Start_Wait(t *testing.T) {
t.Parallel()
execCmd := ExecCommand{Cmd: "/bin/echo", Args: []string{"hello world"}}
ctx, allocDir := testExecutorContext(t)
defer allocDir.Destroy()
@@ -144,6 +147,7 @@ func TestExecutor_Start_Wait(t *testing.T) {
}
func TestExecutor_WaitExitSignal(t *testing.T) {
t.Parallel()
execCmd := ExecCommand{Cmd: "/bin/sleep", Args: []string{"10000"}}
ctx, allocDir := testExecutorContext(t)
defer allocDir.Destroy()
@@ -186,6 +190,7 @@ func TestExecutor_WaitExitSignal(t *testing.T) {
}
func TestExecutor_Start_Kill(t *testing.T) {
t.Parallel()
execCmd := ExecCommand{Cmd: "/bin/sleep", Args: []string{"10 && hello world"}}
ctx, allocDir := testExecutorContext(t)
defer allocDir.Destroy()
@@ -226,6 +231,7 @@ func TestExecutor_Start_Kill(t *testing.T) {
}
func TestExecutor_MakeExecutable(t *testing.T) {
t.Parallel()
// Create a temp file
f, err := ioutil.TempFile("", "")
if err != nil {
@@ -259,6 +265,7 @@ func TestExecutor_MakeExecutable(t *testing.T) {
}
func TestScanPids(t *testing.T) {
t.Parallel()
p1 := NewFakeProcess(2, 5)
p2 := NewFakeProcess(10, 2)
p3 := NewFakeProcess(15, 6)

View File

@@ -18,12 +18,14 @@ var (
)
func TestFileRotator_IncorrectPath(t *testing.T) {
t.Parallel()
if _, err := NewFileRotator("/foo", baseFileName, 10, 10, logger); err == nil {
t.Fatalf("expected error")
}
}
func TestFileRotator_CreateNewFile(t *testing.T) {
t.Parallel()
var path string
var err error
if path, err = ioutil.TempDir("", pathPrefix); err != nil {
@@ -42,6 +44,7 @@ func TestFileRotator_CreateNewFile(t *testing.T) {
}
func TestFileRotator_OpenLastFile(t *testing.T) {
t.Parallel()
var path string
var err error
if path, err = ioutil.TempDir("", pathPrefix); err != nil {
@@ -69,6 +72,7 @@ func TestFileRotator_OpenLastFile(t *testing.T) {
}
func TestFileRotator_WriteToCurrentFile(t *testing.T) {
t.Parallel()
var path string
var err error
if path, err = ioutil.TempDir("", pathPrefix); err != nil {
@@ -106,6 +110,7 @@ func TestFileRotator_WriteToCurrentFile(t *testing.T) {
}
func TestFileRotator_RotateFiles(t *testing.T) {
t.Parallel()
var path string
var err error
if path, err = ioutil.TempDir("", pathPrefix); err != nil {
@@ -164,6 +169,7 @@ func TestFileRotator_RotateFiles(t *testing.T) {
}
func TestFileRotator_WriteRemaining(t *testing.T) {
t.Parallel()
var path string
var err error
if path, err = ioutil.TempDir("", pathPrefix); err != nil {
@@ -243,6 +249,7 @@ func TestFileRotator_WriteRemaining(t *testing.T) {
}
func TestFileRotator_PurgeOldFiles(t *testing.T) {
t.Parallel()
var path string
var err error
if path, err = ioutil.TempDir("", pathPrefix); err != nil {

View File

@@ -12,6 +12,7 @@ import (
)
func TestLogParser_Priority(t *testing.T) {
t.Parallel()
line := []byte("<30>2016-02-10T10:16:43-08:00 d-thinkpad docker/e2a1e3ebd3a3[22950]: 1:C 10 Feb 18:16:43.391 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf")
d := NewDockerLogParser(log.New(os.Stdout, "", log.LstdFlags))
p, _, err := d.parsePriority(line)
@@ -30,6 +31,7 @@ func TestLogParser_Priority(t *testing.T) {
}
func TestLogParser_Priority_UnixFormatter(t *testing.T) {
t.Parallel()
line := []byte("<30>Feb 6, 10:16:43 docker/e2a1e3ebd3a3[22950]: 1:C 10 Feb 18:16:43.391 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf")
d := NewDockerLogParser(log.New(os.Stdout, "", log.LstdFlags))
p, _, err := d.parsePriority(line)

View File

@@ -10,6 +10,7 @@ import (
)
func TestSyslogServer_Start_Shutdown(t *testing.T) {
t.Parallel()
dir, err := ioutil.TempDir("", "sock")
if err != nil {
t.Fatalf("Failed to create temporary direcotry: %v", err)