forked from ovh/terraform-provider-ovh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_cloud_project_kube_test.go
128 lines (114 loc) · 4.11 KB
/
data_cloud_project_kube_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package ovh
import (
"fmt"
"os"
"regexp"
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
func TestAccCloudProjectKubeDataSource_basic(t *testing.T) {
name := acctest.RandomWithPrefix(test_prefix)
region := os.Getenv("OVH_CLOUD_PROJECT_KUBE_REGION_TEST")
version := os.Getenv("OVH_CLOUD_PROJECT_KUBE_VERSION_TEST")
config := fmt.Sprintf(
testAccCloudProjectKubeDatasourceConfig,
os.Getenv("OVH_CLOUD_PROJECT_SERVICE_TEST"),
name,
region,
version,
)
matchVersion := regexp.MustCompile(`^` + version + `(\..*)?$`)
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheckCloud(t)
testAccCheckCloudProjectExists(t)
testAccPreCheckKubernetes(t)
},
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.ovh_cloud_project_kube.cluster", "region", region),
resource.TestCheckResourceAttr("data.ovh_cloud_project_kube.cluster", "name", name),
resource.TestMatchResourceAttr("data.ovh_cloud_project_kube.cluster", "version", matchVersion),
),
},
},
})
}
func TestAccCloudProjectKubeDataSource_kubeProxy(t *testing.T) {
name := acctest.RandomWithPrefix(test_prefix)
region := os.Getenv("OVH_CLOUD_PROJECT_KUBE_REGION_TEST")
config := fmt.Sprintf(
testAccCloudProjectKubeDatasourceKubeProxyConfig,
os.Getenv("OVH_CLOUD_PROJECT_SERVICE_TEST"),
name,
region,
)
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheckCloud(t)
testAccCheckCloudProjectExists(t)
testAccPreCheckKubernetes(t)
},
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.ovh_cloud_project_kube.cluster", "region", region),
resource.TestCheckResourceAttr("data.ovh_cloud_project_kube.cluster", "name", name),
resource.TestCheckResourceAttr("data.ovh_cloud_project_kube.cluster", "kube_proxy_mode", "ipvs"),
resource.TestCheckResourceAttr("data.ovh_cloud_project_kube.cluster", "customization_kube_proxy.0.iptables.0.min_sync_period", "PT30S"),
resource.TestCheckResourceAttr("data.ovh_cloud_project_kube.cluster", "customization_kube_proxy.0.iptables.0.sync_period", "PT30S"),
resource.TestCheckResourceAttr("data.ovh_cloud_project_kube.cluster", "customization_kube_proxy.0.ipvs.0.min_sync_period", "PT30S"),
resource.TestCheckResourceAttr("data.ovh_cloud_project_kube.cluster", "customization_kube_proxy.0.ipvs.0.sync_period", "PT30S"),
resource.TestCheckResourceAttr("data.ovh_cloud_project_kube.cluster", "customization_kube_proxy.0.ipvs.0.scheduler", "rr"),
resource.TestCheckResourceAttr("data.ovh_cloud_project_kube.cluster", "customization_kube_proxy.0.ipvs.0.tcp_fin_timeout", "PT30S"),
resource.TestCheckResourceAttr("data.ovh_cloud_project_kube.cluster", "customization_kube_proxy.0.ipvs.0.tcp_timeout", "PT30S"),
resource.TestCheckResourceAttr("data.ovh_cloud_project_kube.cluster", "customization_kube_proxy.0.ipvs.0.udp_timeout", "PT30S"),
),
},
},
})
}
var testAccCloudProjectKubeDatasourceConfig = `
resource "ovh_cloud_project_kube" "cluster" {
service_name = "%s"
name = "%s"
region = "%s"
version = "%s"
}
data "ovh_cloud_project_kube" "cluster" {
service_name = ovh_cloud_project_kube.cluster.service_name
kube_id = ovh_cloud_project_kube.cluster.id
}
`
var testAccCloudProjectKubeDatasourceKubeProxyConfig = `
resource "ovh_cloud_project_kube" "cluster" {
service_name = "%s"
name = "%s"
region = "%s"
kube_proxy_mode = "ipvs"
customization_kube_proxy {
iptables {
min_sync_period = "PT30S"
sync_period = "PT30S"
}
ipvs {
min_sync_period = "PT30S"
sync_period = "PT30S"
scheduler = "rr"
tcp_fin_timeout = "PT30S"
tcp_timeout = "PT30S"
udp_timeout = "PT30S"
}
}
}
data "ovh_cloud_project_kube" "cluster" {
service_name = ovh_cloud_project_kube.cluster.service_name
kube_id = ovh_cloud_project_kube.cluster.id
}
`