-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #207 from Argonus/support-cached-endpoints
Add resource version parameter for kubernetes strategy
- Loading branch information
Showing
5 changed files
with
175 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,60 @@ defmodule Cluster.Strategy.KubernetesTest do | |
end | ||
end | ||
|
||
test "works with cached resources" do | ||
use_cassette "kubernetes", custom: true do | ||
capture_log(fn -> | ||
start_supervised!({Kubernetes, | ||
[ | ||
%Cluster.Strategy.State{ | ||
topology: :name, | ||
config: [ | ||
kubernetes_node_basename: "test_basename", | ||
kubernetes_selector: "app=test_selector", | ||
kubernetes_use_cached_resources: true, | ||
# If you want to run the test freshly, you'll need to create a DNS Entry | ||
kubernetes_master: "cluster.localhost.", | ||
kubernetes_service_account_path: | ||
Path.join([__DIR__, "fixtures", "kubernetes", "service_account"]) | ||
], | ||
connect: {Nodes, :connect, [self()]}, | ||
disconnect: {Nodes, :disconnect, [self()]}, | ||
list_nodes: {Nodes, :list_nodes, [[]]} | ||
} | ||
]}) | ||
|
||
assert_receive {:connect, _}, 5_000 | ||
end) | ||
end | ||
end | ||
|
||
test "works with no cached resources" do | ||
use_cassette "kubernetes", custom: true do | ||
capture_log(fn -> | ||
start_supervised!({Kubernetes, | ||
[ | ||
%Cluster.Strategy.State{ | ||
topology: :name, | ||
config: [ | ||
kubernetes_node_basename: "test_basename", | ||
kubernetes_selector: "app=test_selector", | ||
kubernetes_use_cached_resources: false, | ||
# If you want to run the test freshly, you'll need to create a DNS Entry | ||
kubernetes_master: "cluster.localhost.", | ||
kubernetes_service_account_path: | ||
Path.join([__DIR__, "fixtures", "kubernetes", "service_account"]) | ||
], | ||
connect: {Nodes, :connect, [self()]}, | ||
disconnect: {Nodes, :disconnect, [self()]}, | ||
list_nodes: {Nodes, :list_nodes, [[]]} | ||
} | ||
]}) | ||
|
||
assert_receive {:connect, _}, 5_000 | ||
end) | ||
end | ||
end | ||
|
||
test "works with dns and cluster_name" do | ||
use_cassette "kubernetes", custom: true do | ||
capture_log(fn -> | ||
|
@@ -201,6 +255,34 @@ defmodule Cluster.Strategy.KubernetesTest do | |
end | ||
end | ||
|
||
test "works with pods and cached resources" do | ||
use_cassette "kubernetes_pods", custom: true do | ||
capture_log(fn -> | ||
start_supervised!({Kubernetes, | ||
[ | ||
%Cluster.Strategy.State{ | ||
topology: :name, | ||
config: [ | ||
kubernetes_node_basename: "test_basename", | ||
kubernetes_selector: "app=test_selector", | ||
# If you want to run the test freshly, you'll need to create a DNS Entry | ||
kubernetes_master: "cluster.localhost.", | ||
kubernetes_ip_lookup_mode: :pods, | ||
kubernetes_use_cached_resources: true, | ||
kubernetes_service_account_path: | ||
Path.join([__DIR__, "fixtures", "kubernetes", "service_account"]) | ||
], | ||
connect: {Nodes, :connect, [self()]}, | ||
disconnect: {Nodes, :disconnect, [self()]}, | ||
list_nodes: {Nodes, :list_nodes, [[]]} | ||
} | ||
]}) | ||
|
||
assert_receive {:connect, :"[email protected]"}, 5_000 | ||
end) | ||
end | ||
end | ||
|
||
test "works with pods and dns" do | ||
use_cassette "kubernetes_pods", custom: true do | ||
capture_log(fn -> | ||
|