You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This directory contains third-party resource interpreters for Karmada. These interpreters define how Karmada should handle custom resources from various third-party applications and operators.
4
+
5
+
## Files
6
+
7
+
-`thirdparty.go` - Main implementation of the third-party resource interpreter
8
+
-`thirdparty_test.go` - Test suite for validating resource interpreter customizations
9
+
-`resourcecustomizations/` - Directory containing resource customization definitions organized by API version and kind
10
+
11
+
## Directory Structure
12
+
13
+
The resource customizations are organized in the following structure:
Test data files are generally divided into four categories:
53
+
54
+
-`desired_xxx.yaml`: Resource definitions deployed on the control plane.
55
+
-`observed_xxx.yaml`: Resource definitions observed in a member cluster.
56
+
-`status_xxx.yaml`: Status information of the resource on each member cluster, with structure `[]workv1alpha2.AggregatedStatusItem`.
57
+
-`output_xxx.yaml`: Expected output for various operations, with structure `map[string]interface`.
58
+
59
+
Multiple test data files can be created for each category as needed. Pay attention to naming distinctions, as they will ultimately be referenced in `customizations_tests.yaml`.
60
+
61
+
#### 3. Create Test Configuration
62
+
63
+
Test configuration is defined in `customizations_tests.yaml` within the resource customization directory. It specifies
64
+
the test cases to be executed. Its structure is as follows:
65
+
```go
66
+
typeTestStructurestruct {
67
+
Tests []IndividualTest`yaml:"tests"`
68
+
}
69
+
70
+
typeIndividualTeststruct {
71
+
DesiredInputPathstring`yaml:"desiredInputPath,omitempty"`// the path of desired_xxx.yaml
72
+
ObservedInputPathstring`yaml:"observedInputPath,omitempty"`// the path of observed_xxx.yaml
73
+
StatusInputPathstring`yaml:"statusInputPath,omitempty"`// the path of status_xxx.yaml
74
+
InputReplicasint64`yaml:"inputReplicas,omitempty"`// the input replicas for revise operation
75
+
OutputResultsPathstring`yaml:"outputResultsPath,omitempty"`// the path of output_xxx.yaml
76
+
Operationstring`yaml:"operation"`// the operation of resource interpreter
77
+
}
78
+
```
79
+
80
+
Create `customizations_tests.yaml` to define test cases:
- `operation` specifies the operation of resource interpreter
95
+
- `outputResultsPath`defines the file path for expected output results. The output results are key-value mapping where the key is the field name of the expected result and the value is the expected result.
96
+
97
+
The keys in output results for different operations correspond to the Name field of the results returned by the corresponding resource interpreter operation `RuleResult.Results`.
- `AggregateStatus`- Aggregate status from multiple clusters
130
+
- `Retain`- Retain the desired resource template.
131
+
132
+
### Test Validation
133
+
134
+
The test framework validates:
135
+
136
+
1. **Lua Script Syntax** - Ensures all Lua scripts are syntactically correct
137
+
2. **Execution Results** - Compares actual results with expected results
138
+
139
+
### Debugging Tests
140
+
141
+
To debug failing tests:
142
+
143
+
1. **Check Lua Script Syntax** - Ensure your Lua scripts are valid
144
+
2. **Verify Test Data** - Confirm test input files are properly formatted
145
+
3. **Review Expected Results** - Make sure expected results match the actual operation output
146
+
4. **Use Verbose Output** - Run tests with `-v` flag for detailed output
147
+
148
+
### Best Practices
149
+
150
+
1. **Comprehensive Coverage** - Test all supported operations for your resource type
151
+
2. **Edge Cases** - Include tests for edge cases and error conditions
152
+
3. **Realistic Data** - Use realistic resource definitions in test data
153
+
4. **Clear Naming** - Use descriptive names for test files and cases
154
+
155
+
For more information about resource interpreter customizations, see the [Karmada documentation](https://karmada.io/docs/userguide/globalview/customizing-resource-interpreter/).
Copy file name to clipboardExpand all lines: pkg/resourceinterpreter/default/thirdparty/resourcecustomizations/flink.apache.org/v1beta1/FlinkDeployment/customizations_tests.yaml
0 commit comments