mirror of https://github.com/kubernetes/kops.git
Include AuxConfig output in TestBootstrapUserData
This commit is contained in:
parent
9cba5e345d
commit
c3c1aca3c1
|
@ -44,11 +44,13 @@ func Test_InstanceGroupKubeletMerge(t *testing.T) {
|
||||||
instanceGroup.Spec.Kubelet.NvidiaGPUs = 1
|
instanceGroup.Spec.Kubelet.NvidiaGPUs = 1
|
||||||
instanceGroup.Spec.Role = kops.InstanceGroupRoleNode
|
instanceGroup.Spec.Role = kops.InstanceGroupRoleNode
|
||||||
|
|
||||||
|
config, auxConfig := nodeup.NewConfig(cluster, instanceGroup)
|
||||||
b := &KubeletBuilder{
|
b := &KubeletBuilder{
|
||||||
&NodeupModelContext{
|
&NodeupModelContext{
|
||||||
Cluster: cluster,
|
Cluster: cluster,
|
||||||
InstanceGroup: instanceGroup,
|
InstanceGroup: instanceGroup,
|
||||||
NodeupConfig: nodeup.NewConfig(cluster, instanceGroup),
|
NodeupConfig: config,
|
||||||
|
NodeupAuxConfig: auxConfig,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if err := b.Init(); err != nil {
|
if err := b.Init(); err != nil {
|
||||||
|
@ -89,11 +91,13 @@ func TestTaintsApplied(t *testing.T) {
|
||||||
cluster := &kops.Cluster{Spec: kops.ClusterSpec{KubernetesVersion: g.version}}
|
cluster := &kops.Cluster{Spec: kops.ClusterSpec{KubernetesVersion: g.version}}
|
||||||
ig := &kops.InstanceGroup{Spec: kops.InstanceGroupSpec{Role: kops.InstanceGroupRoleMaster, Taints: g.taints}}
|
ig := &kops.InstanceGroup{Spec: kops.InstanceGroupSpec{Role: kops.InstanceGroupRoleMaster, Taints: g.taints}}
|
||||||
|
|
||||||
|
config, auxConfig := nodeup.NewConfig(cluster, ig)
|
||||||
b := &KubeletBuilder{
|
b := &KubeletBuilder{
|
||||||
&NodeupModelContext{
|
&NodeupModelContext{
|
||||||
Cluster: cluster,
|
Cluster: cluster,
|
||||||
InstanceGroup: ig,
|
InstanceGroup: ig,
|
||||||
NodeupConfig: nodeup.NewConfig(cluster, ig),
|
NodeupConfig: config,
|
||||||
|
NodeupAuxConfig: auxConfig,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if err := b.Init(); err != nil {
|
if err := b.Init(); err != nil {
|
||||||
|
@ -239,7 +243,7 @@ func BuildNodeupModelContext(basedir string) (*NodeupModelContext, error) {
|
||||||
// We tolerate this - not all tests need an instance group
|
// We tolerate this - not all tests need an instance group
|
||||||
} else if len(model.InstanceGroups) == 1 {
|
} else if len(model.InstanceGroups) == 1 {
|
||||||
nodeUpModelContext.InstanceGroup = model.InstanceGroups[0]
|
nodeUpModelContext.InstanceGroup = model.InstanceGroups[0]
|
||||||
nodeUpModelContext.NodeupConfig = nodeup.NewConfig(model.Cluster, nodeUpModelContext.InstanceGroup)
|
nodeUpModelContext.NodeupConfig, nodeUpModelContext.NodeupAuxConfig = nodeup.NewConfig(model.Cluster, nodeUpModelContext.InstanceGroup)
|
||||||
} else {
|
} else {
|
||||||
return nil, fmt.Errorf("unexpected number of instance groups in %s, found %d", basedir, len(model.InstanceGroups))
|
return nil, fmt.Errorf("unexpected number of instance groups in %s, found %d", basedir, len(model.InstanceGroups))
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ type StaticManifest struct {
|
||||||
Path string `json:"path,omitempty"`
|
Path string `json:"path,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfig(cluster *kops.Cluster, instanceGroup *kops.InstanceGroup) *Config {
|
func NewConfig(cluster *kops.Cluster, instanceGroup *kops.InstanceGroup) (*Config, *AuxConfig) {
|
||||||
role := instanceGroup.Spec.Role
|
role := instanceGroup.Spec.Role
|
||||||
isMaster := role == kops.InstanceGroupRoleMaster
|
isMaster := role == kops.InstanceGroupRoleMaster
|
||||||
|
|
||||||
|
@ -144,5 +144,5 @@ func NewConfig(cluster *kops.Cluster, instanceGroup *kops.InstanceGroup) *Config
|
||||||
config.DefaultMachineType = fi.String(strings.Split(instanceGroup.Spec.MachineType, ",")[0])
|
config.DefaultMachineType = fi.String(strings.Split(instanceGroup.Spec.MachineType, ",")[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
return &config
|
return &config, &AuxConfig{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -64,61 +65,62 @@ type nodeupConfigBuilder struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *nodeupConfigBuilder) BuildConfig(ig *kops.InstanceGroup, apiserverAdditionalIPs []string, ca fi.Resource) (*nodeup.Config, *nodeup.AuxConfig, error) {
|
func (n *nodeupConfigBuilder) BuildConfig(ig *kops.InstanceGroup, apiserverAdditionalIPs []string, ca fi.Resource) (*nodeup.Config, *nodeup.AuxConfig, error) {
|
||||||
return nodeup.NewConfig(n.cluster, ig), &nodeup.AuxConfig{}, nil
|
config, auxConfig := nodeup.NewConfig(n.cluster, ig)
|
||||||
|
return config, auxConfig, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBootstrapUserData(t *testing.T) {
|
func TestBootstrapUserData(t *testing.T) {
|
||||||
cs := []struct {
|
cs := []struct {
|
||||||
Role kops.InstanceGroupRole
|
Role kops.InstanceGroupRole
|
||||||
ExpectedFilePath string
|
ExpectedFileIndex int
|
||||||
HookSpecRoles []kops.InstanceGroupRole
|
HookSpecRoles []kops.InstanceGroupRole
|
||||||
FileAssetSpecRoles []kops.InstanceGroupRole
|
FileAssetSpecRoles []kops.InstanceGroupRole
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Role: "Master",
|
Role: "Master",
|
||||||
ExpectedFilePath: "tests/data/bootstrapscript_0.txt",
|
ExpectedFileIndex: 0,
|
||||||
HookSpecRoles: []kops.InstanceGroupRole{""},
|
HookSpecRoles: []kops.InstanceGroupRole{""},
|
||||||
FileAssetSpecRoles: []kops.InstanceGroupRole{""},
|
FileAssetSpecRoles: []kops.InstanceGroupRole{""},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Role: "Master",
|
Role: "Master",
|
||||||
ExpectedFilePath: "tests/data/bootstrapscript_0.txt",
|
ExpectedFileIndex: 0,
|
||||||
HookSpecRoles: []kops.InstanceGroupRole{"Node"},
|
HookSpecRoles: []kops.InstanceGroupRole{"Node"},
|
||||||
FileAssetSpecRoles: []kops.InstanceGroupRole{"Node"},
|
FileAssetSpecRoles: []kops.InstanceGroupRole{"Node"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Role: "Master",
|
Role: "Master",
|
||||||
ExpectedFilePath: "tests/data/bootstrapscript_1.txt",
|
ExpectedFileIndex: 1,
|
||||||
HookSpecRoles: []kops.InstanceGroupRole{"Master"},
|
HookSpecRoles: []kops.InstanceGroupRole{"Master"},
|
||||||
FileAssetSpecRoles: []kops.InstanceGroupRole{"Master"},
|
FileAssetSpecRoles: []kops.InstanceGroupRole{"Master"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Role: "Master",
|
Role: "Master",
|
||||||
ExpectedFilePath: "tests/data/bootstrapscript_2.txt",
|
ExpectedFileIndex: 2,
|
||||||
HookSpecRoles: []kops.InstanceGroupRole{"Master", "Node"},
|
HookSpecRoles: []kops.InstanceGroupRole{"Master", "Node"},
|
||||||
FileAssetSpecRoles: []kops.InstanceGroupRole{"Master", "Node"},
|
FileAssetSpecRoles: []kops.InstanceGroupRole{"Master", "Node"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Role: "Node",
|
Role: "Node",
|
||||||
ExpectedFilePath: "tests/data/bootstrapscript_3.txt",
|
ExpectedFileIndex: 3,
|
||||||
HookSpecRoles: []kops.InstanceGroupRole{""},
|
HookSpecRoles: []kops.InstanceGroupRole{""},
|
||||||
FileAssetSpecRoles: []kops.InstanceGroupRole{""},
|
FileAssetSpecRoles: []kops.InstanceGroupRole{""},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Role: "Node",
|
Role: "Node",
|
||||||
ExpectedFilePath: "tests/data/bootstrapscript_4.txt",
|
ExpectedFileIndex: 4,
|
||||||
HookSpecRoles: []kops.InstanceGroupRole{"Node"},
|
HookSpecRoles: []kops.InstanceGroupRole{"Node"},
|
||||||
FileAssetSpecRoles: []kops.InstanceGroupRole{"Node"},
|
FileAssetSpecRoles: []kops.InstanceGroupRole{"Node"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Role: "Node",
|
Role: "Node",
|
||||||
ExpectedFilePath: "tests/data/bootstrapscript_3.txt",
|
ExpectedFileIndex: 3,
|
||||||
HookSpecRoles: []kops.InstanceGroupRole{"Master"},
|
HookSpecRoles: []kops.InstanceGroupRole{"Master"},
|
||||||
FileAssetSpecRoles: []kops.InstanceGroupRole{"Master"},
|
FileAssetSpecRoles: []kops.InstanceGroupRole{"Master"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Role: "Node",
|
Role: "Node",
|
||||||
ExpectedFilePath: "tests/data/bootstrapscript_5.txt",
|
ExpectedFileIndex: 5,
|
||||||
HookSpecRoles: []kops.InstanceGroupRole{"Master", "Node"},
|
HookSpecRoles: []kops.InstanceGroupRole{"Master", "Node"},
|
||||||
FileAssetSpecRoles: []kops.InstanceGroupRole{"Master", "Node"},
|
FileAssetSpecRoles: []kops.InstanceGroupRole{"Master", "Node"},
|
||||||
},
|
},
|
||||||
|
@ -168,7 +170,16 @@ func TestBootstrapUserData(t *testing.T) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
golden.AssertMatchesFile(t, actual, x.ExpectedFilePath)
|
golden.AssertMatchesFile(t, actual, fmt.Sprintf("tests/data/bootstrapscript_%d.txt", x.ExpectedFileIndex))
|
||||||
|
|
||||||
|
require.Contains(t, c.Tasks, "ManagedFile/auxconfig-testIG")
|
||||||
|
actual, err = fi.ResourceAsString(c.Tasks["ManagedFile/auxconfig-testIG"].(*fitasks.ManagedFile).Contents)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("case %d failed to render auxconfig resource. error: %s", i, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
golden.AssertMatchesFile(t, actual, fmt.Sprintf("tests/data/auxconfig_%d.txt", x.ExpectedFileIndex))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
{}
|
|
@ -0,0 +1 @@
|
||||||
|
{}
|
|
@ -0,0 +1 @@
|
||||||
|
{}
|
|
@ -0,0 +1 @@
|
||||||
|
{}
|
|
@ -0,0 +1 @@
|
||||||
|
{}
|
|
@ -0,0 +1 @@
|
||||||
|
{}
|
|
@ -1310,7 +1310,7 @@ func (n *nodeUpConfigBuilder) BuildConfig(ig *kops.InstanceGroup, apiserverAddit
|
||||||
useGossip := dns.IsGossipHostname(cluster.Spec.MasterInternalName)
|
useGossip := dns.IsGossipHostname(cluster.Spec.MasterInternalName)
|
||||||
isMaster := role == kops.InstanceGroupRoleMaster
|
isMaster := role == kops.InstanceGroupRoleMaster
|
||||||
|
|
||||||
config := nodeup.NewConfig(cluster, ig)
|
config, auxConfig := nodeup.NewConfig(cluster, ig)
|
||||||
config.Assets = make(map[architectures.Architecture][]string)
|
config.Assets = make(map[architectures.Architecture][]string)
|
||||||
for _, arch := range architectures.GetSupported() {
|
for _, arch := range architectures.GetSupported() {
|
||||||
config.Assets[arch] = []string{}
|
config.Assets[arch] = []string{}
|
||||||
|
@ -1386,5 +1386,5 @@ func (n *nodeUpConfigBuilder) BuildConfig(ig *kops.InstanceGroup, apiserverAddit
|
||||||
config.Channels = n.channels
|
config.Channels = n.channels
|
||||||
config.EtcdManifests = n.etcdManifests[role]
|
config.EtcdManifests = n.etcdManifests[role]
|
||||||
|
|
||||||
return config, &nodeup.AuxConfig{}, nil
|
return config, auxConfig, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue