Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing testrunner defined metadata to the testrun as annotation #248

Merged
merged 1 commit into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 43 additions & 27 deletions pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,64 +19,80 @@ const (
// AnnotationResumeTestrun is the annotation name to trigger resume on the testrun
AnnotationResumeTestrun = "testmachinery.sapcloud.io/resume"

// AnnotationSystemStep is the testflow step annotation to specify that the step is a testmachinery system step.
// It indicates that it should not be considered as a test and therefore should not count for a test to be failed.
AnnotationSystemStep = "testmachinery.sapcloud.io/system-step"

// AnnotationTestDefName is the name of origin TestDefinition.
AnnotationTestDefName = "testmachinery.sapcloud.io/TestDefinition"

// AnnotationTestDefID is the unique name of origin TestDefinition in a specific flow and step.
AnnotationTestDefID = "testmachinery.sapcloud.io/ID"

// LabelTMDashboardIngress is the label to identify TestMachinery ingress objects.
LabelTMDashboardIngress = "testmachinery.garden.cloud/tm-dashboard"
)

// Metadata Annotations
const (

// AnnotationTestrunPurpose is the annotation name to specify a purpose of the testrun
AnnotationTestrunPurpose = "testmachinery.sapcloud.io/purpose"

// AnnotationTemplateIDTestrun is the annotation to specify the name of the template the testun is rendered from
AnnotationTemplateIDTestrun = "testrunner.testmachinery.sapcloud.io/templateID"
// AnnotationTemplateIDTestrun is the annotation to specify the name of the template the testrun is rendered from
AnnotationTemplateIDTestrun = "testrunner.testmachinery.gardener.cloud/templateID"

// AnnotationRetries is the annotation to specify the retry count of the current testrun
AnnotationRetries = "testrunner.testmachinery.gardener.cloud/retries"

// AnnotationLandscape is the annotation to specify the landscape this testrun is testing
AnnotationLandscape = "testrunner.testmachinery.sapcloud.io/landscape"
AnnotationLandscape = "metadata.testmachinery.gardener.cloud/landscape"

// AnnotationK8sVersion is the annotation to specify the k8s version the testrun is testing
AnnotationK8sVersion = "testrunner.testmachinery.sapcloud.io/k8sVersion"
AnnotationK8sVersion = "metadata.testmachinery.gardener.cloud/k8sVersion"

// AnnotationCloudProvider is the annotation to specify the cloudprovider the testrun is testing
AnnotationCloudProvider = "testrunner.testmachinery.sapcloud.io/cloudprovider"
AnnotationCloudProvider = "metadata.testmachinery.gardener.cloud/cloudprovider"

// AnnotationOperatingSystem is the annotation to specify the operating system of the shoot nodes the testrun is testing
AnnotationOperatingSystem = "testrunner.testmachinery.sapcloud.io/operating-system"
AnnotationOperatingSystem = "metadata.testmachinery.gardener.cloud/operating-system"

// AnnotationRegion is the annotation to specify the region of the shoot the testrun is testing
AnnotationRegion = "metadata.testmachinery.gardener.cloud/region"

// AnnotationZone is the annotation to specify the zone of the shoot the testrun is testing
AnnotationZone = "metadata.testmachinery.gardener.cloud/zone"

// AnnotationFlavorDescription is the annotation to describe the test flavor of the current run testrun
AnnotationFlavorDescription = "testrunner.testmachinery.sapcloud.io/flavor-description"
AnnotationFlavorDescription = "metadata.testmachinery.gardener.cloud/flavor-description"

// AnnotationDimension is the annotation to specify the dimension the testrun is testing
AnnotationDimension = "testrunner.testmachinery.sapcloud.io/dimension"
AnnotationDimension = "metadata.testmachinery.gardener.cloud/dimension"

// AnnotationGroupPurpose is the annotation to describe a run group with an arbitrary string
AnnotationGroupPurpose = "testrunner.testmachinery.sapcloud.io/group-purpose"

// AnnotationSystemStep is the testflow step annotation to specify that the step is a testmachinery system step.
// It indicates that it should not be considered as a test and therefore should not count for a test to be failed.
AnnotationSystemStep = "testmachinery.sapcloud.io/system-step"

// AnnotationTestDefName is the name of origin TestDefinition.
AnnotationTestDefName = "testmachinery.sapcloud.io/TestDefinition"

// AnnotationTestDefID is the unique name of origin TestDefinition in a specific flow and step.
AnnotationTestDefID = "testmachinery.sapcloud.io/ID"
AnnotationGroupPurpose = "metadata.testmachinery.gardener.cloud/group-purpose"

// LabelTestrunExecutionGroup is the label to specify the unique name of the run (multiple testruns) this test belongs to.
// A run represents all tests that are running from one testrunner.
LabelTestrunExecutionGroup = "testrunner.testmachinery.sapcloud.io/execution-group"
LabelTestrunExecutionGroup = "testrunner.testmachinery.gardener.cloud/execution-group"
)

