...

Source file src/edge-infra.dev/test/framework/labels.go

Documentation: edge-infra.dev/test/framework

     1  package framework
     2  
     3  // Label adds a label and a value to the framework to describe the block of tests
     4  // the framework instance will be used for. Returns a pointer to itself so it
     5  // can be chained together to add multiple labels:
     6  //
     7  //	f := framework.New("my-test-suite")
     8  //		.Label("serial", "true")
     9  //		.Label("foo", "bar")
    10  func (f *Framework) Label(key, value string) *Framework {
    11  	if f.labels == nil {
    12  		f.labels = map[string]string{}
    13  	}
    14  	f.labels[key] = value
    15  
    16  	return f
    17  }
    18  
    19  // TODO: link test categorization doc as source of truth for test labeling
    20  // TODO: Feature
    21  // TODO: Priviledged
    22  
    23  // Component is syntactic sugar for adding a component label to the test block.
    24  // Returns a pointer to itself for function chaining.
    25  // TODO: allow more than one component
    26  func (f *Framework) Component(c string) *Framework {
    27  	return f.Label("component", c)
    28  }
    29  
    30  // Slow is a label that should be applied to all test suites which take longer
    31  // than 5 minutes to execute.
    32  func (f *Framework) Slow() *Framework {
    33  	return f.Label("slow", "true")
    34  }
    35  
    36  // Disruptive is a label that should be applied to all test suites that are
    37  // likely to disrupt other test cases being ran at the same time.
    38  func (f *Framework) Disruptive() *Framework {
    39  	return f.Label("disruptive", "true")
    40  }
    41  
    42  // Serial is a label that should be applied to all test suites that can't be
    43  // run in parallel.
    44  func (f *Framework) Serial() *Framework {
    45  	return f.Label("serial", "true")
    46  }
    47  
    48  // Flaky is a label that should be applied to tests with inconsistent results.
    49  func (f *Framework) Flaky() *Framework {
    50  	return f.Label("flaky", "true")
    51  }
    52  

View as plain text