Browse code

add test: fail to create container if mem limit < 512KB

unclejack authored on 2013/06/15 04:55:00
Showing 1 changed files
... ...
@@ -147,3 +147,25 @@ func TestCreateStartRestartStopStartKillRm(t *testing.T) {
147 147
 	}
148 148
 
149 149
 }
150
+
151
+func TestRunWithTooLowMemoryLimit(t *testing.T) {
152
+	runtime, err := newTestRuntime()
153
+	srv := &Server{runtime: runtime}
154
+	if err != nil {
155
+		t.Fatal(err)
156
+	}
157
+	defer nuke(runtime)
158
+	// Try to create a container with a memory limit of 1 byte less than the minimum allowed limit.
159
+	_, err = srv.ContainerCreate(
160
+		&Config{
161
+			Image:     GetTestImage(runtime).ID,
162
+			Memory:    524287,
163
+			CpuShares: 1000,
164
+			Cmd:       []string{"/bin/cat"},
165
+		},
166
+	)
167
+	if err == nil {
168
+		t.Errorf("Memory limit is smaller than the allowed limit. Container creation should've failed!")
169
+	}
170
+
171
+}