mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-09-20 00:06:21 +00:00
config: update tests
This commit is contained in:
parent
b61deb6a03
commit
c0177c565f
@ -601,6 +601,8 @@ func (m *stubMerger) kubeconfigEnvVar() string {
|
|||||||
func defaultConfigWithExpectedMeasurements(t *testing.T, conf *config.Config, csp cloudprovider.Provider) *config.Config {
|
func defaultConfigWithExpectedMeasurements(t *testing.T, conf *config.Config, csp cloudprovider.Provider) *config.Config {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
|
conf.RemoveProviderAndAttestationExcept(csp)
|
||||||
|
|
||||||
conf.Image = constants.BinaryVersion().String()
|
conf.Image = constants.BinaryVersion().String()
|
||||||
conf.Name = "kubernetes"
|
conf.Name = "kubernetes"
|
||||||
|
|
||||||
|
@ -25,10 +25,12 @@ go_library(
|
|||||||
"//internal/attestation/variant",
|
"//internal/attestation/variant",
|
||||||
"//internal/cloud/cloudprovider",
|
"//internal/cloud/cloudprovider",
|
||||||
"//internal/compatibility",
|
"//internal/compatibility",
|
||||||
|
"//internal/config/disktypes",
|
||||||
"//internal/config/imageversion",
|
"//internal/config/imageversion",
|
||||||
"//internal/config/instancetypes",
|
"//internal/config/instancetypes",
|
||||||
"//internal/constants",
|
"//internal/constants",
|
||||||
"//internal/file",
|
"//internal/file",
|
||||||
|
"//internal/role",
|
||||||
"//internal/semver",
|
"//internal/semver",
|
||||||
"//internal/versions",
|
"//internal/versions",
|
||||||
"@com_github_go_playground_locales//en",
|
"@com_github_go_playground_locales//en",
|
||||||
|
@ -149,6 +149,24 @@ func modifyConfigForAzureToPassValidate(c *Config) {
|
|||||||
c.Attestation.AzureSEVSNP.Measurements = measurements.M{
|
c.Attestation.AzureSEVSNP.Measurements = measurements.M{
|
||||||
0: measurements.WithAllBytes(0x00, measurements.Enforce, measurements.PCRMeasurementLength),
|
0: measurements.WithAllBytes(0x00, measurements.Enforce, measurements.PCRMeasurementLength),
|
||||||
}
|
}
|
||||||
|
c.NodeGroups = map[string]NodeGroup{
|
||||||
|
constants.ControlPlaneDefault: {
|
||||||
|
Role: "control-plane",
|
||||||
|
Zone: "",
|
||||||
|
InstanceType: "Standard_DC4as_v5",
|
||||||
|
StateDiskSizeGB: 30,
|
||||||
|
StateDiskType: "StandardSSD_LRS",
|
||||||
|
InitialCount: 3,
|
||||||
|
},
|
||||||
|
constants.WorkerDefault: {
|
||||||
|
Role: "worker",
|
||||||
|
Zone: "",
|
||||||
|
InstanceType: "Standard_DC4as_v5",
|
||||||
|
StateDiskSizeGB: 30,
|
||||||
|
StateDiskType: "StandardSSD_LRS",
|
||||||
|
InitialCount: 3,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadConfigFile(t *testing.T) {
|
func TestReadConfigFile(t *testing.T) {
|
||||||
@ -233,11 +251,12 @@ func TestFromFile(t *testing.T) {
|
|||||||
},
|
},
|
||||||
"custom config from default file": {
|
"custom config from default file": {
|
||||||
config: &Config{
|
config: &Config{
|
||||||
Version: Version3,
|
Version: Version4,
|
||||||
},
|
},
|
||||||
configName: constants.ConfigFilename,
|
configName: constants.ConfigFilename,
|
||||||
wantResult: &Config{
|
wantResult: &Config{
|
||||||
Version: Version3,
|
Version: Version4,
|
||||||
|
NodeGroups: map[string]NodeGroup{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"modify default config": {
|
"modify default config": {
|
||||||
@ -280,10 +299,10 @@ func TestFromFile(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestValidate(t *testing.T) {
|
func TestValidate(t *testing.T) {
|
||||||
const defaultErrCount = 33 // expect this number of error messages by default because user-specific values are not set and multiple providers are defined by default
|
const defaultErrCount = 37 // expect this number of error messages by default because user-specific values are not set and multiple providers are defined by default
|
||||||
const azErrCount = 7
|
const azErrCount = 7
|
||||||
const awsErrCount = 6
|
const awsErrCount = 8
|
||||||
const gcpErrCount = 6
|
const gcpErrCount = 8
|
||||||
|
|
||||||
// TODO(AB#3132,3u13r): refactor config validation tests
|
// TODO(AB#3132,3u13r): refactor config validation tests
|
||||||
// Note that the `cnf.Image = ""` is a hack to align `bazel test` with `go test` behavior
|
// Note that the `cnf.Image = ""` is a hack to align `bazel test` with `go test` behavior
|
||||||
@ -337,12 +356,12 @@ func TestValidate(t *testing.T) {
|
|||||||
wantErr: true,
|
wantErr: true,
|
||||||
wantErrCount: defaultErrCount + 1,
|
wantErrCount: defaultErrCount + 1,
|
||||||
},
|
},
|
||||||
"v0 and negative state disk are two errors": {
|
"v0 and long name are two errors": {
|
||||||
cnf: func() *Config {
|
cnf: func() *Config {
|
||||||
cnf := Default()
|
cnf := Default()
|
||||||
cnf.Image = ""
|
cnf.Image = ""
|
||||||
cnf.Version = "v0"
|
cnf.Version = "v0"
|
||||||
cnf.StateDiskSizeGB = -1
|
cnf.Name = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||||
return cnf
|
return cnf
|
||||||
}(),
|
}(),
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
@ -374,6 +393,7 @@ func TestValidate(t *testing.T) {
|
|||||||
cnf.Attestation.AzureSEVSNP.Measurements = measurements.M{
|
cnf.Attestation.AzureSEVSNP.Measurements = measurements.M{
|
||||||
0: measurements.WithAllBytes(0x00, measurements.Enforce, measurements.PCRMeasurementLength),
|
0: measurements.WithAllBytes(0x00, measurements.Enforce, measurements.PCRMeasurementLength),
|
||||||
}
|
}
|
||||||
|
modifyConfigForAzureToPassValidate(cnf)
|
||||||
return cnf
|
return cnf
|
||||||
}(),
|
}(),
|
||||||
},
|
},
|
||||||
@ -395,7 +415,7 @@ func TestValidate(t *testing.T) {
|
|||||||
return cnf
|
return cnf
|
||||||
}(),
|
}(),
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
wantErrCount: awsErrCount - 2,
|
wantErrCount: awsErrCount - 4,
|
||||||
},
|
},
|
||||||
"AWS config with wrong region and zone format": {
|
"AWS config with wrong region and zone format": {
|
||||||
cnf: func() *Config {
|
cnf: func() *Config {
|
||||||
@ -434,6 +454,24 @@ func TestValidate(t *testing.T) {
|
|||||||
cnf.Attestation.GCPSEVES.Measurements = measurements.M{
|
cnf.Attestation.GCPSEVES.Measurements = measurements.M{
|
||||||
0: measurements.WithAllBytes(0x00, measurements.Enforce, measurements.PCRMeasurementLength),
|
0: measurements.WithAllBytes(0x00, measurements.Enforce, measurements.PCRMeasurementLength),
|
||||||
}
|
}
|
||||||
|
cnf.NodeGroups = map[string]NodeGroup{
|
||||||
|
constants.ControlPlaneDefault: {
|
||||||
|
Role: "control-plane",
|
||||||
|
Zone: "europe-west1-b",
|
||||||
|
InstanceType: "n2d-standard-4",
|
||||||
|
StateDiskSizeGB: 30,
|
||||||
|
StateDiskType: "pd-ssd",
|
||||||
|
InitialCount: 3,
|
||||||
|
},
|
||||||
|
constants.WorkerDefault: {
|
||||||
|
Role: "worker",
|
||||||
|
Zone: "europe-west1-b",
|
||||||
|
InstanceType: "n2d-standard-4",
|
||||||
|
StateDiskSizeGB: 30,
|
||||||
|
StateDiskType: "pd-ssd",
|
||||||
|
InitialCount: 3,
|
||||||
|
},
|
||||||
|
}
|
||||||
return cnf
|
return cnf
|
||||||
}(),
|
}(),
|
||||||
},
|
},
|
||||||
@ -889,7 +927,7 @@ func TestValidateProvider(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestConfigVersionCompatibility(t *testing.T) {
|
func TestConfigVersionCompatibility(t *testing.T) {
|
||||||
t.Skip() // TODO(daniel-weisse): re-enable and re-write for config v3
|
t.Skip() // TODO(daniel-weisse): re-enable and re-write for config v4
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
config string
|
config string
|
||||||
expectedConfig *Config
|
expectedConfig *Config
|
||||||
@ -899,7 +937,6 @@ func TestConfigVersionCompatibility(t *testing.T) {
|
|||||||
expectedConfig: &Config{
|
expectedConfig: &Config{
|
||||||
Version: "v2",
|
Version: "v2",
|
||||||
Image: "v2.5.0",
|
Image: "v2.5.0",
|
||||||
StateDiskSizeGB: 16,
|
|
||||||
KubernetesVersion: "1.23",
|
KubernetesVersion: "1.23",
|
||||||
DebugCluster: toPtr(false),
|
DebugCluster: toPtr(false),
|
||||||
Provider: ProviderConfig{
|
Provider: ProviderConfig{
|
||||||
@ -908,8 +945,6 @@ func TestConfigVersionCompatibility(t *testing.T) {
|
|||||||
Region: "europe-west3",
|
Region: "europe-west3",
|
||||||
Zone: "europe-west3-b",
|
Zone: "europe-west3-b",
|
||||||
ServiceAccountKeyPath: "serviceAccountKey.json",
|
ServiceAccountKeyPath: "serviceAccountKey.json",
|
||||||
InstanceType: "n2d-standard-4",
|
|
||||||
StateDiskType: "pd-ssd",
|
|
||||||
DeployCSIDriver: toPtr(true),
|
DeployCSIDriver: toPtr(true),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -920,15 +955,12 @@ func TestConfigVersionCompatibility(t *testing.T) {
|
|||||||
expectedConfig: &Config{
|
expectedConfig: &Config{
|
||||||
Version: "v2",
|
Version: "v2",
|
||||||
Image: "v2.5.0",
|
Image: "v2.5.0",
|
||||||
StateDiskSizeGB: 16,
|
|
||||||
KubernetesVersion: "1.23",
|
KubernetesVersion: "1.23",
|
||||||
DebugCluster: toPtr(false),
|
DebugCluster: toPtr(false),
|
||||||
Provider: ProviderConfig{
|
Provider: ProviderConfig{
|
||||||
AWS: &AWSConfig{
|
AWS: &AWSConfig{
|
||||||
Region: "us-east-2",
|
Region: "us-east-2",
|
||||||
Zone: "us-east-2a",
|
Zone: "us-east-2a",
|
||||||
InstanceType: "c5.xlarge",
|
|
||||||
StateDiskType: "gp2",
|
|
||||||
IAMProfileControlPlane: "control_plane_instance_profile",
|
IAMProfileControlPlane: "control_plane_instance_profile",
|
||||||
IAMProfileWorkerNodes: "node_instance_profile",
|
IAMProfileWorkerNodes: "node_instance_profile",
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user