Skip to content

Commit

Permalink
tests/positive/general: add test for merging multiple base configs
Browse files Browse the repository at this point in the history
  • Loading branch information
sohankunkerkar committed Oct 26, 2020
1 parent 7857e5c commit ff970fa
Showing 1 changed file with 101 additions and 0 deletions.
101 changes: 101 additions & 0 deletions tests/positive/general/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,40 @@ func init() {
register.Register(register.PositiveTest, AppendConfigWithRemoteConfigData())
register.Register(register.PositiveTest, VersionOnlyConfig())
register.Register(register.PositiveTest, EmptyUserdata())
register.Register(register.PositiveTest, VerifyMergingOfMultipleBaseConfigs())
}

var (
baseConfig = []byte(`{
"ignition": { "version": "3.0.0" },
"storage": {
"files": [{
"path": "/foo/bar",
"contents": { "source": "data:,base%20config%0A" }
}]
}
}`)

baseConfig2 = []byte(`{
"ignition": { "version": "3.0.0" },
"storage": {
"files": [{
"path": "/foo/bar2",
"contents": { "source": "data:,base%20config2%0A" }
}]
}
}`)
platformConfig = []byte(`{
"ignition": { "version": "3.0.0" },
"storage": {
"files": [{
"path": "/foo/bar3",
"contents": { "source": "data:,platform%20config%0A" }
}]
}
}`)
)

func ReformatFilesystemAndWriteFile() types.Test {
name := "genernal.reformat.withfile"
in := types.GetBaseDisk()
Expand Down Expand Up @@ -706,3 +738,72 @@ func EmptyUserdata() types.Test {
ConfigShouldBeBad: true,
}
}

// VerifyMergingOfMultipleBaseConfigs checks if multiple
// base configs and/or platform configs are merged in the
// right order.
func VerifyMergingOfMultipleBaseConfigs() types.Test {
name := "merge.multiple.base.configs"
in := types.GetBaseDisk()
out := types.GetBaseDisk()
config := `{
"ignition": {"version": "$version"}
}`
configMinVersion := "3.0.0"
var systemFiles []types.File

systemFiles = append(systemFiles, types.File{
Node: types.Node{
Name: "40-base.ign",
Directory: "base.d",
},
Contents: string(baseConfig),
}, types.File{
Node: types.Node{
Name: "50-base2.ign",
Directory: "base.d",
},
Contents: string(baseConfig2),
}, types.File{
Node: types.Node{
Name: "10-plaform.ign",
Directory: "base.platform.d/file",
},
Contents: string(platformConfig),
})
out[0].Partitions.AddFiles("ROOT", []types.File{
{
Node: types.Node{
Name: "bar",
Directory: "foo",
},
Contents: "base config\n",
},
})
out[0].Partitions.AddFiles("ROOT", []types.File{
{
Node: types.Node{
Name: "bar2",
Directory: "foo",
},
Contents: "base config2\n",
},
})
out[0].Partitions.AddFiles("ROOT", []types.File{
{
Node: types.Node{
Name: "bar3",
Directory: "foo",
},
Contents: "platform config\n",
},
})
return types.Test{
Name: name,
In: in,
Out: out,
Config: config,
SystemDirFiles: systemFiles,
ConfigMinVersion: configMinVersion,
}
}

0 comments on commit ff970fa

Please sign in to comment.