Skip to content

Commit

Permalink
Merge pull request kubernetes#53794 from xiangpengzhao/poduid-e2e-dapi
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue (batch tested with PRs 53575, 53794). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Add e2e test case for downward API exposing pod UID

**What this PR does / why we need it**:
Pod UID is added to downward API env var in kubernetes#48125 for 1.8. This PR adds a e2e test case for it.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
ref: kubernetes#48125

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
  • Loading branch information
Kubernetes Submit Queue authored Oct 17, 2017
2 parents 7d59b2d + 7410674 commit d7e56d5
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion test/e2e/common/downward_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ import (
. "github.com/onsi/ginkgo"
)

var hostIPVersion = utilversion.MustParseSemantic("v1.8.0")
var (
hostIPVersion = utilversion.MustParseSemantic("v1.8.0")
podUIDVersion = utilversion.MustParseSemantic("v1.8.0")
)

var _ = Describe("[sig-api-machinery] Downward API", func() {
f := framework.NewDefaultFramework("downward-api")
Expand Down Expand Up @@ -198,6 +201,28 @@ var _ = Describe("[sig-api-machinery] Downward API", func() {

testDownwardAPIUsingPod(f, pod, env, expectations)
})

It("should provide pod UID as env vars [Conformance]", func() {
framework.SkipUnlessServerVersionGTE(podUIDVersion, f.ClientSet.Discovery())
podName := "downward-api-" + string(uuid.NewUUID())
env := []v1.EnvVar{
{
Name: "POD_UID",
ValueFrom: &v1.EnvVarSource{
FieldRef: &v1.ObjectFieldSelector{
APIVersion: "v1",
FieldPath: "metadata.uid",
},
},
},
}

expectations := []string{
fmt.Sprintf("POD_UID=[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}"),
}

testDownwardAPI(f, podName, env, expectations)
})
})

func testDownwardAPI(f *framework.Framework, podName string, env []v1.EnvVar, expectations []string) {
Expand Down

0 comments on commit d7e56d5

Please sign in to comment.