...

Text file src/github.com/openshift/api/monitoring/v1/stable.alertrelabelconfig.testsuite.yaml

Documentation: github.com/openshift/api/monitoring/v1

     1apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
     2name: "[Stable] AlertRelabelConfig"
     3crd: 0000_50_monitoring_02_alertrelabelconfigs.crd.yaml
     4tests:
     5  onCreate:
     6  - name: Should be able to create a minimal AlertRelabelConfig
     7    initial: |
     8      apiVersion: monitoring.openshift.io/v1
     9      kind: AlertRelabelConfig
    10      spec:
    11        configs:
    12        - sourceLabels:
    13            - foo
    14          targetLabel: bar
    15          replacement: '$1'
    16    expected: |
    17      apiVersion: monitoring.openshift.io/v1
    18      kind: AlertRelabelConfig
    19      spec:
    20        configs:
    21        - action: Replace
    22          sourceLabels:
    23            - foo
    24          targetLabel: bar
    25          replacement: '$1'
    26          regex: '(.*)'
    27  - name: Action Replace requires sourceLabels
    28    initial: |
    29      apiVersion: monitoring.openshift.io/v1
    30      kind: AlertRelabelConfig
    31      spec:
    32        configs:
    33        - action: Replace
    34          targetLabel: bar
    35    expectedError: "Invalid value: \"object\": sourceLabels is required for actions Replace, Keep, Drop, HashMod and LabelMap"
    36  - name: Action Keep requires sourceLabels
    37    initial: |
    38      apiVersion: monitoring.openshift.io/v1
    39      kind: AlertRelabelConfig
    40      spec:
    41        configs:
    42        - action: Keep
    43          targetLabel: bar
    44    expectedError: "Invalid value: \"object\": sourceLabels is required for actions Replace, Keep, Drop, HashMod and LabelMap"
    45  - name: Action Drop requires sourceLabels
    46    initial: |
    47      apiVersion: monitoring.openshift.io/v1
    48      kind: AlertRelabelConfig
    49      spec:
    50        configs:
    51        - action: Drop
    52          targetLabel: bar
    53    expectedError: "Invalid value: \"object\": sourceLabels is required for actions Replace, Keep, Drop, HashMod and LabelMap"
    54  - name: Action HashMod requires sourceLabels
    55    initial: |
    56      apiVersion: monitoring.openshift.io/v1
    57      kind: AlertRelabelConfig
    58      spec:
    59        configs:
    60        - action: HashMod
    61          targetLabel: bar
    62    expectedError: "Invalid value: \"object\": sourceLabels is required for actions Replace, Keep, Drop, HashMod and LabelMap"
    63  - name: Action LabelMap requires sourceLabels
    64    initial: |
    65      apiVersion: monitoring.openshift.io/v1
    66      kind: AlertRelabelConfig
    67      spec:
    68        configs:
    69        - action: LabelMap
    70          targetLabel: bar
    71    expectedError: "Invalid value: \"object\": sourceLabels is required for actions Replace, Keep, Drop, HashMod and LabelMap"
    72  - name: Field modulus requires sourceLabels
    73    initial: |
    74      apiVersion: monitoring.openshift.io/v1
    75      kind: AlertRelabelConfig
    76      spec:
    77        configs:
    78        - action: HashMod
    79          targetLabel: bar
    80          modulus: 3
    81    expectedError: "[spec.configs[0]: Invalid value: \"object\": no such key: sourceLabels evaluating rule: modulus requires sourceLabels to be present, spec.configs[0]: Invalid value: \"object\": sourceLabels is required for actions Replace, Keep, Drop, HashMod and LabelMap]"
    82  - name: Action Replace requires targetLabel
    83    initial: |
    84      apiVersion: monitoring.openshift.io/v1
    85      kind: AlertRelabelConfig
    86      spec:
    87        configs:
    88        - sourceLabels:
    89            - foo
    90    expectedError: "spec.configs[0]: Invalid value: \"object\": targetLabel is required when action is Replace or HashMod"
    91  - name: Action HashMod requires targetLabel
    92    initial: |
    93      apiVersion: monitoring.openshift.io/v1
    94      kind: AlertRelabelConfig
    95      spec:
    96        configs:
    97        - sourceLabels:
    98            - foo
    99          action: HashMod
   100          modulus: 3
   101    expectedError: "spec.configs[0]: Invalid value: \"object\": targetLabel is required when action is Replace or HashMod"
   102  - name: Action LabelKeep only allows regex
   103    initial: |
   104      apiVersion: monitoring.openshift.io/v1
   105      kind: AlertRelabelConfig
   106      spec:
   107        configs:
   108        - sourceLabels:
   109            - foo
   110          action: LabelKeep
   111    expectedError: "spec.configs[0]: Invalid value: \"object\": LabelKeep and LabelDrop actions require only 'regex', and no other fields (found sourceLabels)"
   112  - name: Action LabelKeep only allows regex not sourceLabels
   113    initial: |
   114      apiVersion: monitoring.openshift.io/v1
   115      kind: AlertRelabelConfig
   116      spec:
   117        configs:
   118        - action: LabelKeep
   119          targetLabel: foo
   120    expectedError: "spec.configs[0]: Invalid value: \"object\": LabelKeep and LabelDrop actions require only 'regex', and no other fields (found targetLabel)"
   121  - name: Action LabelKeep only allows regex not targetLabel
   122    initial: |
   123      apiVersion: monitoring.openshift.io/v1
   124      kind: AlertRelabelConfig
   125      spec:
   126        configs:
   127        - action: LabelKeep
   128          modulus: 3
   129    expectedError: "spec.configs[0]: Invalid value: \"object\": LabelKeep and LabelDrop actions require only 'regex', and no other fields (found modulus)"
   130  - name: Action LabelKeep only allows regex not separator
   131    initial: |
   132      apiVersion: monitoring.openshift.io/v1
   133      kind: AlertRelabelConfig
   134      spec:
   135        configs:
   136        - action: LabelKeep
   137          separator: ;
   138    expectedError: "spec.configs[0]: Invalid value: \"object\": LabelKeep and LabelDrop actions require only 'regex', and no other fields (found separator)"
   139  - name: Action LabelKeep only allows regex not replacement
   140    initial: |
   141      apiVersion: monitoring.openshift.io/v1
   142      kind: AlertRelabelConfig
   143      spec:
   144        configs:
   145        - action: LabelKeep
   146          replacement: foo
   147    expectedError: "spec.configs[0]: Invalid value: \"object\": LabelKeep and LabelDrop actions require only 'regex', and no other fields (found replacement)"

View as plain text