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
Speed up CRD apply/openapi unit tests #98694
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,6 @@ import ( | |
"os" | ||
"path/filepath" | ||
"strconv" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
|
@@ -825,18 +824,20 @@ func TestBuildOpenAPIModelsForApply(t *testing.T) { | |
}, | ||
} | ||
|
||
for _, test := range tests { | ||
for i, test := range tests { | ||
crd.Spec.Versions[0].Schema = &test | ||
if _, err := buildOpenAPIModelsForApply(staticSpec, &crd); err != nil { | ||
models, err := buildOpenAPIModelsForApply(staticSpec, &crd) | ||
if err != nil { | ||
t.Fatalf("failed to convert to apply model: %v", err) | ||
} | ||
if models == nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. adds a check that the model was actually built successfully |
||
t.Fatalf("%d: failed to convert to apply model: nil", i) | ||
} | ||
} | ||
} | ||
|
||
func getOpenAPISpecFromFile() (*spec.Swagger, error) { | ||
path := filepath.Join( | ||
strings.Repeat(".."+string(filepath.Separator), 6), | ||
"api", "openapi-spec", "swagger.json") | ||
path := filepath.Join("testdata", "swagger.json") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is simpler. |
||
_, err := os.Stat(path) | ||
if err != nil { | ||
return nil, err | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
`swagger.json` contains static openapi definitions needed to build models for custom resource types. | ||
|
||
It was created by removing all path and non-objectmeta/int-or-string definitions from | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not entirely sure I understand that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. started with |
||
the `api/openapi-spec/swagger.json` in the `k8s.io/kubernetes` module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're not going toward more bazel, AFAIK, it's probably not important, but do we need to depend on everything here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was autogenerated, so... /shrug ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if we were building a super awesome bazel thing, then it means this test would be re-run anytime something changes anything in testdata which wouldn't be great. I can't really care less :-)