Browse code

Add test for keeping same daemon ID on upgrade

Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit f923321aae7a961e94c00207cc80e51d410c676d)
Signed-off-by: Tibor Vass <tibor@docker.com>

Tibor Vass authored on 2019/06/15 13:59:07
Showing 2 changed files
... ...
@@ -63,6 +63,8 @@ var flatOptions = map[string]bool{
63 63
 var skipValidateOptions = map[string]bool{
64 64
 	"features": true,
65 65
 	"builder":  true,
66
+	// Corresponding flag has been removed because it was already unusable
67
+	"deprecated-key-path": true,
66 68
 }
67 69
 
68 70
 // skipDuplicates contains configuration keys that
... ...
@@ -4,6 +4,8 @@ import (
4 4
 	"bytes"
5 5
 	"context"
6 6
 	"encoding/json"
7
+	"io/ioutil"
8
+	"path/filepath"
7 9
 	"sort"
8 10
 	"testing"
9 11
 	"time"
... ...
@@ -13,6 +15,7 @@ import (
13 13
 	swarmtypes "github.com/docker/docker/api/types/swarm"
14 14
 	"github.com/docker/docker/client"
15 15
 	"github.com/docker/docker/integration/internal/swarm"
16
+	"github.com/docker/docker/internal/test/daemon"
16 17
 	"github.com/docker/docker/pkg/stdcopy"
17 18
 	"gotest.tools/assert"
18 19
 	is "gotest.tools/assert/cmp"
... ...
@@ -417,6 +420,26 @@ func TestConfigCreateResolve(t *testing.T) {
417 417
 	assert.Assert(t, is.Equal(0, len(entries)))
418 418
 }
419 419
 
420
+func TestConfigDaemonLibtrustID(t *testing.T) {
421
+	skip.If(t, testEnv.DaemonInfo.OSType != "linux")
422
+	defer setupTest(t)()
423
+
424
+	d := daemon.New(t)
425
+	defer d.Stop(t)
426
+
427
+	trustKey := filepath.Join(d.RootDir(), "key.json")
428
+	err := ioutil.WriteFile(trustKey, []byte(`{"crv":"P-256","d":"dm28PH4Z4EbyUN8L0bPonAciAQa1QJmmyYd876mnypY","kid":"WTJ3:YSIP:CE2E:G6KJ:PSBD:YX2Y:WEYD:M64G:NU2V:XPZV:H2CR:VLUB","kty":"EC","x":"Mh5-JINSjaa_EZdXDttri255Z5fbCEOTQIZjAcScFTk","y":"eUyuAjfxevb07hCCpvi4Zi334Dy4GDWQvEToGEX4exQ"}`), 0644)
429
+	assert.NilError(t, err)
430
+
431
+	config := filepath.Join(d.RootDir(), "daemon.json")
432
+	err = ioutil.WriteFile(config, []byte(`{"deprecated-key-path": "`+trustKey+`"}`), 0644)
433
+	assert.NilError(t, err)
434
+
435
+	d.Start(t, "--config-file", config)
436
+	info := d.Info(t)
437
+	assert.Equal(t, info.ID, "WTJ3:YSIP:CE2E:G6KJ:PSBD:YX2Y:WEYD:M64G:NU2V:XPZV:H2CR:VLUB")
438
+}
439
+
420 440
 func configNamesFromList(entries []swarmtypes.Config) []string {
421 441
 	var values []string
422 442
 	for _, entry := range entries {