Split overlays into discrete functionality and test

- Closes #987

To make the overlays testable in isolation, and after discussion with
the TSC, removed host/time/source from overlay files.

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2024-07-15 16:27:49 -06:00
parent b150b6319e
commit 053dd9953a
109 changed files with 3581 additions and 232 deletions

View File

@@ -41,7 +41,6 @@ const Systemddir = "usr/lib/systemd/system"
const WWOverlaydir = "var/lib/warewulf/overlays"
const WWChrootdir = "var/lib/warewulf/chroots"
const WWProvisiondir = "srv/warewulf"
const WWClientdir = "warewulf"
// New creates a test environment in a temporary directory and configures
// Warewulf to use it.
@@ -78,7 +77,7 @@ func New(t *testing.T) (env *TestEnv) {
conf.Paths.WWOverlaydir = env.GetPath(WWOverlaydir)
conf.Paths.WWChrootdir = env.GetPath(WWChrootdir)
conf.Paths.WWProvisiondir = env.GetPath(WWProvisiondir)
conf.Paths.WWClientdir = env.GetPath(WWClientdir)
conf.Paths.WWClientdir = "/warewulf"
for _, confPath := range []string{
conf.Paths.Sysconfdir,
@@ -92,7 +91,6 @@ func New(t *testing.T) (env *TestEnv) {
conf.Paths.WWOverlaydir,
conf.Paths.WWChrootdir,
conf.Paths.WWProvisiondir,
conf.Paths.WWClientdir,
} {
env.MkdirAll(t, confPath)
}
@@ -133,6 +131,15 @@ func (env *TestEnv) WriteFile(t *testing.T, fileName string, content string) {
assert.NoError(t, err)
}
// ImportFile writes the contents of inputFileName to fileName,
// creating any necessary intermediate directories relative to the
// test environment.
func (env *TestEnv) ImportFile(t *testing.T, fileName string, inputFileName string) {
buffer, err := os.ReadFile(inputFileName)
assert.NoError(t, err)
env.WriteFile(t, fileName, string(buffer))
}
// ReadFile returns the content of fileName as converted to a
// string.
//