@@ -179,6 +179,9 @@ func TestCheckpointRestore(t *testing.T) {
179179 t .Skip ("Checkpoint is not supported." )
180180 }
181181 dockerutil .EnsureDockerExperimentalEnabled ()
182+ if ! dockerutil .IsRestoreSupported () {
183+ t .Skip ("Restore is not supported." )
184+ }
182185
183186 ctx := context .Background ()
184187 d := dockerutil .MakeContainer (ctx , t )
@@ -1268,7 +1271,25 @@ func connectAndReadWrite(t *testing.T, serverIP string, port int) {
12681271 }
12691272}
12701273
1271- func testCheckpointRestoreTCPConnection (ctx context.Context , t * testing.T , d * dockerutil.Container , fName string , numConn int , restoreLoopback bool ) {
1274+ func testCheckpointRestoreTCPConnection (t * testing.T , netstackSR bool , fName string , numConn int , restoreLoopback bool ) {
1275+ if ! testutil .IsCheckpointSupported () {
1276+ t .Skip ("Checkpoint is not supported." )
1277+ }
1278+ dockerutil .EnsureDockerExperimentalEnabled ()
1279+ if ! dockerutil .IsRestoreSupported () {
1280+ t .Skip ("Restore is not supported." )
1281+ }
1282+
1283+ var d * dockerutil.Container
1284+ ctx := context .Background ()
1285+ if netstackSR {
1286+ if ! testutil .IsRunningWithSaveRestoreNetstack () {
1287+ t .Skip ("Netstack save restore is not supported." )
1288+ }
1289+ d = dockerutil .MakeContainerWithRuntime (ctx , t , "-save-restore-netstack" )
1290+ } else {
1291+ d = dockerutil .MakeContainer (ctx , t )
1292+ }
12721293 defer d .CleanUp (ctx )
12731294
12741295 opts := dockerutil.RunOpts {
@@ -1322,59 +1343,22 @@ func testCheckpointRestoreTCPConnection(ctx context.Context, t *testing.T, d *do
13221343
13231344// Test to check restore of a TCP listening connection without netstack S/R.
13241345func TestRestoreListenConn (t * testing.T ) {
1325- if ! testutil .IsCheckpointSupported () {
1326- t .Skip ("Checkpoint is not supported." )
1327- }
1328- dockerutil .EnsureDockerExperimentalEnabled ()
1329-
1330- ctx := context .Background ()
1331- d := dockerutil .MakeContainer (ctx , t )
1332- testCheckpointRestoreTCPConnection (ctx , t , d , "./tcp_server" /* fName */ , 1 /* numConn */ , false /* restoreLoopback */ )
1346+ testCheckpointRestoreTCPConnection (t , false /* netstackSR */ , "./tcp_server" /* fName */ , 1 /* numConn */ , false /* restoreLoopback */ )
13331347}
13341348
13351349// Test to check restore of a TCP listening connection with netstack S/R.
13361350func TestRestoreListenConnWithNetstackSR (t * testing.T ) {
1337- if ! testutil .IsCheckpointSupported () {
1338- t .Skip ("Checkpoint is not supported." )
1339- }
1340- if ! testutil .IsRunningWithSaveRestoreNetstack () {
1341- t .Skip ("Netstack save restore is not supported." )
1342- }
1343- dockerutil .EnsureDockerExperimentalEnabled ()
1344-
1345- ctx := context .Background ()
1346- d := dockerutil .MakeContainerWithRuntime (ctx , t , "-save-restore-netstack" )
1347- testCheckpointRestoreTCPConnection (ctx , t , d , "./tcp_server" /* fName */ , 1 /* numConn */ , false /* restoreLoopback */ )
1351+ testCheckpointRestoreTCPConnection (t , true /* netstackSR */ , "./tcp_server" /* fName */ , 1 /* numConn */ , false /* restoreLoopback */ )
13481352}
13491353
13501354// Test to check restore of multiple TCP listening connections with netstack S/R.
13511355func TestRestoreMultipleListenConnWithNetstackSR (t * testing.T ) {
1352- if ! testutil .IsCheckpointSupported () {
1353- t .Skip ("Checkpoint is not supported." )
1354- }
1355- if ! testutil .IsRunningWithSaveRestoreNetstack () {
1356- t .Skip ("Netstack save restore is not supported." )
1357- }
1358- dockerutil .EnsureDockerExperimentalEnabled ()
1359-
1360- ctx := context .Background ()
1361- d := dockerutil .MakeContainerWithRuntime (ctx , t , "-save-restore-netstack" )
1362- testCheckpointRestoreTCPConnection (ctx , t , d , "./tcp_stress_server" /* fName */ , 100 /* numConn */ , false /* restoreLoopback */ )
1356+ testCheckpointRestoreTCPConnection (t , true /* netstackSR */ , "./tcp_stress_server" /* fName */ , 100 /* numConn */ , false /* restoreLoopback */ )
13631357}
13641358
13651359// Test to check restore of TCP established loopback connection with netstack S/R.
13661360func TestRestoreLoopbackConnWithNetstackSR (t * testing.T ) {
1367- if ! testutil .IsCheckpointSupported () {
1368- t .Skip ("Checkpoint is not supported." )
1369- }
1370- if ! testutil .IsRunningWithSaveRestoreNetstack () {
1371- t .Skip ("Netstack save restore is not supported." )
1372- }
1373- dockerutil .EnsureDockerExperimentalEnabled ()
1374-
1375- ctx := context .Background ()
1376- d := dockerutil .MakeContainerWithRuntime (ctx , t , "-save-restore-netstack" )
1377- testCheckpointRestoreTCPConnection (ctx , t , d , "./tcp_loopback" /* fName */ , 1 /* numConn */ , true /* restoreLoopback */ )
1361+ testCheckpointRestoreTCPConnection (t , true /* netstackSR */ , "./tcp_loopback" /* fName */ , 1 /* numConn */ , true /* restoreLoopback */ )
13781362}
13791363
13801364// Test to check if sudo works
0 commit comments