mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
Merge pull request #116384 from liggitt/fixup-after-roundtrip
Detect and clean up unneeded after_roundtrip fixtures
This commit is contained in:
commit
61050182b5
Binary file not shown.
@ -1,131 +0,0 @@
|
||||
{
|
||||
"kind": "ValidatingAdmissionPolicy",
|
||||
"apiVersion": "admissionregistration.k8s.io/v1alpha1",
|
||||
"metadata": {
|
||||
"name": "nameValue",
|
||||
"generateName": "generateNameValue",
|
||||
"namespace": "namespaceValue",
|
||||
"selfLink": "selfLinkValue",
|
||||
"uid": "uidValue",
|
||||
"resourceVersion": "resourceVersionValue",
|
||||
"generation": 7,
|
||||
"creationTimestamp": "2008-01-01T01:01:01Z",
|
||||
"deletionTimestamp": "2009-01-01T01:01:01Z",
|
||||
"deletionGracePeriodSeconds": 10,
|
||||
"labels": {
|
||||
"labelsKey": "labelsValue"
|
||||
},
|
||||
"annotations": {
|
||||
"annotationsKey": "annotationsValue"
|
||||
},
|
||||
"ownerReferences": [
|
||||
{
|
||||
"apiVersion": "apiVersionValue",
|
||||
"kind": "kindValue",
|
||||
"name": "nameValue",
|
||||
"uid": "uidValue",
|
||||
"controller": true,
|
||||
"blockOwnerDeletion": true
|
||||
}
|
||||
],
|
||||
"finalizers": [
|
||||
"finalizersValue"
|
||||
],
|
||||
"managedFields": [
|
||||
{
|
||||
"manager": "managerValue",
|
||||
"operation": "operationValue",
|
||||
"apiVersion": "apiVersionValue",
|
||||
"time": "2004-01-01T01:01:01Z",
|
||||
"fieldsType": "fieldsTypeValue",
|
||||
"fieldsV1": {},
|
||||
"subresource": "subresourceValue"
|
||||
}
|
||||
]
|
||||
},
|
||||
"spec": {
|
||||
"paramKind": {
|
||||
"apiVersion": "apiVersionValue",
|
||||
"kind": "kindValue"
|
||||
},
|
||||
"matchConstraints": {
|
||||
"namespaceSelector": {
|
||||
"matchLabels": {
|
||||
"matchLabelsKey": "matchLabelsValue"
|
||||
},
|
||||
"matchExpressions": [
|
||||
{
|
||||
"key": "keyValue",
|
||||
"operator": "operatorValue",
|
||||
"values": [
|
||||
"valuesValue"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"objectSelector": {
|
||||
"matchLabels": {
|
||||
"matchLabelsKey": "matchLabelsValue"
|
||||
},
|
||||
"matchExpressions": [
|
||||
{
|
||||
"key": "keyValue",
|
||||
"operator": "operatorValue",
|
||||
"values": [
|
||||
"valuesValue"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"resourceRules": [
|
||||
{
|
||||
"resourceNames": [
|
||||
"resourceNamesValue"
|
||||
],
|
||||
"operations": [
|
||||
"operationsValue"
|
||||
],
|
||||
"apiGroups": [
|
||||
"apiGroupsValue"
|
||||
],
|
||||
"apiVersions": [
|
||||
"apiVersionsValue"
|
||||
],
|
||||
"resources": [
|
||||
"resourcesValue"
|
||||
],
|
||||
"scope": "scopeValue"
|
||||
}
|
||||
],
|
||||
"excludeResourceRules": [
|
||||
{
|
||||
"resourceNames": [
|
||||
"resourceNamesValue"
|
||||
],
|
||||
"operations": [
|
||||
"operationsValue"
|
||||
],
|
||||
"apiGroups": [
|
||||
"apiGroupsValue"
|
||||
],
|
||||
"apiVersions": [
|
||||
"apiVersionsValue"
|
||||
],
|
||||
"resources": [
|
||||
"resourcesValue"
|
||||
],
|
||||
"scope": "scopeValue"
|
||||
}
|
||||
],
|
||||
"matchPolicy": "matchPolicyValue"
|
||||
},
|
||||
"validations": [
|
||||
{
|
||||
"expression": "expressionValue",
|
||||
"message": "messageValue",
|
||||
"reason": "reasonValue"
|
||||
}
|
||||
],
|
||||
"failurePolicy": "failurePolicyValue"
|
||||
}
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
apiVersion: admissionregistration.k8s.io/v1alpha1
|
||||
kind: ValidatingAdmissionPolicy
|
||||
metadata:
|
||||
annotations:
|
||||
annotationsKey: annotationsValue
|
||||
creationTimestamp: "2008-01-01T01:01:01Z"
|
||||
deletionGracePeriodSeconds: 10
|
||||
deletionTimestamp: "2009-01-01T01:01:01Z"
|
||||
finalizers:
|
||||
- finalizersValue
|
||||
generateName: generateNameValue
|
||||
generation: 7
|
||||
labels:
|
||||
labelsKey: labelsValue
|
||||
managedFields:
|
||||
- apiVersion: apiVersionValue
|
||||
fieldsType: fieldsTypeValue
|
||||
fieldsV1: {}
|
||||
manager: managerValue
|
||||
operation: operationValue
|
||||
subresource: subresourceValue
|
||||
time: "2004-01-01T01:01:01Z"
|
||||
name: nameValue
|
||||
namespace: namespaceValue
|
||||
ownerReferences:
|
||||
- apiVersion: apiVersionValue
|
||||
blockOwnerDeletion: true
|
||||
controller: true
|
||||
kind: kindValue
|
||||
name: nameValue
|
||||
uid: uidValue
|
||||
resourceVersion: resourceVersionValue
|
||||
selfLink: selfLinkValue
|
||||
uid: uidValue
|
||||
spec:
|
||||
failurePolicy: failurePolicyValue
|
||||
matchConstraints:
|
||||
excludeResourceRules:
|
||||
- apiGroups:
|
||||
- apiGroupsValue
|
||||
apiVersions:
|
||||
- apiVersionsValue
|
||||
operations:
|
||||
- operationsValue
|
||||
resourceNames:
|
||||
- resourceNamesValue
|
||||
resources:
|
||||
- resourcesValue
|
||||
scope: scopeValue
|
||||
matchPolicy: matchPolicyValue
|
||||
namespaceSelector:
|
||||
matchExpressions:
|
||||
- key: keyValue
|
||||
operator: operatorValue
|
||||
values:
|
||||
- valuesValue
|
||||
matchLabels:
|
||||
matchLabelsKey: matchLabelsValue
|
||||
objectSelector:
|
||||
matchExpressions:
|
||||
- key: keyValue
|
||||
operator: operatorValue
|
||||
values:
|
||||
- valuesValue
|
||||
matchLabels:
|
||||
matchLabelsKey: matchLabelsValue
|
||||
resourceRules:
|
||||
- apiGroups:
|
||||
- apiGroupsValue
|
||||
apiVersions:
|
||||
- apiVersionsValue
|
||||
operations:
|
||||
- operationsValue
|
||||
resourceNames:
|
||||
- resourceNamesValue
|
||||
resources:
|
||||
- resourcesValue
|
||||
scope: scopeValue
|
||||
paramKind:
|
||||
apiVersion: apiVersionValue
|
||||
kind: kindValue
|
||||
validations:
|
||||
- expression: expressionValue
|
||||
message: messageValue
|
||||
reason: reasonValue
|
Binary file not shown.
@ -364,6 +364,12 @@ func writeFile(t *testing.T, dir string, gvk schema.GroupVersionKind, suffix, ex
|
||||
}
|
||||
}
|
||||
|
||||
func deleteFile(t *testing.T, dir string, gvk schema.GroupVersionKind, suffix, extension string) {
|
||||
if err := os.Remove(filepath.Join(dir, makeName(gvk)+suffix+"."+extension)); err != nil {
|
||||
t.Fatalf("error removing %s: %v", extension, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CompatibilityTestOptions) runPreviousVersionTest(t *testing.T, gvk schema.GroupVersionKind, previousVersionDir string, usedFiles sets.String) {
|
||||
jsonBeforeRoundTrip, yamlBeforeRoundTrip, protoBeforeRoundTrip, err := read(previousVersionDir, gvk, "", usedFiles)
|
||||
if os.IsNotExist(err) || (len(jsonBeforeRoundTrip) == 0 && len(yamlBeforeRoundTrip) == 0 && len(protoBeforeRoundTrip) == 0) {
|
||||
@ -422,15 +428,28 @@ func (c *CompatibilityTestOptions) runPreviousVersionTest(t *testing.T, gvk sche
|
||||
}
|
||||
protoAfterRoundTrip := protoBytes.Bytes()
|
||||
|
||||
jsonNeedsRemove := false
|
||||
yamlNeedsRemove := false
|
||||
protoNeedsRemove := false
|
||||
|
||||
expectedJSONAfterRoundTrip, expectedYAMLAfterRoundTrip, expectedProtoAfterRoundTrip, _ := read(previousVersionDir, gvk, ".after_roundtrip", usedFiles)
|
||||
if len(expectedJSONAfterRoundTrip) == 0 {
|
||||
expectedJSONAfterRoundTrip = jsonBeforeRoundTrip
|
||||
} else if bytes.Equal(jsonBeforeRoundTrip, expectedJSONAfterRoundTrip) {
|
||||
t.Errorf("JSON after_roundtrip file is identical and should be removed")
|
||||
jsonNeedsRemove = true
|
||||
}
|
||||
if len(expectedYAMLAfterRoundTrip) == 0 {
|
||||
expectedYAMLAfterRoundTrip = yamlBeforeRoundTrip
|
||||
} else if bytes.Equal(yamlBeforeRoundTrip, expectedYAMLAfterRoundTrip) {
|
||||
t.Errorf("YAML after_roundtrip file is identical and should be removed")
|
||||
yamlNeedsRemove = true
|
||||
}
|
||||
if len(expectedProtoAfterRoundTrip) == 0 {
|
||||
expectedProtoAfterRoundTrip = protoBeforeRoundTrip
|
||||
} else if bytes.Equal(protoBeforeRoundTrip, expectedProtoAfterRoundTrip) {
|
||||
t.Errorf("Proto after_roundtrip file is identical and should be removed")
|
||||
protoNeedsRemove = true
|
||||
}
|
||||
|
||||
jsonNeedsUpdate := false
|
||||
@ -456,17 +475,25 @@ func (c *CompatibilityTestOptions) runPreviousVersionTest(t *testing.T, gvk sche
|
||||
// t.Logf("json (for locating the offending field based on surrounding data): %s", string(expectedJSON))
|
||||
}
|
||||
|
||||
if jsonNeedsUpdate || yamlNeedsUpdate || protoNeedsUpdate {
|
||||
if jsonNeedsUpdate || yamlNeedsUpdate || protoNeedsUpdate || jsonNeedsRemove || yamlNeedsRemove || protoNeedsRemove {
|
||||
const updateEnvVar = "UPDATE_COMPATIBILITY_FIXTURE_DATA"
|
||||
if os.Getenv(updateEnvVar) == "true" {
|
||||
if jsonNeedsUpdate {
|
||||
writeFile(t, previousVersionDir, gvk, ".after_roundtrip", "json", jsonAfterRoundTrip)
|
||||
} else if jsonNeedsRemove {
|
||||
deleteFile(t, previousVersionDir, gvk, ".after_roundtrip", "json")
|
||||
}
|
||||
|
||||
if yamlNeedsUpdate {
|
||||
writeFile(t, previousVersionDir, gvk, ".after_roundtrip", "yaml", yamlAfterRoundTrip)
|
||||
} else if yamlNeedsRemove {
|
||||
deleteFile(t, previousVersionDir, gvk, ".after_roundtrip", "yaml")
|
||||
}
|
||||
|
||||
if protoNeedsUpdate {
|
||||
writeFile(t, previousVersionDir, gvk, ".after_roundtrip", "pb", protoAfterRoundTrip)
|
||||
} else if protoNeedsRemove {
|
||||
deleteFile(t, previousVersionDir, gvk, ".after_roundtrip", "pb")
|
||||
}
|
||||
t.Logf("wrote expected compatibility data... verify, commit, and rerun tests")
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user