Skip to content

Commit 84706b0

Browse files
committed
skip k8s test if no enough nodes
1 parent e37ef19 commit 84706b0

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

integrationtests/k8s/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ resource "grid_kubernetes" "k8s1" {
7878
}
7979

8080
output "mr_ygg_ip" {
81-
value = grid_kubernetes.k8s1.master[0]
81+
value = grid_kubernetes.k8s1.master[0].planetary_ip
8282
}
8383

8484
output "wg_config" {
8585
value = grid_network.net1.access_wg_config
8686
}
8787

8888
output "worker_ygg_ip" {
89-
value = grid_kubernetes.k8s1.workers[0]
89+
value = grid_kubernetes.k8s1.workers[0].planetary_ip
9090
}

integrationtests/k8s_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package integrationtests
22

33
import (
4+
"fmt"
45
"strings"
56
"testing"
67
"time"
@@ -21,10 +22,11 @@ func RequireNodesAreReady(t *testing.T, terraformOptions *terraform.Options, pri
2122

2223
output, err := RemoteRun("root", masterYggIP, "export KUBECONFIG=/etc/rancher/k3s/k3s.yaml && kubectl get node", privateKey)
2324
output = strings.TrimSpace(output)
24-
require.Empty(t, err)
25+
require.NoError(t, err)
2526

2627
nodesNumber := 2
2728
numberOfReadyNodes := strings.Count(output, "Ready")
29+
fmt.Println(output)
2830
require.True(t, numberOfReadyNodes == nodesNumber, "number of ready nodes is not equal to number of nodes only %d nodes are ready", numberOfReadyNodes)
2931
}
3032

integrationtests/k8s_using_module/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ locals {
6464
}
6565

6666
output "mr_ygg_ip" {
67-
value = module.kubernetes.master
67+
value = module.kubernetes.master.planetary_ip
6868
}

integrationtests/k8s_using_module_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ func TestModuleK8s(t *testing.T) {
4545
FarmIDs: []uint64{1},
4646
}
4747

48-
nodes, err := deployer.FilterNodes(context.Background(), tfPlugin, f, []uint64{freeSRU}, []uint64{}, []uint64{}, 3)
49-
if err != nil || len(nodes) != 3 {
50-
t.Fatal("grid proxy could not find nodes with suitable resources")
51-
}
48+
nodes, err := deployer.FilterNodes(context.Background(), tfPlugin, f, []uint64{freeSRU}, []uint64{}, []uint64{})
5249
require.NoError(t, err)
50+
if len(nodes) < 3 {
51+
t.Skip("couldn't find enough nodes")
52+
}
5353

5454
masterNode := nodes[0].NodeID
5555
worker0Node := nodes[1].NodeID
@@ -59,9 +59,9 @@ func TestModuleK8s(t *testing.T) {
5959
TerraformDir: "./k8s_using_module",
6060
Vars: map[string]interface{}{
6161
"ssh": publicKey,
62-
"network_nodes": []int{masterNode},
62+
"network_nodes": []int{masterNode, worker0Node, worker1Node},
6363
"master": map[string]interface{}{
64-
"name": "master",
64+
"name": "mr",
6565
"node": masterNode,
6666
"cpu": 1,
6767
"memory": 1024,
@@ -72,7 +72,7 @@ func TestModuleK8s(t *testing.T) {
7272
},
7373
"workers": []map[string]interface{}{
7474
{
75-
"name": "worker0",
75+
"name": "w0",
7676
"node": worker0Node,
7777
"cpu": 1,
7878
"memory": 1024,

integrationtests/remoterun.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
// Package integrationtests includes integration tests for deploying solutions on the tf grid, and some utilities to test these solutions.
52
package integrationtests
63

@@ -25,7 +22,7 @@ func setup() (deployer.TFPluginClient, error) {
2522
network = "dev"
2623
}
2724

28-
return deployer.NewTFPluginClient(mnemonics, deployer.WithNetwork(network), deployer.WithLogs())
25+
return deployer.NewTFPluginClient(mnemonics, deployer.WithNetwork(network), deployer.WithLogs(), deployer.WithRMBTimeout(60))
2926
}
3027

3128
// RemoteRun used for running cmd remotely using ssh
@@ -65,7 +62,6 @@ func RemoteRun(user string, addr string, cmd string, privateKey string) (string,
6562

6663
// GenerateSSHKeyPair creats the public and private key for the machine
6764
func GenerateSSHKeyPair() (string, string, error) {
68-
6965
rsaKey, err := rsa.GenerateKey(rand.Reader, 1024)
7066
if err != nil {
7167
return "", "", errors.Wrapf(err, "could not generate rsa key")

0 commit comments

Comments
 (0)