Make config dir handling deterministic

This commit is contained in:
Justin Huff 2014-06-19 15:14:57 -07:00
parent d5bf045a6c
commit ecf7d11477
2 changed files with 6 additions and 3 deletions

View File

@ -27,6 +27,7 @@ import (
"os"
"os/exec"
"path/filepath"
"sort"
"strconv"
"strings"
"sync"
@ -394,6 +395,8 @@ func (kl *Kubelet) extractFromDir(name string) ([]api.ContainerManifest, error)
return manifests, err
}
sort.Strings(files)
for _, file := range files {
manifest, err := kl.extractFromFile(file)
if err != nil {

View File

@ -785,8 +785,8 @@ func TestExtractFromDir(t *testing.T) {
kubelet := Kubelet{}
manifests := []api.ContainerManifest{
{Id: "foo"},
{Id: "bar"},
{Id: "aaaa"},
{Id: "bbbb"},
}
dirName, err := ioutil.TempDir("", "foo")
@ -795,7 +795,7 @@ func TestExtractFromDir(t *testing.T) {
for _, manifest := range manifests {
data, err := json.Marshal(manifest)
expectNoError(t, err)
file, err := ioutil.TempFile(dirName, "kub")
file, err := ioutil.TempFile(dirName, manifest.Id)
expectNoError(t, err)
name := file.Name()
expectNoError(t, file.Close())