mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-04-23 00:29:12 -04:00
fix tests
This commit is contained in:
parent
6215d8df41
commit
48f5f550cc
@ -149,6 +149,16 @@ func NextMinorVersion(version string) (string, error) {
|
||||
return fmt.Sprintf("v%d.%d", major, minor+1), nil
|
||||
}
|
||||
|
||||
// PriorMinorVersion returns the prior minor version for a given canonical semver.
|
||||
// The returned format is vMAJOR.MINOR.
|
||||
func PriorMinorVersion(version string) (string, error) {
|
||||
major, minor, err := parseCanonicalSemver(EnsurePrefixV(version))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return fmt.Sprintf("v%d.%d", major, minor-1), nil
|
||||
}
|
||||
|
||||
func parseCanonicalSemver(version string) (major int, minor int, err error) {
|
||||
version = semver.MajorMinor(version) // ensure version is in canonical form (vX.Y.Z)
|
||||
if version == "" {
|
||||
|
@ -85,13 +85,14 @@ go_test(
|
||||
],
|
||||
# keep
|
||||
x_defs = {
|
||||
"runsUnder": "bazel",
|
||||
"providerVersion": "{STABLE_STAMP_VERSION}",
|
||||
"runsUnder": "bazel",
|
||||
},
|
||||
deps = [
|
||||
"//internal/attestation/idkeydigest",
|
||||
"//internal/attestation/measurements",
|
||||
"//internal/attestation/variant",
|
||||
"//internal/compatibility",
|
||||
"//internal/config",
|
||||
"//internal/constants",
|
||||
"//internal/semver",
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/internal/compatibility"
|
||||
"github.com/edgelesssys/constellation/v2/internal/semver"
|
||||
"github.com/edgelesssys/constellation/v2/internal/versions"
|
||||
"github.com/edgelesssys/constellation/v2/terraform-provider-constellation/internal/data"
|
||||
@ -24,6 +25,7 @@ import (
|
||||
)
|
||||
|
||||
var providerVersion string
|
||||
|
||||
func TestMicroserviceConstraint(t *testing.T) {
|
||||
providerVersion := semver.NewFromInt(2, 15, 0, "")
|
||||
sut := &ClusterResource{
|
||||
@ -468,11 +470,17 @@ func fullClusterTestingConfig(t *testing.T, csp string) string {
|
||||
provider "constellation" {}
|
||||
`
|
||||
|
||||
// pick a compatible release image for the current development version
|
||||
priorMinor, err := compatibility.PriorMinorVersion(providerVersion)
|
||||
if err != nil {
|
||||
t.Fatal("get current provider version release", err)
|
||||
}
|
||||
image := fmt.Sprintf("%s.0", priorMinor)
|
||||
switch csp {
|
||||
case "aws":
|
||||
return providerConfig + `
|
||||
return providerConfig + fmt.Sprintf(`
|
||||
data "constellation_image" "bar" {
|
||||
version = "v2.14.0"
|
||||
version = "%s"
|
||||
attestation_variant = "aws-sev-snp"
|
||||
csp = "aws"
|
||||
region = "us-east-2"
|
||||
@ -482,11 +490,11 @@ func fullClusterTestingConfig(t *testing.T, csp string) string {
|
||||
csp = "aws"
|
||||
attestation_variant = "aws-sev-snp"
|
||||
image = data.constellation_image.bar.image
|
||||
}`
|
||||
}`, image)
|
||||
case "azure":
|
||||
return providerConfig + `
|
||||
return providerConfig + fmt.Sprintf(`
|
||||
data "constellation_image" "bar" {
|
||||
version = "v2.14.0"
|
||||
version = "%s"
|
||||
attestation_variant = "azure-sev-snp"
|
||||
csp = "azure"
|
||||
}
|
||||
@ -495,11 +503,11 @@ func fullClusterTestingConfig(t *testing.T, csp string) string {
|
||||
csp = "azure"
|
||||
attestation_variant = "azure-sev-snp"
|
||||
image = data.constellation_image.bar.image
|
||||
}`
|
||||
}`, image)
|
||||
case "gcp":
|
||||
return providerConfig + `
|
||||
return providerConfig + fmt.Sprintf(`
|
||||
data "constellation_image" "bar" {
|
||||
version = "v2.14.0"
|
||||
version = "%s"
|
||||
attestation_variant = "gcp-sev-es"
|
||||
csp = "gcp"
|
||||
}
|
||||
@ -508,7 +516,7 @@ func fullClusterTestingConfig(t *testing.T, csp string) string {
|
||||
csp = "gcp"
|
||||
attestation_variant = "gcp-sev-es"
|
||||
image = data.constellation_image.bar.image
|
||||
}`
|
||||
}`, image)
|
||||
default:
|
||||
t.Fatal("unknown csp")
|
||||
return ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user