Commit c1f84f3a authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #35094 from chenchun/annotations

Automatic merge from submit-queue kubectl describe: show annotations Fixes https://github.com/kubernetes/kubernetes/issues/23380
parents dac0296f b605da25
...@@ -1265,3 +1265,37 @@ func TestDescribeEvents(t *testing.T) { ...@@ -1265,3 +1265,37 @@ func TestDescribeEvents(t *testing.T) {
} }
} }
} }
func TestPrintLabelsMultiline(t *testing.T) {
var maxLenAnnotationStr string = "MaxLenAnnotation=Multicast addressing can be used in the link layer (Layer 2 in the OSI model), such as Ethernet multicast, and at the internet layer (Layer 3 for OSI) for Internet Protocol Version 4 "
testCases := []struct {
annotations map[string]string
expectPrint string
}{
{
annotations: map[string]string{"col1": "asd", "COL2": "zxc"},
expectPrint: "Annotations:\tCOL2=zxc\n\tcol1=asd\n",
},
{
annotations: map[string]string{"MaxLenAnnotation": maxLenAnnotationStr[17:]},
expectPrint: "Annotations:\t" + maxLenAnnotationStr + "\n",
},
{
annotations: map[string]string{"MaxLenAnnotation": maxLenAnnotationStr[17:] + "1"},
expectPrint: "Annotations:\t" + maxLenAnnotationStr + "...\n",
},
{
annotations: map[string]string{},
expectPrint: "Annotations:\t<none>\n",
},
}
for i, testCase := range testCases {
out := new(bytes.Buffer)
writer := &PrefixWriter{out}
printAnnotationsMultiline(writer, "Annotations", testCase.annotations)
output := out.String()
if output != testCase.expectPrint {
t.Errorf("Test case %d: expected to find %q in output: %q", i, testCase.expectPrint, output)
}
}
}
...@@ -718,6 +718,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -718,6 +718,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
{"Node:"}, {"Node:"},
{"Labels:", "app=redis"}, {"Labels:", "app=redis"},
{"role=master"}, {"role=master"},
{"Annotations:"},
{"Status:", "Running"}, {"Status:", "Running"},
{"IP:"}, {"IP:"},
{"Controllers:", "ReplicationController/redis-master"}, {"Controllers:", "ReplicationController/redis-master"},
...@@ -737,6 +738,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -737,6 +738,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
{"Selector:", "app=redis,role=master"}, {"Selector:", "app=redis,role=master"},
{"Labels:", "app=redis"}, {"Labels:", "app=redis"},
{"role=master"}, {"role=master"},
{"Annotations:"},
{"Replicas:", "1 current", "1 desired"}, {"Replicas:", "1 current", "1 desired"},
{"Pods Status:", "1 Running", "0 Waiting", "0 Succeeded", "0 Failed"}, {"Pods Status:", "1 Running", "0 Waiting", "0 Succeeded", "0 Failed"},
// {"Events:"} would ordinarily go in the list // {"Events:"} would ordinarily go in the list
...@@ -754,6 +756,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -754,6 +756,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
{"Namespace:", ns}, {"Namespace:", ns},
{"Labels:", "app=redis"}, {"Labels:", "app=redis"},
{"role=master"}, {"role=master"},
{"Annotations:"},
{"Selector:", "app=redis", "role=master"}, {"Selector:", "app=redis", "role=master"},
{"Type:", "ClusterIP"}, {"Type:", "ClusterIP"},
{"IP:"}, {"IP:"},
...@@ -771,6 +774,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -771,6 +774,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
requiredStrings = [][]string{ requiredStrings = [][]string{
{"Name:", node.Name}, {"Name:", node.Name},
{"Labels:"}, {"Labels:"},
{"Annotations:"},
{"CreationTimestamp:"}, {"CreationTimestamp:"},
{"Conditions:"}, {"Conditions:"},
{"Type", "Status", "LastHeartbeatTime", "LastTransitionTime", "Reason", "Message"}, {"Type", "Status", "LastHeartbeatTime", "LastTransitionTime", "Reason", "Message"},
...@@ -790,6 +794,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -790,6 +794,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
requiredStrings = [][]string{ requiredStrings = [][]string{
{"Name:", ns}, {"Name:", ns},
{"Labels:"}, {"Labels:"},
{"Annotations:"},
{"Status:", "Active"}} {"Status:", "Active"}}
checkOutput(output, requiredStrings) checkOutput(output, requiredStrings)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment