Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
d46cbfd3
Commit
d46cbfd3
authored
Jul 08, 2016
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turn pkg/api/pod_example.json into go struct to avoid noise in pprof
parent
61cde636
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
121 deletions
+108
-121
conversion_test.go
pkg/api/conversion_test.go
+1
-9
deep_copy_test.go
pkg/api/deep_copy_test.go
+107
-10
pod_example.json
pkg/api/pod_example.json
+0
-102
No files found.
pkg/api/conversion_test.go
View file @
d46cbfd3
...
@@ -38,15 +38,7 @@ func BenchmarkPodConversion(b *testing.B) {
...
@@ -38,15 +38,7 @@ func BenchmarkPodConversion(b *testing.B) {
}
}
// add a fixed item
// add a fixed item
data
,
err
:=
ioutil
.
ReadFile
(
"pod_example.json"
)
items
=
append
(
items
,
benchmarkPod
)
if
err
!=
nil
{
b
.
Fatalf
(
"Unexpected error while reading file: %v"
,
err
)
}
var
pod
api
.
Pod
if
err
:=
runtime
.
DecodeInto
(
testapi
.
Default
.
Codec
(),
data
,
&
pod
);
err
!=
nil
{
b
.
Fatalf
(
"Unexpected error decoding pod: %v"
,
err
)
}
items
=
append
(
items
,
pod
)
width
:=
len
(
items
)
width
:=
len
(
items
)
scheme
:=
api
.
Scheme
scheme
:=
api
.
Scheme
...
...
pkg/api/deep_copy_test.go
View file @
d46cbfd3
...
@@ -19,32 +19,129 @@ package api_test
...
@@ -19,32 +19,129 @@ package api_test
import
(
import
(
"io/ioutil"
"io/ioutil"
"testing"
"testing"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/types"
)
)
func
BenchmarkPodCopy
(
b
*
testing
.
B
)
{
func
parseTimeOrDie
(
ts
string
)
unversioned
.
Time
{
data
,
err
:=
ioutil
.
ReadFile
(
"pod_example.json"
)
t
,
err
:=
time
.
Parse
(
time
.
RFC3339
,
ts
)
if
err
!=
nil
{
if
err
!=
nil
{
b
.
Fatalf
(
"Unexpected error while reading file: %v"
,
err
)
panic
(
err
)
}
var
pod
api
.
Pod
if
err
:=
runtime
.
DecodeInto
(
testapi
.
Default
.
Codec
(),
data
,
&
pod
);
err
!=
nil
{
b
.
Fatalf
(
"Unexpected error decoding pod: %v"
,
err
)
}
}
return
unversioned
.
Time
{
Time
:
t
}
}
var
benchmarkPod
api
.
Pod
=
api
.
Pod
{
TypeMeta
:
unversioned
.
TypeMeta
{
Kind
:
"Pod"
,
APIVersion
:
"v1"
,
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"etcd-server-e2e-test-wojtekt-master"
,
Namespace
:
"default"
,
SelfLink
:
"/api/v1/namespaces/default/pods/etcd-server-e2e-test-wojtekt-master"
,
UID
:
types
.
UID
(
"a671734a-e8e5-11e4-8fde-42010af09327"
),
ResourceVersion
:
"22"
,
CreationTimestamp
:
parseTimeOrDie
(
"2015-04-22T11:49:36Z"
),
Annotations
:
map
[
string
]
string
{
"kubernetes.io/config.mirror"
:
"mirror"
,
"kubernetes.io/config.source"
:
"file"
,
},
},
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{
{
Name
:
"varetcd"
,
VolumeSource
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
Path
:
"/mnt/master-pd/var/etcd"
,
},
},
},
},
Containers
:
[]
api
.
Container
{
{
Name
:
"etcd-container"
,
Image
:
"gcr.io/google_containers/etcd:2.0.9"
,
Command
:
[]
string
{
"/usr/local/bin/etcd"
,
"--addr"
,
"127.0.0.1:4001"
,
"--bind-addr"
,
"127.0.0.1:4001"
,
"--data-dir"
,
"/var/etcd/data"
,
},
Ports
:
[]
api
.
ContainerPort
{
{
Name
:
"serverport"
,
HostPort
:
2380
,
ContainerPort
:
2380
,
Protocol
:
"TCP"
,
},
{
Name
:
"clientport"
,
HostPort
:
4001
,
ContainerPort
:
4001
,
Protocol
:
"TCP"
,
},
},
VolumeMounts
:
[]
api
.
VolumeMount
{
{
Name
:
"varetcd"
,
MountPath
:
"/var/etcd"
,
},
},
TerminationMessagePath
:
"/dev/termination-log"
,
ImagePullPolicy
:
api
.
PullIfNotPresent
,
},
},
RestartPolicy
:
api
.
RestartPolicyAlways
,
DNSPolicy
:
api
.
DNSClusterFirst
,
NodeName
:
"e2e-test-wojtekt-master"
,
},
Status
:
api
.
PodStatus
{
Phase
:
api
.
PodRunning
,
Conditions
:
[]
api
.
PodCondition
{
{
Type
:
api
.
PodReady
,
Status
:
api
.
ConditionTrue
,
},
},
ContainerStatuses
:
[]
api
.
ContainerStatus
{
{
Name
:
"etcd-container"
,
State
:
api
.
ContainerState
{
Running
:
&
api
.
ContainerStateRunning
{
StartedAt
:
parseTimeOrDie
(
"2015-04-22T11:49:32Z"
),
},
},
Ready
:
true
,
RestartCount
:
0
,
Image
:
"gcr.io/google_containers/etcd:2.0.9"
,
ImageID
:
"docker://b6b9a86dc06aa1361357ca1b105feba961f6a4145adca6c54e142c0be0fe87b0"
,
ContainerID
:
"docker://3cbbf818f1addfc252957b4504f56ef2907a313fe6afc47fc75373674255d46d"
,
},
},
},
}
func
BenchmarkPodCopy
(
b
*
testing
.
B
)
{
var
result
*
api
.
Pod
var
result
*
api
.
Pod
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
obj
,
err
:=
api
.
Scheme
.
DeepCopy
(
&
p
od
)
obj
,
err
:=
api
.
Scheme
.
DeepCopy
(
&
benchmarkP
od
)
if
err
!=
nil
{
if
err
!=
nil
{
b
.
Fatalf
(
"Unexpected error copying pod: %v"
,
err
)
b
.
Fatalf
(
"Unexpected error copying pod: %v"
,
err
)
}
}
result
=
obj
.
(
*
api
.
Pod
)
result
=
obj
.
(
*
api
.
Pod
)
}
}
if
!
api
.
Semantic
.
DeepEqual
(
p
od
,
*
result
)
{
if
!
api
.
Semantic
.
DeepEqual
(
benchmarkP
od
,
*
result
)
{
b
.
Fatalf
(
"Incorrect copy: expected %v, got %v"
,
p
od
,
*
result
)
b
.
Fatalf
(
"Incorrect copy: expected %v, got %v"
,
benchmarkP
od
,
*
result
)
}
}
}
}
...
...
pkg/api/pod_example.json
deleted
100644 → 0
View file @
61cde636
{
"kind"
:
"Pod"
,
"apiVersion"
:
"v1"
,
"metadata"
:
{
"name"
:
"etcd-server-e2e-test-wojtekt-master"
,
"namespace"
:
"default"
,
"selfLink"
:
"/api/v1/namespaces/default/pods/etcd-server-e2e-test-wojtekt-master"
,
"uid"
:
"a671734a-e8e5-11e4-8fde-42010af09327"
,
"resourceVersion"
:
"22"
,
"creationTimestamp"
:
"2015-04-22T11:49:36Z"
,
"annotations"
:
{
"kubernetes.io/config.mirror"
:
"mirror"
,
"kubernetes.io/config.source"
:
"file"
}
},
"spec"
:
{
"volumes"
:
[
{
"name"
:
"varetcd"
,
"hostPath"
:
{
"path"
:
"/mnt/master-pd/var/etcd"
},
"emptyDir"
:
null
,
"gcePersistentDisk"
:
null
,
"awsElasticBlockStore"
:
null
,
"gitRepo"
:
null
,
"secret"
:
null
,
"nfs"
:
null
,
"iscsi"
:
null
,
"glusterfs"
:
null
}
],
"containers"
:
[
{
"name"
:
"etcd-container"
,
"image"
:
"gcr.io/google_containers/etcd:2.0.9"
,
"command"
:
[
"/usr/local/bin/etcd"
,
"--addr"
,
"127.0.0.1:4001"
,
"--bind-addr"
,
"127.0.0.1:4001"
,
"--data-dir"
,
"/var/etcd/data"
],
"ports"
:
[
{
"name"
:
"serverport"
,
"hostPort"
:
2380
,
"containerPort"
:
2380
,
"protocol"
:
"TCP"
},
{
"name"
:
"clientport"
,
"hostPort"
:
4001
,
"containerPort"
:
4001
,
"protocol"
:
"TCP"
}
],
"resources"
:
{},
"volumeMounts"
:
[
{
"name"
:
"varetcd"
,
"mountPath"
:
"/var/etcd"
}
],
"terminationMessagePath"
:
"/dev/termination-log"
,
"imagePullPolicy"
:
"IfNotPresent"
,
"capabilities"
:
{}
}
],
"restartPolicy"
:
"Always"
,
"dnsPolicy"
:
"ClusterFirst"
,
"nodeName"
:
"e2e-test-wojtekt-master"
,
"hostNetwork"
:
true
},
"status"
:
{
"phase"
:
"Running"
,
"conditions"
:
[
{
"type"
:
"Ready"
,
"status"
:
"True"
}
],
"containerStatuses"
:
[
{
"name"
:
"etcd-container"
,
"state"
:
{
"running"
:
{
"startedAt"
:
"2015-04-22T11:49:32Z"
}
},
"lastState"
:
{},
"ready"
:
true
,
"restartCount"
:
0
,
"image"
:
"gcr.io/google_containers/etcd:2.0.9"
,
"imageID"
:
"docker://b6b9a86dc06aa1361357ca1b105feba961f6a4145adca6c54e142c0be0fe87b0"
,
"containerID"
:
"docker://3cbbf818f1addfc252957b4504f56ef2907a313fe6afc47fc75373674255d46d"
}
]
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment