Skip to content

Commit

Permalink
[430] Refactor cluster creation
Browse files Browse the repository at this point in the history
  • Loading branch information
zipofar committed Jun 20, 2023
1 parent a07b15e commit 89a6685
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 0 additions & 1 deletion core/app/services/uffizzi_core/cluster_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def deploy_cluster(cluster)
return cluster.fail!
end


UffizziCore::Cluster::ManageDeployingJob.perform_in(5.seconds, cluster.id)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ class UffizziCore::Api::Cli::V1::Projects::ClustersControllerTest < ActionContro
},
}

data = json_fixture('files/controller/cluster_not_ready.json')
stubbed_create_cluster_request = stub_create_cluster_request(data)
cluster_creation_data = json_fixture('files/controller/cluster_not_ready.json')
stubbed_create_namespace_request = stub_create_namespace_request
stubbed_create_cluster_request = stub_create_cluster_request(cluster_creation_data)
cluster_show_data = json_fixture('files/controller/cluster_ready.json')
stubbed_cluster_request = stub_get_cluster_request(cluster_show_data)

differences = {
-> { UffizziCore::Cluster.count } => 1,
Expand All @@ -50,6 +52,7 @@ class UffizziCore::Api::Cli::V1::Projects::ClustersControllerTest < ActionContro
assert_response(:success)
assert_requested(stubbed_create_cluster_request)
assert_requested(stubbed_create_namespace_request)
assert_requested(stubbed_cluster_request)
end

test '#create when enabled cluster with the same name exists' do
Expand Down Expand Up @@ -85,9 +88,11 @@ class UffizziCore::Api::Cli::V1::Projects::ClustersControllerTest < ActionContro
},
}

data = json_fixture('files/controller/cluster_not_ready.json')
stubbed_create_cluster_request = stub_create_cluster_request(data)
cluster_creation_data = json_fixture('files/controller/cluster_not_ready.json')
stubbed_create_namespace_request = stub_create_namespace_request
stubbed_create_cluster_request = stub_create_cluster_request(cluster_creation_data)
cluster_show_data = json_fixture('files/controller/cluster_ready.json')
stubbed_cluster_request = stub_get_cluster_request(cluster_show_data)

differences = {
-> { UffizziCore::Cluster.count } => 1,
Expand All @@ -100,12 +105,11 @@ class UffizziCore::Api::Cli::V1::Projects::ClustersControllerTest < ActionContro
assert_response(:success)
assert_requested(stubbed_create_cluster_request)
assert_requested(stubbed_create_namespace_request)
assert_requested(stubbed_cluster_request)
end

test '#show' do
cluster = create(:cluster, project: @project, deployed_by: @user, name: 'test')
data = json_fixture('files/controller/cluster_ready.json')
stubbed_cluster_request = stub_get_cluster_request(data)

params = {
project_slug: @project.slug,
Expand All @@ -115,7 +119,6 @@ class UffizziCore::Api::Cli::V1::Projects::ClustersControllerTest < ActionContro
get :show, params: params, format: :json

assert_response(:success)
assert_requested(stubbed_cluster_request)
end

test '#destroy' do
Expand Down
2 changes: 2 additions & 0 deletions core/test/dummy/config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ continuous_preview:
deployment:
subdomain:
length_limit: 63
vcluster:
max_creation_retry_count: 5

0 comments on commit 89a6685

Please sign in to comment.