• k8s-merge-robot's avatar
    Merge pull request #26942 from xiangpengzhao/fix_testcase · 5a7b52b8
    k8s-merge-robot authored
    Automatic merge from submit-queue
    
    Fix panic in schema test
    
    If the swagger files for testing are lost, the func `loadSchemaForTest` or `NewSwaggerSchemaFromBytes` will return a non-nil error and a nil schema. In this case, the calling for `ValidateBytes` will result in panic. So, call Fatalf instead of Errorf.
    
    Also fix minor typos.
    
    Test logs:
    
    ```
    --- FAIL: TestLoad (0.01s)
    	schema_test.go:131: Failed to load: open ../../../api/swagger-spec/v1.json: no such file or directory
    --- FAIL: TestValidateOk (0.00s)
    	schema_test.go:138: Failed to load: open ../../../api/swagger-spec/v1.json: no such file or directory
    panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    	panic: runtime error: invalid memory address or nil pointer dereference
    [signal 0xb code=0x1 addr=0x20 pc=0x4d52df]
    
    goroutine 10 [running]:
    panic(0x15fffa0, 0xc8200100a0)
    	/usr/local/go/src/runtime/panic.go:481 +0x3e6
    testing.tRunner.func1(0xc820085a70)
    	/usr/local/go/src/testing/testing.go:467 +0x192
    panic(0x15fffa0, 0xc8200100a0)
    	/usr/local/go/src/runtime/panic.go:443 +0x4e9
    k8s.io/kubernetes/pkg/api/validation.TestValidateOk(0xc820085a70)
    	/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/api/validation/schema_test.go:159 +0x79f
    testing.tRunner(0xc820085a70, 0x22aad68)
    	/usr/local/go/src/testing/testing.go:473 +0x98
    created by testing.RunTests
    	/usr/local/go/src/testing/testing.go:582 +0x892
    FAIL	k8s.io/kubernetes/pkg/api/validation	0.048s
    ```
    5a7b52b8
Name
Last commit
Last update
.github Loading commit data...
Godeps Loading commit data...
api/swagger-spec Loading commit data...
build Loading commit data...
cluster Loading commit data...
cmd Loading commit data...
contrib Loading commit data...
docs Loading commit data...
examples Loading commit data...
federation Loading commit data...
hack Loading commit data...
hooks Loading commit data...
logo Loading commit data...
pkg Loading commit data...
plugin Loading commit data...
release Loading commit data...
test Loading commit data...
third_party Loading commit data...
vendor Loading commit data...
www Loading commit data...
.generated_docs Loading commit data...
.gitignore Loading commit data...
CHANGELOG.md Loading commit data...
CONTRIB.md Loading commit data...
CONTRIBUTING.md Loading commit data...
DESIGN.md Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
Makefile.generated_files Loading commit data...
README.md Loading commit data...
Vagrantfile Loading commit data...
code-of-conduct.md Loading commit data...