@@ -20,12 +20,14 @@ import (
20
20
)
21
21
22
22
const (
23
- defaultNamespace = "53cd37b9-66b2-4cc8-b080-3722ed7af64a"
24
- defaultNodeGUID = "12345678-1234-1234-1234-123456789012"
25
- namespaceEnvVar = "NAMESPACE"
26
- nodeGUIDEnvVar = "NODEGUID"
27
- clusterName = "demo-cluster"
28
- clusterTemplateName = "baseline-v2.0.1"
23
+ defaultNamespace = "53cd37b9-66b2-4cc8-b080-3722ed7af64a"
24
+ defaultNodeGUID = "12345678-1234-1234-1234-123456789012"
25
+ namespaceEnvVar = "NAMESPACE"
26
+ nodeGUIDEnvVar = "NODEGUID"
27
+ clusterName = "demo-cluster"
28
+
29
+ clusterTemplateOnlyName = "baseline"
30
+ clusterTemplateOnlyVersion = "v2.0.1"
29
31
clusterOrchFunctionalTest = "cluster-orch-functional-test"
30
32
portForwardAddress = "0.0.0.0"
31
33
portForwardService = "svc/cluster-manager"
@@ -41,7 +43,8 @@ const (
41
43
)
42
44
43
45
var (
44
- skipDeleteCluster = os .Getenv ("SKIP_DELETE_CLUSTER" ) == "true"
46
+ clusterTemplateName = fmt .Sprintf ("%s-%s" , clusterTemplateOnlyName , clusterTemplateOnlyVersion )
47
+ skipDeleteCluster = os .Getenv ("SKIP_DELETE_CLUSTER" ) == "true"
45
48
)
46
49
47
50
func TestClusterOrchFunctionalTest (t * testing.T ) {
@@ -190,6 +193,12 @@ var _ = Describe("Cluster Orch Functional tests", Ordered, Label(clusterOrchFunc
190
193
_ , err = cmd .Output ()
191
194
Expect (err ).NotTo (HaveOccurred ())
192
195
})
196
+ It ("TC-CO-INT-009: Should verify that a cluster template cannot be deleted if there is a cluster using it" , func () {
197
+ By ("Trying to delete the cluster template" )
198
+ err := deleteTemplate (namespace )
199
+ Expect (err ).To (HaveOccurred ())
200
+ Expect (err .Error ()).To (ContainSubstring ("denied the request: clusterTemplate is in use" ))
201
+ })
193
202
// TODO: Add more functional tests
194
203
})
195
204
@@ -355,6 +364,33 @@ func deleteCluster(namespace string) error {
355
364
return nil
356
365
}
357
366
367
+ func deleteTemplate (namespace string ) error {
368
+ url := fmt .Sprintf ("%s/%s/%s" , clusterTemplateURL , clusterTemplateOnlyName , clusterTemplateOnlyVersion )
369
+
370
+ req , err := http .NewRequest ("DELETE" , url , nil )
371
+ if err != nil {
372
+ return err
373
+ }
374
+
375
+ req .Header .Set ("Activeprojectid" , namespace )
376
+ req .Header .Set ("Content-Type" , "application/json" )
377
+ req .Header .Set ("Accept" , "application/json" )
378
+
379
+ client := & http.Client {}
380
+ resp , err := client .Do (req )
381
+ if err != nil {
382
+ return err
383
+ }
384
+ defer resp .Body .Close ()
385
+
386
+ if resp .StatusCode != http .StatusNoContent {
387
+ body , _ := io .ReadAll (resp .Body )
388
+ return fmt .Errorf ("failed to delete template: %s" , string (body ))
389
+ }
390
+
391
+ return nil
392
+ }
393
+
358
394
func getClusterInfo (namespace , clusterName string ) (* http.Response , error ) {
359
395
url := fmt .Sprintf ("%s/%s" , clusterCreateURL , clusterName )
360
396
req , err := http .NewRequest ("GET" , url , nil )
0 commit comments