// Testrunner Annotations
const (

// LabelIngested is the label that states whether the result of a testrun is already ingested into a persistent storage (db).
LabelIngested = "testrunner.testmachinery.sapcloud.io/ingested"

// LabelUploadedToGithub is the label to specify whether the testrun result was uploaded to github
LabelUploadedToGithub = "testrunner.testmachinery.sapcloud.io/uploaded-to-github"

// LabelTMDashboardIngress is the label to identify TestMachinery ingress objects.
LabelTMDashboardIngress = "testmachinery.garden.cloud/tm-dashboard"

// images
DockerImageGardenerApiServer = "eu.gcr.io/gardener-project/gardener/apiserver"

// Repositories
TestInfraRepo = "https://github.com/gardener/test-infra.git"
GardenSetupRepo = "https://github.com/gardener/garden-setup.git"
GardenerRepo = "https://github.com/gardener/gardener.git"
GardenerExtensionsRepo = "https://github.com/gardener/gardener-extensions.git"
TestInfraRepo = "https://github.com/gardener/test-infra.git"
GardenSetupRepo = "https://github.com/gardener/garden-setup.git"
GardenerRepo = "https://github.com/gardener/gardener.git"

PatternLatest = "latest"

Expand Down
11 changes: 11 additions & 0 deletions pkg/testrunner/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"
tmv1beta1 "github.com/gardener/test-infra/pkg/apis/testmachinery/v1beta1"
"github.com/gardener/test-infra/pkg/common"
"strconv"
)

// CreateAnnotations creates annotations of the metadata to be set on the respective workflow
Expand All @@ -27,8 +28,11 @@ func (m *Metadata) CreateAnnotations() map[string]string {
common.AnnotationK8sVersion: m.KubernetesVersion,
common.AnnotationCloudProvider: m.CloudProvider,
common.AnnotationOperatingSystem: m.OperatingSystem,
common.AnnotationRegion: m.Region,
common.AnnotationZone: m.Zone,
common.AnnotationFlavorDescription: m.FlavorDescription,
common.AnnotationDimension: m.GetDimensionFromMetadata("/"),
common.AnnotationRetries: strconv.Itoa(m.Retries),
}
}

Expand All @@ -50,14 +54,21 @@ func (m *Metadata) DeepCopy() *Metadata {

// MetadataFromTestrun reads metadata from a testrun
func MetadataFromTestrun(tr *tmv1beta1.Testrun) *Metadata {

retries, _ := strconv.Atoi(tr.Annotations[common.AnnotationRetries])

return &Metadata{
Landscape: tr.Annotations[common.AnnotationLandscape],
KubernetesVersion: tr.Annotations[common.AnnotationK8sVersion],
CloudProvider: tr.Annotations[common.AnnotationCloudProvider],
OperatingSystem: tr.Annotations[common.AnnotationOperatingSystem],
Region: tr.Annotations[common.AnnotationRegion],
Zone: tr.Annotations[common.AnnotationZone],
FlavorDescription: tr.Annotations[common.AnnotationFlavorDescription],
Retries: retries,
Testrun: TestrunMetadata{
ID: tr.Name,
StartTime: tr.Status.StartTime,
ExecutionGroup: tr.Annotations[common.LabelTestrunExecutionGroup],
},
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/testrunner/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ type Metadata struct {
// It is formatted as an array of components: { name: "my_component", version: "0.0.1" }
ComponentDescriptor interface{} `json:"bom,omitempty"`

// UpgradedComponentDescriptor describes the updated component_descriptor.
// It is formatted as an array of components: { name: "my_component", version: "0.0.1" }
UpgradedComponentDescriptor interface{} `json:"upgraded_bom,omitempty"`

// Name of the testrun crd object.
Testrun TestrunMetadata `json:"tr"`

Expand Down