This commit is contained in:
Chao Xu
2016-11-18 12:55:17 -08:00
parent 1044aa4500
commit a55c71db4d
102 changed files with 2940 additions and 2836 deletions

View File

@@ -17,8 +17,8 @@ limitations under the License.
package e2e
import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/util/intstr"
"k8s.io/kubernetes/pkg/util/uuid"
"k8s.io/kubernetes/test/e2e/framework"
@@ -57,8 +57,8 @@ var _ = framework.KubeDescribe("EmptyDir wrapper volumes", func() {
volumeName := "secret-volume"
volumeMountPath := "/etc/secret-volume"
secret := &api.Secret{
ObjectMeta: api.ObjectMeta{
secret := &v1.Secret{
ObjectMeta: v1.ObjectMeta{
Namespace: f.Namespace.Name,
Name: name,
},
@@ -77,35 +77,35 @@ var _ = framework.KubeDescribe("EmptyDir wrapper volumes", func() {
gitURL, gitRepo, gitCleanup := createGitServer(f)
defer gitCleanup()
pod := &api.Pod{
ObjectMeta: api.ObjectMeta{
pod := &v1.Pod{
ObjectMeta: v1.ObjectMeta{
Name: "pod-secrets-" + string(uuid.NewUUID()),
},
Spec: api.PodSpec{
Volumes: []api.Volume{
Spec: v1.PodSpec{
Volumes: []v1.Volume{
{
Name: volumeName,
VolumeSource: api.VolumeSource{
Secret: &api.SecretVolumeSource{
VolumeSource: v1.VolumeSource{
Secret: &v1.SecretVolumeSource{
SecretName: name,
},
},
},
{
Name: gitVolumeName,
VolumeSource: api.VolumeSource{
GitRepo: &api.GitRepoVolumeSource{
VolumeSource: v1.VolumeSource{
GitRepo: &v1.GitRepoVolumeSource{
Repository: gitURL,
Directory: gitRepo,
},
},
},
},
Containers: []api.Container{
Containers: []v1.Container{
{
Name: "secret-test",
Image: "gcr.io/google_containers/test-webserver:e2e",
VolumeMounts: []api.VolumeMount{
VolumeMounts: []v1.VolumeMount{
{
Name: volumeName,
MountPath: volumeMountPath,
@@ -128,7 +128,7 @@ var _ = framework.KubeDescribe("EmptyDir wrapper volumes", func() {
framework.Failf("unable to delete secret %v: %v", secret.Name, err)
}
By("Cleaning up the git vol pod")
if err = f.ClientSet.Core().Pods(f.Namespace.Name).Delete(pod.Name, api.NewDeleteOptions(0)); err != nil {
if err = f.ClientSet.Core().Pods(f.Namespace.Name).Delete(pod.Name, v1.NewDeleteOptions(0)); err != nil {
framework.Failf("unable to delete git vol pod %v: %v", pod.Name, err)
}
}()
@@ -177,18 +177,18 @@ func createGitServer(f *framework.Framework) (gitURL string, gitRepo string, cle
labels := map[string]string{"name": gitServerPodName}
gitServerPod := &api.Pod{
ObjectMeta: api.ObjectMeta{
gitServerPod := &v1.Pod{
ObjectMeta: v1.ObjectMeta{
Name: gitServerPodName,
Labels: labels,
},
Spec: api.PodSpec{
Containers: []api.Container{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "git-repo",
Image: "gcr.io/google_containers/fakegitserver:0.1",
ImagePullPolicy: "IfNotPresent",
Ports: []api.ContainerPort{
Ports: []v1.ContainerPort{
{ContainerPort: int32(containerPort)},
},
},
@@ -200,13 +200,13 @@ func createGitServer(f *framework.Framework) (gitURL string, gitRepo string, cle
// Portal IP and port
httpPort := 2345
gitServerSvc := &api.Service{
ObjectMeta: api.ObjectMeta{
gitServerSvc := &v1.Service{
ObjectMeta: v1.ObjectMeta{
Name: "git-server-svc",
},
Spec: api.ServiceSpec{
Spec: v1.ServiceSpec{
Selector: labels,
Ports: []api.ServicePort{
Ports: []v1.ServicePort{
{
Name: "http-portal",
Port: int32(httpPort),
@@ -222,7 +222,7 @@ func createGitServer(f *framework.Framework) (gitURL string, gitRepo string, cle
return "http://" + gitServerSvc.Spec.ClusterIP + ":" + strconv.Itoa(httpPort), "test", func() {
By("Cleaning up the git server pod")
if err := f.ClientSet.Core().Pods(f.Namespace.Name).Delete(gitServerPod.Name, api.NewDeleteOptions(0)); err != nil {
if err := f.ClientSet.Core().Pods(f.Namespace.Name).Delete(gitServerPod.Name, v1.NewDeleteOptions(0)); err != nil {
framework.Failf("unable to delete git server pod %v: %v", gitServerPod.Name, err)
}
By("Cleaning up the git server svc")
@@ -232,19 +232,19 @@ func createGitServer(f *framework.Framework) (gitURL string, gitRepo string, cle
}
}
func makeGitRepoVolumes(gitURL, gitRepo string) (volumes []api.Volume, volumeMounts []api.VolumeMount) {
func makeGitRepoVolumes(gitURL, gitRepo string) (volumes []v1.Volume, volumeMounts []v1.VolumeMount) {
for i := 0; i < wrappedVolumeRaceGitRepoVolumeCount; i++ {
volumeName := fmt.Sprintf("racey-git-repo-%d", i)
volumes = append(volumes, api.Volume{
volumes = append(volumes, v1.Volume{
Name: volumeName,
VolumeSource: api.VolumeSource{
GitRepo: &api.GitRepoVolumeSource{
VolumeSource: v1.VolumeSource{
GitRepo: &v1.GitRepoVolumeSource{
Repository: gitURL,
Directory: gitRepo,
},
},
})
volumeMounts = append(volumeMounts, api.VolumeMount{
volumeMounts = append(volumeMounts, v1.VolumeMount{
Name: volumeName,
MountPath: fmt.Sprintf("/etc/git-volume-%d", i),
})
@@ -257,8 +257,8 @@ func createConfigmapsForRace(f *framework.Framework) (configMapNames []string) {
for i := 0; i < wrappedVolumeRaceConfigMapVolumeCount; i++ {
configMapName := fmt.Sprintf("racey-configmap-%d", i)
configMapNames = append(configMapNames, configMapName)
configMap := &api.ConfigMap{
ObjectMeta: api.ObjectMeta{
configMap := &v1.ConfigMap{
ObjectMeta: v1.ObjectMeta{
Namespace: f.Namespace.Name,
Name: configMapName,
},
@@ -280,17 +280,17 @@ func deleteConfigMaps(f *framework.Framework, configMapNames []string) {
}
}
func makeConfigMapVolumes(configMapNames []string) (volumes []api.Volume, volumeMounts []api.VolumeMount) {
func makeConfigMapVolumes(configMapNames []string) (volumes []v1.Volume, volumeMounts []v1.VolumeMount) {
for i, configMapName := range configMapNames {
volumeName := fmt.Sprintf("racey-configmap-%d", i)
volumes = append(volumes, api.Volume{
volumes = append(volumes, v1.Volume{
Name: volumeName,
VolumeSource: api.VolumeSource{
ConfigMap: &api.ConfigMapVolumeSource{
LocalObjectReference: api.LocalObjectReference{
VolumeSource: v1.VolumeSource{
ConfigMap: &v1.ConfigMapVolumeSource{
LocalObjectReference: v1.LocalObjectReference{
Name: configMapName,
},
Items: []api.KeyToPath{
Items: []v1.KeyToPath{
{
Key: "data-1",
Path: "data-1",
@@ -299,7 +299,7 @@ func makeConfigMapVolumes(configMapNames []string) (volumes []api.Volume, volume
},
},
})
volumeMounts = append(volumeMounts, api.VolumeMount{
volumeMounts = append(volumeMounts, v1.VolumeMount{
Name: volumeName,
MountPath: fmt.Sprintf("/etc/config-%d", i),
})
@@ -307,7 +307,7 @@ func makeConfigMapVolumes(configMapNames []string) (volumes []api.Volume, volume
return
}
func testNoWrappedVolumeRace(f *framework.Framework, volumes []api.Volume, volumeMounts []api.VolumeMount, podCount int32) {
func testNoWrappedVolumeRace(f *framework.Framework, volumes []v1.Volume, volumeMounts []v1.VolumeMount, podCount int32) {
rcName := wrappedVolumeRaceRCNamePrefix + string(uuid.NewUUID())
nodeList := framework.GetReadySchedulableNodesOrDie(f.ClientSet)
Expect(len(nodeList.Items)).To(BeNumerically(">", 0))
@@ -315,7 +315,7 @@ func testNoWrappedVolumeRace(f *framework.Framework, volumes []api.Volume, volum
By("Creating RC which spawns configmap-volume pods")
affinity := map[string]string{
api.AffinityAnnotationKey: fmt.Sprintf(`
v1.AffinityAnnotationKey: fmt.Sprintf(`
{"nodeAffinity": { "requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms": [{
"matchExpressions": [{
@@ -327,35 +327,35 @@ func testNoWrappedVolumeRace(f *framework.Framework, volumes []api.Volume, volum
}}}`, targetNode.Name),
}
rc := &api.ReplicationController{
ObjectMeta: api.ObjectMeta{
rc := &v1.ReplicationController{
ObjectMeta: v1.ObjectMeta{
Name: rcName,
},
Spec: api.ReplicationControllerSpec{
Replicas: podCount,
Spec: v1.ReplicationControllerSpec{
Replicas: &podCount,
Selector: map[string]string{
"name": rcName,
},
Template: &api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Template: &v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{
Annotations: affinity,
Labels: map[string]string{"name": rcName},
},
Spec: api.PodSpec{
Containers: []api.Container{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "test-container",
Image: "gcr.io/google_containers/busybox:1.24",
Command: []string{"sleep", "10000"},
Resources: api.ResourceRequirements{
Requests: api.ResourceList{
api.ResourceCPU: resource.MustParse("10m"),
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{
v1.ResourceCPU: resource.MustParse("10m"),
},
},
VolumeMounts: volumeMounts,
},
},
DNSPolicy: api.DNSDefault,
DNSPolicy: v1.DNSDefault,
Volumes: volumes,
},
},
@@ -365,7 +365,7 @@ func testNoWrappedVolumeRace(f *framework.Framework, volumes []api.Volume, volum
Expect(err).NotTo(HaveOccurred(), "error creating replication controller")
defer func() {
err := framework.DeleteRCAndPods(f.ClientSet, f.Namespace.Name, rcName)
err := framework.DeleteRCAndPods(f.ClientSet, f.InternalClientset, f.Namespace.Name, rcName)
framework.ExpectNoError(err)
}()