Recommended refactors
- make sure spec sets new cache dir - move clean out of api - capture warewulfconf.Paths.Cachedir+"/warewulf" in once place - split Clean() into multiple functions - remove WriteFileAbs Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
@@ -103,10 +103,10 @@ nodes:
|
||||
assert.NoError(t, dbErr)
|
||||
|
||||
conf.Warewulf.Secure = false
|
||||
assert.NoError(t, os.MkdirAll(path.Join(conf.Paths.WWProvisiondir, "overlays", "n1"), 0700))
|
||||
assert.NoError(t, os.WriteFile(path.Join(conf.Paths.WWProvisiondir, "overlays", "n1", "__SYSTEM__.img"), []byte("system overlay"), 0600))
|
||||
assert.NoError(t, os.WriteFile(path.Join(conf.Paths.WWProvisiondir, "overlays", "n1", "__RUNTIME__.img"), []byte("runtime overlay"), 0600))
|
||||
assert.NoError(t, os.WriteFile(path.Join(conf.Paths.WWProvisiondir, "overlays", "n1", "o1.img"), []byte("specific overlay"), 0600))
|
||||
assert.NoError(t, os.MkdirAll(path.Join(conf.Paths.OverlayProvisiondir(), "n1"), 0700))
|
||||
assert.NoError(t, os.WriteFile(path.Join(conf.Paths.OverlayProvisiondir(), "n1", "__SYSTEM__.img"), []byte("system overlay"), 0600))
|
||||
assert.NoError(t, os.WriteFile(path.Join(conf.Paths.OverlayProvisiondir(), "n1", "__RUNTIME__.img"), []byte("runtime overlay"), 0600))
|
||||
assert.NoError(t, os.WriteFile(path.Join(conf.Paths.OverlayProvisiondir(), "n1", "o1.img"), []byte("specific overlay"), 0600))
|
||||
|
||||
wwlog.SetLogLevel(wwlog.DEBUG)
|
||||
for _, tt := range provisionSendTests {
|
||||
|
||||
@@ -37,42 +37,42 @@ var getOverlayFileTests = []struct {
|
||||
node: "",
|
||||
context: "",
|
||||
overlays: []string{"o1", "o2"},
|
||||
result: "overlays/node1/o1-o2.img",
|
||||
result: "node1/o1-o2.img",
|
||||
},
|
||||
{
|
||||
description: "system overlay for a node points to the node's system overlay image",
|
||||
node: "node1",
|
||||
context: "system",
|
||||
overlays: []string{"o1"},
|
||||
result: "overlays/node1/__SYSTEM__.img",
|
||||
result: "node1/__SYSTEM__.img",
|
||||
},
|
||||
{
|
||||
description: "runtime overlay for a node points to the node's runtime overlay image",
|
||||
node: "node1",
|
||||
context: "runtime",
|
||||
overlays: nil,
|
||||
result: "overlays/node1/__RUNTIME__.img",
|
||||
result: "node1/__RUNTIME__.img",
|
||||
},
|
||||
{
|
||||
description: "a specific overlay for a node points to that specific overlay image for that node",
|
||||
node: "node1",
|
||||
context: "",
|
||||
overlays: []string{"o1"},
|
||||
result: "overlays/node1/o1.img",
|
||||
result: "node1/o1.img",
|
||||
},
|
||||
{
|
||||
description: "a specific set of overlays for a node points to a combined overlay image for that node",
|
||||
node: "node1",
|
||||
context: "",
|
||||
overlays: []string{"o1", "o2"},
|
||||
result: "overlays/node1/o1-o2.img",
|
||||
result: "node1/o1-o2.img",
|
||||
},
|
||||
{
|
||||
description: "a specific set of overlays for a node while also specifying a context points to the contextual overlay image for that node",
|
||||
node: "node1",
|
||||
context: "system",
|
||||
overlays: []string{"o1", "o2"},
|
||||
result: "overlays/node1/__SYSTEM__.img",
|
||||
result: "node1/__SYSTEM__.img",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ nodes:
|
||||
result, err := getOverlayFile(nodeInfo, tt.context, tt.overlays, false)
|
||||
assert.NoError(t, err)
|
||||
if tt.result != "" {
|
||||
tt.result = path.Join(conf.Paths.WWProvisiondir, tt.result)
|
||||
tt.result = path.Join(conf.Paths.OverlayProvisiondir(), tt.result)
|
||||
}
|
||||
assert.Equal(t, tt.result, result)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user