mirror of https://github.com/k3s-io/k3s
remove most references to api.PreV1Beta3
parent
6b81c064ed
commit
ca72165b20
|
@ -28,9 +28,6 @@ import (
|
|||
)
|
||||
|
||||
func getLimitRangesResourceName() string {
|
||||
if api.PreV1Beta3(testapi.Version()) {
|
||||
return "limitRanges"
|
||||
}
|
||||
return "limitranges"
|
||||
}
|
||||
|
||||
|
|
|
@ -28,9 +28,6 @@ import (
|
|||
)
|
||||
|
||||
func getNodesResourceName() string {
|
||||
if api.PreV1Beta3(testapi.Version()) {
|
||||
return "minions"
|
||||
}
|
||||
return "nodes"
|
||||
}
|
||||
|
||||
|
|
|
@ -28,9 +28,6 @@ import (
|
|||
)
|
||||
|
||||
func getPersistentVolumesResoureName() string {
|
||||
if api.PreV1Beta3(testapi.Version()) {
|
||||
return "persistentVolumes"
|
||||
}
|
||||
return "persistentvolumes"
|
||||
}
|
||||
|
||||
|
|
|
@ -28,9 +28,6 @@ import (
|
|||
)
|
||||
|
||||
func getPersistentVolumeClaimsResoureName() string {
|
||||
if api.PreV1Beta3(testapi.Version()) {
|
||||
return "persistentVolumeClaims"
|
||||
}
|
||||
return "persistentvolumeclaims"
|
||||
}
|
||||
|
||||
|
|
|
@ -31,10 +31,6 @@ func getPodTemplatesResoureName() string {
|
|||
}
|
||||
|
||||
func TestPodTemplateCreate(t *testing.T) {
|
||||
if api.PreV1Beta3(testapi.Version()) {
|
||||
return
|
||||
}
|
||||
|
||||
ns := api.NamespaceDefault
|
||||
podTemplate := api.PodTemplate{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
|
@ -58,10 +54,6 @@ func TestPodTemplateCreate(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPodTemplateGet(t *testing.T) {
|
||||
if api.PreV1Beta3(testapi.Version()) {
|
||||
return
|
||||
}
|
||||
|
||||
ns := api.NamespaceDefault
|
||||
podTemplate := &api.PodTemplate{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
|
@ -85,10 +77,6 @@ func TestPodTemplateGet(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPodTemplateList(t *testing.T) {
|
||||
if api.PreV1Beta3(testapi.Version()) {
|
||||
return
|
||||
}
|
||||
|
||||
ns := api.NamespaceDefault
|
||||
podTemplateList := &api.PodTemplateList{
|
||||
Items: []api.PodTemplate{
|
||||
|
@ -114,10 +102,6 @@ func TestPodTemplateList(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPodTemplateUpdate(t *testing.T) {
|
||||
if api.PreV1Beta3(testapi.Version()) {
|
||||
return
|
||||
}
|
||||
|
||||
ns := api.NamespaceDefault
|
||||
podTemplate := &api.PodTemplate{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
|
@ -136,10 +120,6 @@ func TestPodTemplateUpdate(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPodTemplateDelete(t *testing.T) {
|
||||
if api.PreV1Beta3(testapi.Version()) {
|
||||
return
|
||||
}
|
||||
|
||||
ns := api.NamespaceDefault
|
||||
c := &testClient{
|
||||
Request: testRequest{Method: "DELETE", Path: testapi.ResourcePath(getPodTemplatesResoureName(), ns, "foo"), Query: buildQueryValues(ns, nil)},
|
||||
|
@ -150,10 +130,6 @@ func TestPodTemplateDelete(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPodTemplateWatch(t *testing.T) {
|
||||
if api.PreV1Beta3(testapi.Version()) {
|
||||
return
|
||||
}
|
||||
|
||||
c := &testClient{
|
||||
Request: testRequest{
|
||||
Method: "GET",
|
||||
|
|
|
@ -25,9 +25,6 @@ import (
|
|||
)
|
||||
|
||||
func getRCResourceName() string {
|
||||
if api.PreV1Beta3(testapi.Version()) {
|
||||
return "replicationControllers"
|
||||
}
|
||||
return "replicationcontrollers"
|
||||
}
|
||||
|
||||
|
|
|
@ -28,9 +28,6 @@ import (
|
|||
)
|
||||
|
||||
func getResourceQuotasResoureName() string {
|
||||
if api.PreV1Beta3(testapi.Version()) {
|
||||
return "resourceQuotas"
|
||||
}
|
||||
return "resourcequotas"
|
||||
}
|
||||
|
||||
|
|
|
@ -166,9 +166,6 @@ func validateSyncReplication(t *testing.T, fakePodControl *FakePodControl, expec
|
|||
}
|
||||
|
||||
func replicationControllerResourceName() string {
|
||||
if api.PreV1Beta3(testapi.Version()) {
|
||||
return "replicationControllers"
|
||||
}
|
||||
return "replicationcontrollers"
|
||||
}
|
||||
|
||||
|
@ -193,7 +190,7 @@ func makeTestServer(t *testing.T, namespace, name string, podResponse, controlle
|
|||
mux := http.NewServeMux()
|
||||
mux.Handle(testapi.ResourcePath("pods", namespace, ""), &fakePodHandler)
|
||||
mux.Handle(testapi.ResourcePath(replicationControllerResourceName(), "", ""), &fakeControllerHandler)
|
||||
if !api.PreV1Beta3(testapi.Version()) && namespace != "" {
|
||||
if namespace != "" {
|
||||
mux.Handle(testapi.ResourcePath(replicationControllerResourceName(), namespace, ""), &fakeControllerHandler)
|
||||
}
|
||||
if name != "" {
|
||||
|
|
|
@ -416,20 +416,7 @@ func TestTemplateStrings(t *testing.T) {
|
|||
}
|
||||
// The point of this test is to verify that the below template works. If you change this
|
||||
// template, you need to update hack/e2e-suite/update.sh.
|
||||
tmpl := ``
|
||||
if api.PreV1Beta3(testapi.Version()) {
|
||||
tmpl = `{{exists . "currentState" "info" "foo" "state" "running"}}`
|
||||
useThisToDebug := `
|
||||
a: {{exists . "currentState"}}
|
||||
b: {{exists . "currentState" "info"}}
|
||||
c: {{exists . "currentState" "info" "foo"}}
|
||||
d: {{exists . "currentState" "info" "foo" "state"}}
|
||||
e: {{exists . "currentState" "info" "foo" "state" "running"}}
|
||||
f: {{exists . "currentState" "info" "foo" "state" "running" "startedAt"}}`
|
||||
_ = useThisToDebug // don't complain about unused var
|
||||
} else {
|
||||
tmpl = `{{if (exists . "status" "containerStatuses")}}{{range .status.containerStatuses}}{{if (and (eq .name "foo") (exists . "state" "running"))}}true{{end}}{{end}}{{end}}`
|
||||
}
|
||||
tmpl := `{{if (exists . "status" "containerStatuses")}}{{range .status.containerStatuses}}{{if (and (eq .name "foo") (exists . "state" "running"))}}true{{end}}{{end}}{{end}}`
|
||||
p, err := NewTemplatePrinter([]byte(tmpl))
|
||||
if err != nil {
|
||||
t.Fatalf("tmpl fail: %v", err)
|
||||
|
|
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
@ -68,99 +67,6 @@ func writeTestFile(t *testing.T, dir, name string, contents string) *os.File {
|
|||
return file
|
||||
}
|
||||
|
||||
func TestReadContainerManifestFromFile(t *testing.T) {
|
||||
// ContainerManifest is supported only for pre v1beta3 versions.
|
||||
if !api.PreV1Beta3(testapi.Version()) {
|
||||
return
|
||||
}
|
||||
hostname := "random-test-hostname"
|
||||
var testCases = []struct {
|
||||
desc string
|
||||
fileContents string
|
||||
expected kubelet.PodUpdate
|
||||
}{
|
||||
{
|
||||
desc: "Manifest",
|
||||
fileContents: fmt.Sprintf(`{
|
||||
"version": "%s",
|
||||
"uuid": "12345",
|
||||
"id": "test",
|
||||
"containers": [{ "name": "image", "image": "test/image", "imagePullPolicy": "PullAlways"}]
|
||||
}`, testapi.Version()),
|
||||
expected: CreatePodUpdate(kubelet.SET, kubelet.FileSource, &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "test-" + hostname,
|
||||
UID: "12345",
|
||||
Namespace: kubelet.NamespaceDefault,
|
||||
SelfLink: getSelfLink("test-"+hostname, kubelet.NamespaceDefault),
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
NodeName: hostname,
|
||||
RestartPolicy: api.RestartPolicyAlways,
|
||||
DNSPolicy: api.DNSClusterFirst,
|
||||
Containers: []api.Container{{
|
||||
Name: "image",
|
||||
Image: "test/image",
|
||||
TerminationMessagePath: "/dev/termination-log",
|
||||
ImagePullPolicy: "Always",
|
||||
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
|
||||
},
|
||||
}),
|
||||
},
|
||||
{
|
||||
desc: "Manifest without ID",
|
||||
fileContents: fmt.Sprintf(`{
|
||||
"version": "%s",
|
||||
"uuid": "12345",
|
||||
"containers": [{ "name": "image", "image": "test/image", "imagePullPolicy": "PullAlways"}]
|
||||
}`, testapi.Version()),
|
||||
expected: CreatePodUpdate(kubelet.SET, kubelet.FileSource, &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "12345-" + hostname,
|
||||
UID: "12345",
|
||||
Namespace: kubelet.NamespaceDefault,
|
||||
SelfLink: getSelfLink("12345-"+hostname, kubelet.NamespaceDefault),
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
NodeName: hostname,
|
||||
RestartPolicy: api.RestartPolicyAlways,
|
||||
DNSPolicy: api.DNSClusterFirst,
|
||||
Containers: []api.Container{{
|
||||
Name: "image",
|
||||
Image: "test/image",
|
||||
TerminationMessagePath: "/dev/termination-log",
|
||||
ImagePullPolicy: "Always",
|
||||
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
|
||||
},
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
func() {
|
||||
file := writeTestFile(t, os.TempDir(), "test_pod_config", testCase.fileContents)
|
||||
defer os.Remove(file.Name())
|
||||
|
||||
ch := make(chan interface{})
|
||||
NewSourceFile(file.Name(), hostname, time.Millisecond, ch)
|
||||
select {
|
||||
case got := <-ch:
|
||||
update := got.(kubelet.PodUpdate)
|
||||
for _, pod := range update.Pods {
|
||||
if errs := validation.ValidatePod(pod); len(errs) > 0 {
|
||||
t.Errorf("%s: Invalid pod %#v, %#v", testCase.desc, pod, errs)
|
||||
}
|
||||
}
|
||||
if !api.Semantic.DeepEqual(testCase.expected, update) {
|
||||
t.Errorf("%s: Expected %#v, Got %#v", testCase.desc, testCase.expected, update)
|
||||
}
|
||||
case <-time.After(time.Second):
|
||||
t.Errorf("%s: Expected update, timeout instead", testCase.desc)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadPodsFromFile(t *testing.T) {
|
||||
hostname := "random-test-hostname"
|
||||
var testCases = []struct {
|
||||
|
@ -276,32 +182,6 @@ func TestReadPodsFromFile(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestReadManifestFromFileWithDefaults(t *testing.T) {
|
||||
if !api.PreV1Beta3(testapi.Version()) {
|
||||
return
|
||||
}
|
||||
file := writeTestFile(t, os.TempDir(), "test_pod_config",
|
||||
fmt.Sprintf(`{
|
||||
"version": "%s",
|
||||
"id": "test",
|
||||
"containers": [{ "name": "image", "image": "test/image" }]
|
||||
}`, testapi.Version()))
|
||||
defer os.Remove(file.Name())
|
||||
|
||||
ch := make(chan interface{})
|
||||
NewSourceFile(file.Name(), "localhost", time.Millisecond, ch)
|
||||
select {
|
||||
case got := <-ch:
|
||||
update := got.(kubelet.PodUpdate)
|
||||
if update.Pods[0].UID == "" {
|
||||
t.Errorf("Unexpected UID: %s", update.Pods[0].UID)
|
||||
}
|
||||
|
||||
case <-time.After(time.Second):
|
||||
t.Errorf("Expected update, timeout instead")
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtractFromBadDataFile(t *testing.T) {
|
||||
file := writeTestFile(t, os.TempDir(), "test_pod_config", string([]byte{1, 2, 3}))
|
||||
defer os.Remove(file.Name())
|
||||
|
|
Loading…
Reference in New Issue