Skip to content

Instantly share code, notes, and snippets.

@jbarrick-mesosphere
Created May 29, 2019 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbarrick-mesosphere/da74b9f49c3076f4cdf85a60669740cc to your computer and use it in GitHub Desktop.
Save jbarrick-mesosphere/da74b9f49c3076f4cdf85a60669740cc to your computer and use it in GitHub Desktop.
kudo test framework example
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-instance-nginx
spec:
replicas: 4
selector:
matchLabels:
app: test-framework
template:
metadata:
labels:
app: test-framework
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
apiVersion: kudo.k8s.io/v1alpha1
kind: Instance
metadata:
name: my-instance
spec:
frameworkVersion:
name: test-framework-1.0
kind: FrameworkVersion
namespace: default
➜ kudo git:(harness) ✗ go test -run TestRunWithKudo ./pkg/test/...
2019/05/29 14:33:34 FrameworkController: Registering framework controller.
2019/05/29 14:33:34 FrameworkVersionController: Registering frameworkversion controller.
2019/05/29 14:33:34 InstanceController: Registering instance controller.
2019/05/29 14:33:34 PlanExecutionController: Registering planexecution controller.
2019/05/29 14:33:35 PlanExecutionController: Recieved create event for an instance named: my-instance
2019/05/29 14:33:35 InstanceController: Received create event for an instance named: my-instance
2019/05/29 14:33:35 FrameworkController: Recieved Reconcile request for a framework named: test-framework
2019/05/29 14:33:35 FrameworkVersionController: Recieved Reconcile request for a frameworkversion named: test-framework-1.0
2019/05/29 14:33:35 InstanceController: Recieved Reconcile request for "my-instance"
2019/05/29 14:33:35 PlanExecutionController: Recieved update event for an instance named: my-instance
2019/05/29 14:33:35 InstanceController: Old and new spec matched...
2019/05/29 14:33:35 InstanceController: Going to call plan "deploy"
2019/05/29 14:33:35 InstanceController: Recieved Reconcile request for "my-instance"
2019/05/29 14:33:35 PlanExecutionController: Phase "deploy" Step "deploy" has 1 object(s)
2019/05/29 14:33:35 PlanExecutionController: Recieved create event for an instance named: my-instance-nginx
2019/05/29 14:33:35 PlanExecutionController: Adding "my-instance-deploy-40530024" to reconcile
2019/05/29 14:33:35 PlanExecutionController: CreateOrUpdate resulted in: created
2019/05/29 14:33:35 PlanExecutionController: CreateOrUpdate resulted in: created
2019/05/29 14:33:35 HealthUtil: Deployment my-instance-nginx is NOT healthy. Not enough ready replicas: 0/3
2019/05/29 14:33:35 PlanExecutionController: Obj is NOT healthy: &Deployment{ObjectMeta:k8s_io_apimachinery_pkg_apis_meta_v1.ObjectMeta{Name:my-instance-nginx,GenerateName:,Namespace:707a9d8d-268c-48e9-9727-21cdb63519a6,SelfLink:/apis/apps/v1/namespaces/707a9d8d-268c-48e9-9727-21cdb63519a6/deployments/my-instance-nginx,UID:69e93f7c-8259-11e9-becd-482ae320814d,ResourceVersion:66,Generation:1,CreationTimestamp:2019-05-29 14:33:35 -0700 PDT,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{app: test-framework,heritage: kudo,instance: my-instance,phase: deploy,plan: deploy,planexecution: my-instance-deploy-40530024,step: deploy,version: 1.0,},Annotations:map[string]string{},OwnerReferences:[{kudo.k8s.io/v1alpha1 Instance my-instance 69cf086f-8259-11e9-becd-482ae320814d 0xc000018964 0xc000018965}],Finalizers:[],ClusterName:,Initializers:nil,},Spec:DeploymentSpec{Replicas:*3,Selector:&k8s_io_apimachinery_pkg_apis_meta_v1.LabelSelector{MatchLabels:map[string]string{app: test-framework,heritage: kudo,instance: my-instance,phase: deploy,plan: deploy,planexecution: my-instance-deploy-40530024,step: deploy,version: 1.0,},MatchExpressions:[],},Template:k8s_io_api_core_v1.PodTemplateSpec{ObjectMeta:k8s_io_apimachinery_pkg_apis_meta_v1.ObjectMeta{Name:,GenerateName:,Namespace:,SelfLink:,UID:,ResourceVersion:,Generation:0,CreationTimestamp:0001-01-01 00:00:00 +0000 UTC,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{app: test-framework,heritage: kudo,instance: my-instance,phase: deploy,plan: deploy,planexecution: my-instance-deploy-40530024,step: deploy,version: 1.0,},Annotations:map[string]string{},OwnerReferences:[],Finalizers:[],ClusterName:,Initializers:nil,},Spec:PodSpec{Volumes:[],Containers:[{nginx nginx:1.7.9 [] [] [{ 0 80 TCP }] [] [] {map[] map[]} [] [] nil nil nil /dev/termination-log File IfNotPresent nil false false false}],RestartPolicy:Always,TerminationGracePeriodSeconds:*30,ActiveDeadlineSeconds:nil,DNSPolicy:ClusterFirst,NodeSelector:map[string]string{},ServiceAccountName:,DeprecatedServiceAccount:,NodeName:,HostNetwork:false,HostPID:false,HostIPC:false,SecurityContext:&PodSecurityContext{SELinuxOptions:nil,RunAsUser:nil,RunAsNonRoot:nil,SupplementalGroups:[],FSGroup:nil,RunAsGroup:nil,Sysctls:[],},ImagePullSecrets:[],Hostname:,Subdomain:,Affinity:nil,SchedulerName:default-scheduler,InitContainers:[],AutomountServiceAccountToken:nil,Tolerations:[],HostAliases:[],PriorityClassName:,Priority:nil,DNSConfig:nil,ShareProcessNamespace:nil,ReadinessGates:[],RuntimeClassName:nil,EnableServiceLinks:nil,},},Strategy:DeploymentStrategy{Type:RollingUpdate,RollingUpdate:&RollingUpdateDeployment{MaxUnavailable:25%,MaxSurge:25%,},},MinReadySeconds:0,RevisionHistoryLimit:*10,Paused:false,ProgressDeadlineSeconds:*600,},Status:DeploymentStatus{ObservedGeneration:0,Replicas:0,UpdatedReplicas:0,AvailableReplicas:0,UnavailableReplicas:0,Conditions:[],ReadyReplicas:0,CollisionCount:nil,},}
2019/05/29 14:33:35 PlanExecutionController: Phase "deploy" has strategy parallel
2019/05/29 14:33:35 PlanExecutionController: Looked at step "deploy"
2019/05/29 14:33:35 HealthUtil: Phase deploy is not healthy b/c step deploy is not healthy
2019/05/29 14:33:35 PlanExecutionController: Phase "deploy" not healthy, and plan marked as serial, so breaking.
2019/05/29 14:33:35 HealthUtil: Phase deploy is not healthy b/c step deploy is not healthy
2019/05/29 14:33:35 PlanExecutionController: Recieved update event for an instance named: my-instance
2019/05/29 14:33:35 InstanceController: Old and new spec matched...
2019/05/29 14:33:35 InstanceController: Going to call plan "deploy"
2019/05/29 14:33:35 InstanceController: Recieved Reconcile request for "my-instance"
2019/05/29 14:33:35 PlanExecutionController: Phase "deploy" Step "deploy" has 1 object(s)
2019/05/29 14:33:35 PlanExecutionController: CreateOrUpdate resulted in: unchanged
2019/05/29 14:33:35 PlanExecutionController: CreateOrUpdate resulted in: unchanged
2019/05/29 14:33:35 HealthUtil: Deployment my-instance-nginx is NOT healthy. Not enough ready replicas: 0/3
2019/05/29 14:33:35 PlanExecutionController: Obj is NOT healthy: &Deployment{ObjectMeta:k8s_io_apimachinery_pkg_apis_meta_v1.ObjectMeta{Name:my-instance-nginx,GenerateName:,Namespace:707a9d8d-268c-48e9-9727-21cdb63519a6,SelfLink:/apis/apps/v1/namespaces/707a9d8d-268c-48e9-9727-21cdb63519a6/deployments/my-instance-nginx,UID:69e93f7c-8259-11e9-becd-482ae320814d,ResourceVersion:66,Generation:1,CreationTimestamp:2019-05-29 14:33:35 -0700 PDT,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{app: test-framework,heritage: kudo,instance: my-instance,phase: deploy,plan: deploy,planexecution: my-instance-deploy-40530024,step: deploy,version: 1.0,},Annotations:map[string]string{},OwnerReferences:[{kudo.k8s.io/v1alpha1 Instance my-instance 69cf086f-8259-11e9-becd-482ae320814d 0xc000bebed0 0xc000bebed1}],Finalizers:[],ClusterName:,Initializers:nil,},Spec:DeploymentSpec{Replicas:*3,Selector:&k8s_io_apimachinery_pkg_apis_meta_v1.LabelSelector{MatchLabels:map[string]string{app: test-framework,heritage: kudo,instance: my-instance,phase: deploy,plan: deploy,planexecution: my-instance-deploy-40530024,step: deploy,version: 1.0,},MatchExpressions:[],},Template:k8s_io_api_core_v1.PodTemplateSpec{ObjectMeta:k8s_io_apimachinery_pkg_apis_meta_v1.ObjectMeta{Name:,GenerateName:,Namespace:,SelfLink:,UID:,ResourceVersion:,Generation:0,CreationTimestamp:0001-01-01 00:00:00 +0000 UTC,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{app: test-framework,heritage: kudo,instance: my-instance,phase: deploy,plan: deploy,planexecution: my-instance-deploy-40530024,step: deploy,version: 1.0,},Annotations:map[string]string{},OwnerReferences:[],Finalizers:[],ClusterName:,Initializers:nil,},Spec:PodSpec{Volumes:[],Containers:[{nginx nginx:1.7.9 [] [] [{ 0 80 TCP }] [] [] {map[] map[]} [] [] nil nil nil /dev/termination-log File IfNotPresent nil false false false}],RestartPolicy:Always,TerminationGracePeriodSeconds:*30,ActiveDeadlineSeconds:nil,DNSPolicy:ClusterFirst,NodeSelector:map[string]string{},ServiceAccountName:,DeprecatedServiceAccount:,NodeName:,HostNetwork:false,HostPID:false,HostIPC:false,SecurityContext:&PodSecurityContext{SELinuxOptions:nil,RunAsUser:nil,RunAsNonRoot:nil,SupplementalGroups:[],FSGroup:nil,RunAsGroup:nil,Sysctls:[],},ImagePullSecrets:[],Hostname:,Subdomain:,Affinity:nil,SchedulerName:default-scheduler,InitContainers:[],AutomountServiceAccountToken:nil,Tolerations:[],HostAliases:[],PriorityClassName:,Priority:nil,DNSConfig:nil,ShareProcessNamespace:nil,ReadinessGates:[],RuntimeClassName:nil,EnableServiceLinks:nil,},},Strategy:DeploymentStrategy{Type:RollingUpdate,RollingUpdate:&RollingUpdateDeployment{MaxUnavailable:25%,MaxSurge:25%,},},MinReadySeconds:0,RevisionHistoryLimit:*10,Paused:false,ProgressDeadlineSeconds:*600,},Status:DeploymentStatus{ObservedGeneration:0,Replicas:0,UpdatedReplicas:0,AvailableReplicas:0,UnavailableReplicas:0,Conditions:[],ReadyReplicas:0,CollisionCount:nil,},}
2019/05/29 14:33:35 PlanExecutionController: Phase "deploy" has strategy parallel
2019/05/29 14:33:35 PlanExecutionController: Looked at step "deploy"
2019/05/29 14:33:35 HealthUtil: Phase deploy is not healthy b/c step deploy is not healthy
2019/05/29 14:33:35 PlanExecutionController: Phase "deploy" not healthy, and plan marked as serial, so breaking.
2019/05/29 14:33:35 HealthUtil: Phase deploy is not healthy b/c step deploy is not healthy
2019/05/29 14:33:35 PlanExecutionController: Phase "deploy" Step "deploy" has 1 object(s)
2019/05/29 14:33:35 PlanExecutionController: CreateOrUpdate resulted in: unchanged
2019/05/29 14:33:35 PlanExecutionController: CreateOrUpdate resulted in: unchanged
2019/05/29 14:33:35 HealthUtil: Deployment my-instance-nginx is NOT healthy. Not enough ready replicas: 0/3
2019/05/29 14:33:35 PlanExecutionController: Obj is NOT healthy: &Deployment{ObjectMeta:k8s_io_apimachinery_pkg_apis_meta_v1.ObjectMeta{Name:my-instance-nginx,GenerateName:,Namespace:707a9d8d-268c-48e9-9727-21cdb63519a6,SelfLink:/apis/apps/v1/namespaces/707a9d8d-268c-48e9-9727-21cdb63519a6/deployments/my-instance-nginx,UID:69e93f7c-8259-11e9-becd-482ae320814d,ResourceVersion:66,Generation:1,CreationTimestamp:2019-05-29 14:33:35 -0700 PDT,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{app: test-framework,heritage: kudo,instance: my-instance,phase: deploy,plan: deploy,planexecution: my-instance-deploy-40530024,step: deploy,version: 1.0,},Annotations:map[string]string{},OwnerReferences:[{kudo.k8s.io/v1alpha1 Instance my-instance 69cf086f-8259-11e9-becd-482ae320814d 0xc000d0fdd0 0xc000d0fdd1}],Finalizers:[],ClusterName:,Initializers:nil,},Spec:DeploymentSpec{Replicas:*3,Selector:&k8s_io_apimachinery_pkg_apis_meta_v1.LabelSelector{MatchLabels:map[string]string{app: test-framework,heritage: kudo,instance: my-instance,phase: deploy,plan: deploy,planexecution: my-instance-deploy-40530024,step: deploy,version: 1.0,},MatchExpressions:[],},Template:k8s_io_api_core_v1.PodTemplateSpec{ObjectMeta:k8s_io_apimachinery_pkg_apis_meta_v1.ObjectMeta{Name:,GenerateName:,Namespace:,SelfLink:,UID:,ResourceVersion:,Generation:0,CreationTimestamp:0001-01-01 00:00:00 +0000 UTC,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{app: test-framework,heritage: kudo,instance: my-instance,phase: deploy,plan: deploy,planexecution: my-instance-deploy-40530024,step: deploy,version: 1.0,},Annotations:map[string]string{},OwnerReferences:[],Finalizers:[],ClusterName:,Initializers:nil,},Spec:PodSpec{Volumes:[],Containers:[{nginx nginx:1.7.9 [] [] [{ 0 80 TCP }] [] [] {map[] map[]} [] [] nil nil nil /dev/termination-log File IfNotPresent nil false false false}],RestartPolicy:Always,TerminationGracePeriodSeconds:*30,ActiveDeadlineSeconds:nil,DNSPolicy:ClusterFirst,NodeSelector:map[string]string{},ServiceAccountName:,DeprecatedServiceAccount:,NodeName:,HostNetwork:false,HostPID:false,HostIPC:false,SecurityContext:&PodSecurityContext{SELinuxOptions:nil,RunAsUser:nil,RunAsNonRoot:nil,SupplementalGroups:[],FSGroup:nil,RunAsGroup:nil,Sysctls:[],},ImagePullSecrets:[],Hostname:,Subdomain:,Affinity:nil,SchedulerName:default-scheduler,InitContainers:[],AutomountServiceAccountToken:nil,Tolerations:[],HostAliases:[],PriorityClassName:,Priority:nil,DNSConfig:nil,ShareProcessNamespace:nil,ReadinessGates:[],RuntimeClassName:nil,EnableServiceLinks:nil,},},Strategy:DeploymentStrategy{Type:RollingUpdate,RollingUpdate:&RollingUpdateDeployment{MaxUnavailable:25%,MaxSurge:25%,},},MinReadySeconds:0,RevisionHistoryLimit:*10,Paused:false,ProgressDeadlineSeconds:*600,},Status:DeploymentStatus{ObservedGeneration:0,Replicas:0,UpdatedReplicas:0,AvailableReplicas:0,UnavailableReplicas:0,Conditions:[],ReadyReplicas:0,CollisionCount:nil,},}
2019/05/29 14:33:35 PlanExecutionController: Phase "deploy" has strategy parallel
2019/05/29 14:33:35 PlanExecutionController: Looked at step "deploy"
2019/05/29 14:33:35 HealthUtil: Phase deploy is not healthy b/c step deploy is not healthy
2019/05/29 14:33:35 PlanExecutionController: Phase "deploy" not healthy, and plan marked as serial, so breaking.
2019/05/29 14:33:35 HealthUtil: Phase deploy is not healthy b/c step deploy is not healthy
2019/05/29 14:33:45 PlanExecutionController: Recieved delete event for an instance named: my-instance
2019/05/29 14:33:45 InstanceController: Received delete event for an instance named: my-instance
E0529 14:33:45.260916 6729 reflector.go:251] pkg/mod/k8s.io/client-go@v0.0.0-20181213151034-8d9ed539ba31/tools/cache/reflector.go:95: Failed to watch *v1.Job: Get http://127.0.0.1:40197/apis/batch/v1/jobs?resourceVersion=1&timeoutSeconds=390&watch=true: dial tcp 127.0.0.1:40197: connect: connection refused
E0529 14:33:45.260921 6729 reflector.go:251] pkg/mod/k8s.io/client-go@v0.0.0-20181213151034-8d9ed539ba31/tools/cache/reflector.go:95: Failed to watch *v1.Deployment: Get http://127.0.0.1:40197/apis/apps/v1/deployments?resourceVersion=66&timeoutSeconds=329&watch=true: dial tcp 127.0.0.1:40197: connect: connection refused
E0529 14:33:45.260921 6729 reflector.go:251] pkg/mod/k8s.io/client-go@v0.0.0-20181213151034-8d9ed539ba31/tools/cache/reflector.go:95: Failed to watch *v1alpha1.FrameworkVersion: Get http://127.0.0.1:40197/apis/kudo.k8s.io/v1alpha1/frameworkversions?resourceVersion=59&timeoutSeconds=454&watch=true: dial tcp 127.0.0.1:40197: connect: connection refused
E0529 14:33:45.260987 6729 reflector.go:251] pkg/mod/k8s.io/client-go@v0.0.0-20181213151034-8d9ed539ba31/tools/cache/reflector.go:95: Failed to watch *v1alpha1.Framework: Get http://127.0.0.1:40197/apis/kudo.k8s.io/v1alpha1/frameworks?resourceVersion=58&timeoutSeconds=544&watch=true: dial tcp 127.0.0.1:40197: connect: connection refused
E0529 14:33:45.261030 6729 reflector.go:251] pkg/mod/k8s.io/client-go@v0.0.0-20181213151034-8d9ed539ba31/tools/cache/reflector.go:95: Failed to watch *v1.StatefulSet: Get http://127.0.0.1:40197/apis/apps/v1/statefulsets?resourceVersion=1&timeoutSeconds=346&watch=true: dial tcp 127.0.0.1:40197: connect: connection refused
E0529 14:33:45.261252 6729 reflector.go:251] pkg/mod/k8s.io/client-go@v0.0.0-20181213151034-8d9ed539ba31/tools/cache/reflector.go:95: Failed to watch *v1alpha1.Instance: Get http://127.0.0.1:40197/apis/kudo.k8s.io/v1alpha1/instances?resourceVersion=70&timeoutSeconds=414&watch=true: dial tcp 127.0.0.1:40197: connect: connection refused
E0529 14:33:45.261256 6729 reflector.go:251] pkg/mod/k8s.io/client-go@v0.0.0-20181213151034-8d9ed539ba31/tools/cache/reflector.go:95: Failed to watch *v1alpha1.PlanExecution: Get http://127.0.0.1:40197/apis/kudo.k8s.io/v1alpha1/planexecutions?resourceVersion=68&timeoutSeconds=364&watch=true: dial tcp 127.0.0.1:40197: connect: connection refused
--- FAIL: TestRunWithKudo (14.24s)
--- FAIL: TestRunWithKudo/harness (0.00s)
--- FAIL: TestRunWithKudo/harness/framework-test (10.23s)
logger.go:30: framework-test/0-framework | starting test stage 0-framework
logger.go:30: framework-test/0-framework | creating resource: Instance:707a9d8d-268c-48e9-9727-21cdb63519a6/my-instance
harness.go:95: --- Deployment:707a9d8d-268c-48e9-9727-21cdb63519a6/my-instance-nginx
+++ Deployment:707a9d8d-268c-48e9-9727-21cdb63519a6/my-instance-nginx
@@ -1,21 +1,70 @@
apiVersion: apps/v1
kind: Deployment
metadata:
+ labels:
+ app: test-framework
+ heritage: kudo
+ instance: my-instance
+ phase: deploy
+ plan: deploy
+ planexecution: my-instance-deploy-40530024
+ step: deploy
+ version: "1.0"
name: my-instance-nginx
namespace: 707a9d8d-268c-48e9-9727-21cdb63519a6
+ ownerReferences:
+ - apiVersion: kudo.k8s.io/v1alpha1
+ blockOwnerDeletion: true
+ controller: true
+ kind: Instance
+ name: my-instance
+ uid: 69cf086f-8259-11e9-becd-482ae320814d
spec:
- replicas: 4
+ progressDeadlineSeconds: 600
+ replicas: 3
+ revisionHistoryLimit: 10
selector:
matchLabels:
app: test-framework
+ heritage: kudo
+ instance: my-instance
+ phase: deploy
+ plan: deploy
+ planexecution: my-instance-deploy-40530024
+ step: deploy
+ version: "1.0"
+ strategy:
+ rollingUpdate:
+ maxSurge: 25%
+ maxUnavailable: 25%
+ type: RollingUpdate
template:
metadata:
+ creationTimestamp: null
labels:
app: test-framework
+ heritage: kudo
+ instance: my-instance
+ phase: deploy
+ plan: deploy
+ planexecution: my-instance-deploy-40530024
+ step: deploy
+ version: "1.0"
spec:
containers:
- image: nginx:1.7.9
+ imagePullPolicy: IfNotPresent
name: nginx
ports:
- containerPort: 80
+ protocol: TCP
+ resources: {}
+ terminationMessagePath: /dev/termination-log
+ terminationMessagePolicy: File
+ dnsPolicy: ClusterFirst
+ restartPolicy: Always
+ schedulerName: default-scheduler
+ securityContext: {}
+ terminationGracePeriodSeconds: 30
+status: {}
harness.go:95: resource Deployment:707a9d8d-268c-48e9-9727-21cdb63519a6/my-instance-nginx: .spec.replicas: value mismatch: 4 != 3
harness.go:98: failed in stage 0-framework
FAIL
FAIL github.com/kudobuilder/kudo/pkg/test 14.283s
ok github.com/kudobuilder/kudo/pkg/test/utils (cached) [no tests to run]
➜ kudo git:(harness) ✗
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment