github.com/sealerio/sealer@v0.11.1-0.20240507115618-f4f89c5853ae/pkg/infra/test/infra_test.go (about) 1 // Copyright © 2021 Alibaba Group Holding Ltd. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package infra 16 17 /*func TestApply(t *testing.T) { 18 //setup cluster 19 password := os.Getenv("SealerPassword") 20 cluster := v1.Cluster{ 21 TypeMeta: metav1.TypeMeta{ 22 Kind: "Cluster", 23 APIVersion: "zlink.aliyun.com/v1alpha1", 24 }, 25 ObjectMeta: metav1.ObjectMeta{ 26 Name: "my-cluster", 27 }, 28 Spec: v1.ClusterSpec{ 29 Masters: v1.Hosts{ 30 Count: "1", 31 CPU: "2", 32 Memory: "4", 33 SystemDisk: "100", 34 DataDisks: []string{"100"}, 35 }, 36 Nodes: v1.Hosts{ 37 Count: "1", 38 CPU: "2", 39 Memory: "4", 40 SystemDisk: "100", 41 DataDisks: []string{"100"}, 42 }, 43 Provider: "ALI_CLOUD", 44 SSH: v1.SSH{ 45 Passwd: password, 46 }, 47 }, 48 } 49 50 aliProvider, err := infra.NewDefaultProvider(&cluster) 51 if err != nil { 52 fmt.Printf("%v", err) 53 } else { 54 fmt.Printf("%v", aliProvider.Apply()) 55 } 56 57 t.Run("modify instance type", func(t *testing.T) { 58 cluster.Spec.Masters.CPU = "4" 59 cluster.Spec.Masters.Memory = "8" 60 cluster.Spec.Nodes.CPU = "4" 61 cluster.Spec.Nodes.Memory = "8" 62 fmt.Printf("%v", aliProvider.Apply()) 63 }) 64 65 t.Run("add instance count", func(t *testing.T) { 66 cluster.Spec.Masters.Count = "5" 67 cluster.Spec.Nodes.Count = "5" 68 fmt.Printf("%v", aliProvider.Apply()) 69 fmt.Printf("%v \n", cluster.Spec.Masters) 70 fmt.Printf("%v \n", cluster.Spec.Nodes) 71 }) 72 73 t.Run("reduce instance count", func(t *testing.T) { 74 cluster.Spec.Masters.Count = "1" 75 cluster.Spec.Nodes.Count = "1" 76 fmt.Printf("%v", aliProvider.Apply()) 77 }) 78 79 t.Run("modify instance type & count both", func(t *testing.T) { 80 cluster.Spec.Masters.CPU = "8" 81 cluster.Spec.Masters.Memory = "16" 82 cluster.Spec.Nodes.CPU = "8" 83 cluster.Spec.Nodes.Memory = "16" 84 cluster.Spec.Masters.Count = "5" 85 cluster.Spec.Nodes.Count = "5" 86 fmt.Printf("%v", aliProvider.Apply()) 87 }) 88 89 // todo 90 t.Run("modify instance system disk", func(t *testing.T) { 91 92 }) 93 94 //teardown 95 time.Sleep(60 * time.Second) 96 now := metav1.Now() 97 cluster.ObjectMeta.DeletionTimestamp = &now 98 fmt.Printf("%v", aliProvider.Apply()) 99 } 100 */