Skip to content

Commit

Permalink
Fix up in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
dturn committed Jul 27, 2018
1 parent a45680a commit 1ac9a3b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
6 changes: 5 additions & 1 deletion lib/kubernetes-deploy/kubernetes_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def file_path
end

def sync(mediator)
@instance_data = mediator.get_instance(type, name)
@instance_data = mediator.get_instance(fetch_type, name)
end

def deploy_failed?
Expand Down Expand Up @@ -146,6 +146,10 @@ def type
@type || self.class.kind
end

def fetch_type
type
end

def deploy_timed_out?
return false unless deploy_started?
!deploy_succeeded? && !deploy_failed? && (Time.now.utc - @deploy_started_at > timeout)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module KubernetesDeploy
class HorizontalPodAutoscaler < KubernetesResource
TIMEOUT = 30.seconds
TIMEOUT = 5.minutes

def deploy_succeeded?
able_to_scale_condition["status"] == "True"
Expand All @@ -12,7 +12,7 @@ def deploy_failed?
able_to_scale_condition["status"] == "False"
end

def type
def fetch_type
'hpa.v2beta1.autoscaling'
end

Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/hpa/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ spec:
image: busybox
imagePullPolicy: IfNotPresent
command: ["tail", "-f", "/dev/null"]
resources:
requests:
cpu: 200m
memory: 1Gi
20 changes: 6 additions & 14 deletions test/integration/kubernetes_deploy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_full_hello_cloud_set_deploy_succeeds
%r{Deploying Pod/unmanaged-pod-[-\w]+ \(timeout: 60s\)}, # annotation timeout override
"Hello from the command runner!", # unmanaged pod logs
"Result: SUCCESS",
"Successfully deployed 18 resources"
"Successfully deployed 19 resources"
], in_order: true)

assert_logs_match_all([
Expand All @@ -22,12 +22,8 @@ def test_full_hello_cloud_set_deploy_succeeds
%r{DaemonSet/ds-app\s+1 updatedNumberScheduled, 1 desiredNumberScheduled, 1 numberReady},
%r{StatefulSet/stateful-busybox},
%r{Service/redis-external\s+Doesn't require any endpoint},
<<<<<<< HEAD
"- Job/hello-job (timeout: 600s)",
%r{Job/hello-job\s+(Succeeded|Started)},
%r{HorizontalPodAutoscaler/hello-hpa\s+Exists},
=======
>>>>>>> 459b6bd... Re-work tests
])

# Verify that success section isn't duplicated for predeployed resources
Expand Down Expand Up @@ -76,13 +72,9 @@ def test_pruning_works
'ingress(\.extensions)? "web"',
'daemonset(\.extensions)? "ds-app"',
'statefulset(\.apps)? "stateful-busybox"',
<<<<<<< HEAD
'job "hello-job"',
'horizontalpodautoscaler "hello-hpa"',
=======
>>>>>>> 459b6bd... Re-work tests
] # not necessarily listed in this order
expected_msgs = [/Pruned 8 resources and successfully deployed 6 resources/]
expected_msgs = [/Pruned 9 resources and successfully deployed 6 resources/]
expected_pruned.map do |resource|
expected_msgs << /The following resources were pruned:.*#{resource}/
end
Expand Down Expand Up @@ -1067,17 +1059,17 @@ def test_hpa_can_be_successful
assert_deploy_success(deploy_fixtures("hpa"))
assert_logs_match_all([
"Deploying resources:",
"hpa.v2beta1.autoscaling/hello-hpa (timeout: 30s)",
%r{hpa.v2beta1.autoscaling/hello-hpa\s+Succeeded}
"HorizontalPodAutoscaler/hello-hpa (timeout: 300s)",
%r{HorizontalPodAutoscaler/hello-hpa\s+Succeeded}
])
end

def test_hpa_can_fail_when_no_matching_deployment
skip if KUBE_SERVER_VERSION < Gem::Version.new('1.8.0')
assert_deploy_failure(deploy_fixtures("hpa", subset: ["hpa.yml"]))
assert_logs_match_all([
"Deploying hpa.v2beta1.autoscaling/hello-hpa (timeout: 30s)",
"hpa.v2beta1.autoscaling/hello-hpa: FAILED",
"Deploying HorizontalPodAutoscaler/hello-hpa (timeout: 300s)",
"HorizontalPodAutoscaler/hello-hpa: FAILED",
"Final status: FailedGetScale"
])
end
Expand Down

0 comments on commit 1ac9a3b

Please sign in to comment.