Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jrjyipee committed Aug 9, 2018
1 parent 8a7d658 commit 974d683
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 16 deletions.
45 changes: 33 additions & 12 deletions deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ type labelSelectorRequirementResolver struct {

type rollingUpdateDeploymentResolver struct {
ctx context.Context
r *rollingUpdateDeployment
r rollingUpdateDeployment
}

type podTemplateSpecResolver struct {
Expand Down Expand Up @@ -191,22 +191,40 @@ func mapToStrategy(strat *JsonObject) *deploymentStrategy {
return &deploymentStrategy{nil, sType}
}

rudg := jgetter(*updateItem)
is := rudg.intRefItemOr("maxSurge", nil)
iu := rudg.intRefItemOr("maxUnavailable", nil)
ms := rudg.stringRefItemOr("maxSurgeString", nil)
mu := rudg.stringRefItemOr("maxUnavailableString", nil)
sval, spresent := (*updateItem)["maxSurge"]
uval, upresent := (*updateItem)["maxUnavailable"]
var ss, su string
var is, iu int32
var ssptr *string = nil
var suptr *string = nil
var isptr *int32 = nil
var iuptr *int32 = nil
defval := "25%"

if is == nil && ms == nil {
ms = &defval
if !spresent {
ss = defval
ssptr = &ss
} else if ssval, ok := sval.(string); ok {
ss = ssval
ssptr = &ss
} else {
is = toGQLInt(sval)
isptr = &is
}

if iu == nil && mu == nil {
mu = &defval
if !upresent {
su = defval
suptr = &su
} else if suval, ok := uval.(string); ok {
su = suval
suptr = &su
} else {
iu = toGQLInt(uval)
iuptr = &iu
}

return &deploymentStrategy{&rollingUpdateDeployment{is, ms, iu, mu},
return &deploymentStrategy{
&rollingUpdateDeployment{isptr, ssptr, iuptr, suptr},
sType}
}

Expand Down Expand Up @@ -357,7 +375,10 @@ func (r *deploymentResolver) ReplicaSets() []*replicaSetResolver {
}

func (r deploymentStrategyResolver) RollingUpdate() *rollingUpdateDeploymentResolver {
return &rollingUpdateDeploymentResolver{r.ctx, r.d.RollingUpdate}
if r.d.RollingUpdate == nil {
return nil
}
return &rollingUpdateDeploymentResolver{r.ctx, *r.d.RollingUpdate}
}

func (r deploymentStrategyResolver) Type() *string {
Expand Down
107 changes: 104 additions & 3 deletions get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,40 @@ func TestPods(t *testing.T) {
}
}
}
replicaSets {
metadata {
name
}
pods {
metadata {
name
namespace
labels {
name
value
}
}
spec {
dnsPolicy
nodeName
restartPolicy
schedulerName
serviceAccountName
terminationGracePeriodSeconds
tolerations {
effect
key
operator
tolerationSeconds
}
volumes {
name
persistentVolumeClaim { claimName readOnly }
secret { defaultMode secretName }
}
}
}
}
}}`,
`{"allDeployments": [
{
Expand Down Expand Up @@ -173,8 +207,75 @@ func TestPods(t *testing.T) {
]
}
}
}
},
"replicaSets": [
{
"metadata": {
"name": "clunky-sabertooth-joomla-5d4ddc985d"
},
"pods": [
{
"metadata": {
"name": "clunky-sabertooth-joomla-5d4ddc985d-fpddz",
"namespace": "default",
"labels": [
{"name": "app", "value": "clunky-sabertooth-joomla"},
{"name": "pod-template-hash", "value": "1808875418"}
]
},
"spec": {
"dnsPolicy": "ClusterFirst",
"nodeName": "minikube",
"restartPolicy": "Always",
"schedulerName": "default-scheduler",
"serviceAccountName": "default",
"terminationGracePeriodSeconds": 30,
"tolerations": [
{
"effect": "NoExecute",
"key": "node.kubernetes.io/not-ready",
"operator": "Exists",
"tolerationSeconds": 300
},
{
"effect": "NoExecute",
"key": "node.kubernetes.io/unreachable",
"operator": "Exists",
"tolerationSeconds": 300
}
],
"volumes": [
{
"name": "joomla-data",
"persistentVolumeClaim": {
"claimName": "clunky-sabertooth-joomla-joomla",
"readOnly": false
},
"secret": null
},
{
"name": "apache-data",
"persistentVolumeClaim": {
"claimName": "clunky-sabertooth-joomla-apache",
"readOnly": false
},
"secret": null
},
{
"name": "default-token-l6lb2",
"persistentVolumeClaim": null,
"secret": {
"defaultMode": 420,
"secretName": "default-token-l6lb2"
}
}
]
}
}
]
}
]
}
]
}`)
]
}`)
}
2 changes: 1 addition & 1 deletion vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,5 @@
"revisionTime": "2017-02-01T04:15:14Z"
}
],
"rootPath": "auth"
"rootPath": "kubeiql"
}

0 comments on commit 974d683

Please sign in to comment.