How to use Len method of install Package

Best Gauge code snippet using install.Len

deployments.go

Source:deployments.go Github

copy

Full Screen

1// Copyright 2018 Red Hat, Inc.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 at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// 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 and13// limitations under the License.14package rpmostree15import (16 "reflect"17 "regexp"18 "github.com/coreos/mantle/kola/cluster"19 "github.com/coreos/mantle/kola/register"20 "github.com/coreos/mantle/kola/tests/util"21 "github.com/coreos/mantle/platform/conf"22)23func init() {24 register.RegisterTest(&register.Test{25 Run: rpmOstreeUpgradeRollback,26 ClusterSize: 1,27 Name: "rpmostree.upgrade-rollback",28 FailFast: true,29 Tags: []string{"rpm-ostree", "upgrade"},30 })31 register.RegisterTest(&register.Test{32 Run: rpmOstreeInstallUninstall,33 ClusterSize: 1,34 Name: "rpmostree.install-uninstall",35 Tags: []string{"rpm-ostree"},36 // this Ignition config lands the EPEL repo + key37 UserDataV3: conf.Ignition(`{38 "ignition": {39 "version": "3.0.0"40 },41 "storage": {42 "files": [43 {44 "group": {45 "name": "root"46 },47 "path": "/etc/yum.repos.d/epel.repo",48 "user": {49 "name": "root"50 },51 "contents": {52 "source": "data:,%5Bepel%5D%0Aname%3DExtra%20Packages%20for%20Enterprise%20Linux%208%20-%20%24basearch%0Ametalink%3Dhttps%3A%2F%2Fmirrors.fedoraproject.org%2Fmetalink%3Frepo%3Depel-8%26arch%3D%24basearch%0Afailovermethod%3Dpriority%0Aenabled%3D1%0Agpgcheck%3D1%0Agpgkey%3Dfile%3A%2F%2F%2Fetc%2Fpki%2Frpm-gpg%2FRPM-GPG-KEY-EPEL-8%0A"53 },54 "mode": 42055 },56 {57 "group": {58 "name": "root"59 },60 "path": "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8",61 "user": {62 "name": "root"63 },64 "contents": {65 "source": "data:text/plain;charset=utf-8,-----BEGIN%20PGP%20PUBLIC%20KEY%20BLOCK-----%0D%0A%0D%0AmQINBFz3zvsBEADJOIIWllGudxnpvJnkxQz2CtoWI7godVnoclrdl83kVjqSQp%2B2%0D%0AdgxuG5mUiADUfYHaRQzxKw8efuQnwxzU9kZ70ngCxtmbQWGmUmfSThiapOz00018%0D%0A%2Beo5MFabd2vdiGo1y%2B51m2sRDpN8qdCaqXko65cyMuLXrojJHIuvRA%2Fx7iqOrRfy%0D%0Aa8x3OxC4PEgl5pgDnP8pVK0lLYncDEQCN76D9ubhZQWhISF%2FzJI%2Be806V71hzfyL%0D%0A%2FMt3mQm%2Fli%2BlRKU25Usk9dWaf4NH%2FwZHMIPAkVJ4uD4H%2FuS49wqWnyiTYGT7hUbi%0D%0AecF7crhLCmlRzvJR8mkRP6%2F4T%2FF3tNDPWZeDNEDVFUkTFHNU6%2Fh2%2BO398MNY%2FfOh%0D%0AyKaNK3nnE0g6QJ1dOH31lXHARlpFOtWt3VmZU0JnWLeYdvap4Eff9qTWZJhI7Cq0%0D%0AWm8DgLUpXgNlkmquvE7P2W5EAr2E5AqKQoDbfw%2FGiWdRvHWKeNGMRLnGI3QuoX3U%0D%0ApAlXD7v13VdZxNydvpeypbf%2FAfRyrHRKhkUj3cU1pYkM3DNZE77C5JUe6%2F0nxbt4%0D%0AETUZBTgLgYJGP8c7PbkVnO6I%2FKgL1jw%2B7MW6Az8Ox%2BRXZLyGMVmbW%2FTMc8haJfKL%0D%0AMoUo3TVk8nPiUhoOC0%2FkI7j9ilFrBxBU5dUtF4ITAWc8xnG6jJs%2FIsvRpQARAQAB%0D%0AtChGZWRvcmEgRVBFTCAoOCkgPGVwZWxAZmVkb3JhcHJvamVjdC5vcmc%2BiQI4BBMB%0D%0AAgAiBQJc9877AhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRAh6kWrL4bW%0D%0AoWagD%2F4xnLWws34GByVDQkjprk0fX7Iyhpm%2FU7BsIHKspHLL%2BY46vAAGY%2F9vMvdE%0D%0A0fcr9Ek2Zp7zE1RWmSCzzzUgTG6BFoTG1H4Fho%2F7Z8BXK%2FjybowXSZfqXnTOfhSF%0D%0AalwDdwlSJvfYNV9MbyvbxN8qZRU1z7PEWZrIzFDDToFRk0R71zHpnPTNIJ5%2FYXTw%0D%0ANqU9OxII8hMQj4ufF11040AJQZ7br3rzerlyBOB%2BJd1zSPVrAPpeMyJppWFHSDAI%0D%0AWK6x%2Bam13VIInXtqB%2FCz4GBHLFK5d2%2FIYspVw47Solj8jiFEtnAq6%2B1Aq5WH3iB4%0D%0AbE2e6z00DSF93frwOyWN7WmPIoc2QsNRJhgfJC%2BisGQAwwq8xAbHEBeuyMG8GZjz%0D%0Axohg0H4bOSEujVLTjH1xbAG4DnhWO%2F1VXLX%2BLXELycO8ZQTcjj%2F4AQKuo4wvMPrv%0D%0A9A169oETG%2BVwQlNd74VBPGCvhnzwGXNbTK%2FKH1%2BWRH0YSb%2B41flB3NKhMSU6dGI0%0D%0ASGtIxDSHhVVNmx2%2F6XiT9U%2FznrZsG5Kw8nIbbFz%2B9MGUUWgJMsd1Zl9R8gz7V9fp%0D%0An7L7y5LhJ8HOCMsY%2FZ7%2F7HUs%2Bt%2FA1MI4g7Q5g5UuSZdgi0zxukiWuCkLeAiAP4y7%0D%0AzKK4OjJ644NDcWCHa36znwVmkz3ixL8Q0auR15Oqq2BjR%2Ffyog%3D%3D%0D%0A%3D84m8%0D%0A-----END%20PGP%20PUBLIC%20KEY%20BLOCK-----%0A"66 },67 "mode": 42068 }69 ]70 }71}`),72 Flags: []register.Flag{register.RequiresInternetAccess}, // these need network to retrieve bits73 })74}75// rpmOstreeUpgradeRollback simulates an upgrade by creating a local branch, making76// a commit to the branch, and rebases the host to said commit. After a successful77// "upgrade", the host is rolled back to the original deployment.78func rpmOstreeUpgradeRollback(c cluster.TestCluster) {79 var newBranch string = "local-branch"80 var newVersion string = "kola-test-1.0"81 m := c.Machines()[0]82 originalStatus, err := util.GetRpmOstreeStatusJSON(c, m)83 if err != nil {84 c.Fatal(err)85 }86 if len(originalStatus.Deployments) < 1 {87 c.Fatalf(`Unexpected results from "rpm-ostree status"; received: %v`, originalStatus)88 }89 c.Run("upgrade", func(c cluster.TestCluster) {90 // create a local branch to act as our upgrade target91 originalCsum := originalStatus.Deployments[0].Checksum92 createBranch := "sudo ostree refs --create " + newBranch + " " + originalCsum93 c.MustSSH(m, createBranch)94 // make a commit to the new branch95 createCommit := "sudo ostree commit -b " + newBranch + " --tree ref=" + originalCsum + " --add-metadata-string version=" + newVersion96 newCommit := c.MustSSH(m, createCommit)97 // use "rpm-ostree rebase" to get to the "new" commit98 c.MustSSH(m, "sudo rpm-ostree rebase :"+newBranch)99 // get latest rpm-ostree status output to check validity100 postUpgradeStatus, err := util.GetRpmOstreeStatusJSON(c, m)101 if err != nil {102 c.Fatal(err)103 }104 // should have an additional deployment105 if len(postUpgradeStatus.Deployments) != len(originalStatus.Deployments)+1 {106 c.Fatalf("Expected %d deployments; found %d deployments", len(originalStatus.Deployments)+1, len(postUpgradeStatus.Deployments))107 }108 // reboot into new deployment109 rebootErr := m.Reboot()110 if rebootErr != nil {111 c.Fatalf("Failed to reboot machine: %v", err)112 }113 // get latest rpm-ostree status output114 postRebootStatus, err := util.GetRpmOstreeStatusJSON(c, m)115 if err != nil {116 c.Fatal(err)117 }118 // should have 2 deployments, the previously booted deployment and the test deployment due to rpm-ostree pruning119 if len(postRebootStatus.Deployments) != 2 {120 c.Fatalf("Expected %d deployments; found %d deployment", 2, len(postRebootStatus.Deployments))121 }122 // origin should be new branch123 if postRebootStatus.Deployments[0].Origin != newBranch {124 c.Fatalf(`New deployment origin is incorrect; expected %q, got %q`, newBranch, postRebootStatus.Deployments[0].Origin)125 }126 // new deployment should be booted127 if !postRebootStatus.Deployments[0].Booted {128 c.Fatalf("New deployment is not reporting as booted")129 }130 // checksum should be new commit131 if postRebootStatus.Deployments[0].Checksum != string(newCommit) {132 c.Fatalf(`New deployment checksum is incorrect; expected %q, got %q`, newCommit, postRebootStatus.Deployments[0].Checksum)133 }134 // version should be new version string135 if postRebootStatus.Deployments[0].Version != newVersion {136 c.Fatalf(`New deployment version is incorrect; expected %q, got %q`, newVersion, postRebootStatus.Deployments[0].Checksum)137 }138 })139 c.Run("rollback", func(c cluster.TestCluster) {140 // rollback to original deployment141 c.MustSSH(m, "sudo rpm-ostree rollback")142 newRebootErr := m.Reboot()143 if newRebootErr != nil {144 c.Fatalf("Failed to reboot machine: %v", err)145 }146 rollbackStatus, err := util.GetRpmOstreeStatusJSON(c, m)147 if err != nil {148 c.Fatal(err)149 }150 // still 2 deployments...151 if len(rollbackStatus.Deployments) != 2 {152 c.Fatalf("Expected %d deployments; found %d deployments", 2, len(rollbackStatus.Deployments))153 }154 // validate we are back to the original deployment by comparing the155 // the two RpmOstreeDeployment structs156 if !reflect.DeepEqual(originalStatus.Deployments[0], rollbackStatus.Deployments[0]) {157 c.Fatalf(`Differences found in "rpm-ostree status"; original %v, current: %v`, originalStatus.Deployments[0], rollbackStatus.Deployments[0])158 }159 // cleanup our mess160 cleanupErr := rpmOstreeCleanup(c, m)161 if cleanupErr != nil {162 c.Fatal(cleanupErr)163 }164 })165}166// rpmOstreeInstallUninstall verifies that we can install a package167// and then uninstall it168//169// 'bird' is available in EPEL(8) and installs on Fedora 29 and RHEL 8170// on all arches171//172// NOTE: we could be churning on the package choice going forward as173// we need something that is a) small, b) has no dependencies, and c)174// can be installed on Fedora + RHEL + all arches from the EPEL repo that we are175// currently using. We've already had to swap from `fpaste`-`bcrypt`-`bird`176func rpmOstreeInstallUninstall(c cluster.TestCluster) {177 var installPkgName = "bird"178 var installPkgBin string179 if c.Distribution() == "fcos" {180 installPkgBin = "/usr/sbin/bird"181 } else {182 installPkgBin = "/sbin/bird"183 }184 m := c.Machines()[0]185 originalStatus, err := util.GetRpmOstreeStatusJSON(c, m)186 if err != nil {187 c.Fatal(err)188 }189 if len(originalStatus.Deployments) < 1 {190 c.Fatal(`Unexpected results from "rpm-ostree status"; no deployments?`)191 }192 originalCsum := originalStatus.Deployments[0].Checksum193 c.Run("install", func(c cluster.TestCluster) {194 // install package and reboot195 c.MustSSH(m, "sudo rpm-ostree install "+installPkgName)196 installRebootErr := m.Reboot()197 if installRebootErr != nil {198 c.Fatalf("Failed to reboot machine: %v", installRebootErr)199 }200 postInstallStatus, err := util.GetRpmOstreeStatusJSON(c, m)201 if err != nil {202 c.Fatal(err)203 }204 if len(postInstallStatus.Deployments) != 2 {205 c.Fatalf(`Expected two deployments, found %d deployments`, len(postInstallStatus.Deployments))206 }207 // check the command is present, in the rpmdb, and usable208 cmdOut := c.MustSSH(m, "command -v "+installPkgName)209 if string(cmdOut) != installPkgBin {210 c.Fatalf(`%q binary in unexpected location. expectd %q, got %q`, installPkgName, installPkgBin, string(cmdOut))211 }212 rpmOut := c.MustSSH(m, "rpm -q "+installPkgName)213 rpmRegex := "^" + installPkgName214 rpmMatch := regexp.MustCompile(rpmRegex).MatchString(string(rpmOut))215 if !rpmMatch {216 c.Fatalf(`Output from "rpm -q" was unexpected: %q`, string(rpmOut))217 }218 // package should be in the metadata219 var reqPkg bool = false220 for _, pkg := range postInstallStatus.Deployments[0].RequestedPackages {221 if pkg == installPkgName {222 reqPkg = true223 break224 }225 }226 if !reqPkg {227 c.Fatalf(`Unable to find "%q" in requested-packages: %v`, installPkgName, postInstallStatus.Deployments[0].RequestedPackages)228 }229 var installPkg bool = false230 for _, pkg := range postInstallStatus.Deployments[0].Packages {231 if pkg == installPkgName {232 installPkg = true233 break234 }235 }236 if !installPkg {237 c.Fatalf(`Unable to find "%q" in packages: %v`, installPkgName, postInstallStatus.Deployments[0].Packages)238 }239 // checksum should be different240 if postInstallStatus.Deployments[0].Checksum == originalCsum {241 c.Fatalf(`Commit IDs incorrectly matched after package install`)242 }243 })244 // uninstall the package245 c.Run("uninstall", func(c cluster.TestCluster) {246 c.MustSSH(m, "sudo rpm-ostree uninstall "+installPkgName)247 uninstallRebootErr := m.Reboot()248 if uninstallRebootErr != nil {249 c.Fatalf("Failed to reboot machine: %v", uninstallRebootErr)250 }251 postUninstallStatus, err := util.GetRpmOstreeStatusJSON(c, m)252 if err != nil {253 c.Fatal(err)254 }255 // check the metadata to make sure everything went well256 if len(postUninstallStatus.Deployments) != 2 {257 c.Fatal("Expected %d deployments, got %d", 2, len(postUninstallStatus.Deployments))258 }259 if postUninstallStatus.Deployments[0].Checksum != originalCsum {260 c.Fatalf(`Checksum is incorrect; expected %q, got %q`, originalCsum, postUninstallStatus.Deployments[0].Checksum)261 }262 if len(postUninstallStatus.Deployments[0].RequestedPackages) != 0 {263 c.Fatalf(`Found unexpected requested-packages: %q`, postUninstallStatus.Deployments[0].RequestedPackages)264 }265 if len(postUninstallStatus.Deployments[0].Packages) != 0 {266 c.Fatalf(`Found unexpected packages: %q`, postUninstallStatus.Deployments[0].Packages)267 }268 // cleanup our mess269 cleanupErr := rpmOstreeCleanup(c, m)270 if cleanupErr != nil {271 c.Fatal(cleanupErr)272 }273 })274}...

Full Screen

Full Screen

environment_hook_test.go

Source:environment_hook_test.go Github

copy

Full Screen

1package model2import (3 "testing"4 "github.com/stretchr/testify/assert"5)6// Test loading an environment with unknown global hooks7//8// The validation must complain only about 10 hooks pointing on unknown tasks9//10//- Error: empty volume path @nodes.managers.volumes.path11//12func TestValidateUnknownGlobalHooks(t *testing.T) {13 yamlEnv, e := ParseYamlDescriptor(buildURL(t, "./testdata/yaml/grammar/unknown_global_hook.yaml"), &TemplateContext{})14 assert.Nil(t, e)15 p, e := createPlatform(yamlEnv.Ekara)16 assert.Nil(t, e)17 env, e := CreateEnvironment("", yamlEnv, MainComponentId)18 assert.Nil(t, e)19 env.ekara = &p20 assert.NotNil(t, env)21 vErrs := env.Validate()22 assert.True(t, vErrs.HasErrors())23 assert.False(t, vErrs.HasWarnings())24 assert.Equal(t, 10, len(vErrs.Errors))25 assert.True(t, vErrs.contains(Error, "reference to unknown task: unknown", "hooks.init.before"))26 assert.True(t, vErrs.contains(Error, "reference to unknown task: unknown", "hooks.init.after"))27 assert.True(t, vErrs.contains(Error, "reference to unknown task: unknown", "hooks.create.before"))28 assert.True(t, vErrs.contains(Error, "reference to unknown task: unknown", "hooks.create.after"))29 assert.True(t, vErrs.contains(Error, "reference to unknown task: unknown", "hooks.install.before"))30 assert.True(t, vErrs.contains(Error, "reference to unknown task: unknown", "hooks.install.after"))31 assert.True(t, vErrs.contains(Error, "reference to unknown task: unknown", "hooks.deploy.before"))32 assert.True(t, vErrs.contains(Error, "reference to unknown task: unknown", "hooks.deploy.after"))33 assert.True(t, vErrs.contains(Error, "reference to unknown task: unknown", "hooks.delete.before"))34 assert.True(t, vErrs.contains(Error, "reference to unknown task: unknown", "hooks.delete.after"))35}36func TestHasNoTaskEnv(t *testing.T) {37 h := EnvironmentHooks{}38 assert.False(t, h.HasTasks())39}40func TestHasTaskBeforeEnvInit(t *testing.T) {41 h := EnvironmentHooks{}42 h.Init.Before = append(h.Init.Before, oneTask)43 assert.True(t, h.HasTasks())44}45func TestHasTaskAfterEnvInit(t *testing.T) {46 h := EnvironmentHooks{}47 h.Init.After = append(h.Init.After, oneTask)48 assert.True(t, h.HasTasks())49}50func TestHasTaskBeforeEnvCreate(t *testing.T) {51 h := EnvironmentHooks{}52 h.Create.Before = append(h.Create.Before, oneTask)53 assert.True(t, h.HasTasks())54}55func TestHasTaskAfterEnvCreate(t *testing.T) {56 h := EnvironmentHooks{}57 h.Create.After = append(h.Create.After, oneTask)58 assert.True(t, h.HasTasks())59}60func TestHasTaskBeforeEnvInstall(t *testing.T) {61 h := EnvironmentHooks{}62 h.Install.Before = append(h.Install.Before, oneTask)63 assert.True(t, h.HasTasks())64}65func TestHasTaskAfterEnvInstall(t *testing.T) {66 h := EnvironmentHooks{}67 h.Install.After = append(h.Install.After, oneTask)68 assert.True(t, h.HasTasks())69}70func TestHasTaskBeforeEnvDeploy(t *testing.T) {71 h := EnvironmentHooks{}72 h.Deploy.Before = append(h.Deploy.Before, oneTask)73 assert.True(t, h.HasTasks())74}75func TestHasTaskAfterEnvDeploy(t *testing.T) {76 h := EnvironmentHooks{}77 h.Deploy.After = append(h.Deploy.After, oneTask)78 assert.True(t, h.HasTasks())79}80func TestHasTaskBeforeEnvDelete(t *testing.T) {81 h := EnvironmentHooks{}82 h.Destroy.Before = append(h.Destroy.Before, oneTask)83 assert.True(t, h.HasTasks())84}85func TestHasTaskAfterEnvDelete(t *testing.T) {86 h := EnvironmentHooks{}87 h.Destroy.After = append(h.Destroy.After, oneTask)88 assert.True(t, h.HasTasks())89}90func TestMergeEnvironmentHookBefore(t *testing.T) {91 task1 := TaskRef{ref: "ref1"}92 task2 := TaskRef{ref: "ref2"}93 h := EnvironmentHooks{}94 h.Init.Before = append(h.Init.Before, task1)95 h.Create.Before = append(h.Create.Before, task1)96 h.Install.Before = append(h.Install.Before, task1)97 h.Deploy.Before = append(h.Deploy.Before, task1)98 h.Destroy.Before = append(h.Destroy.Before, task1)99 o := EnvironmentHooks{}100 o.Init.Before = append(o.Init.Before, task2)101 o.Create.Before = append(o.Create.Before, task2)102 o.Install.Before = append(o.Install.Before, task2)103 o.Deploy.Before = append(o.Deploy.Before, task2)104 o.Destroy.Before = append(o.Destroy.Before, task2)105 err := h.customize(o)106 assert.Nil(t, err)107 assert.True(t, h.HasTasks())108 if assert.Equal(t, 2, len(h.Init.Before)) {109 assert.Equal(t, 0, len(h.Init.After))110 assert.Equal(t, task1.ref, h.Init.Before[0].ref)111 assert.Equal(t, task2.ref, h.Init.Before[1].ref)112 }113 if assert.Equal(t, 2, len(h.Create.Before)) {114 assert.Equal(t, 0, len(h.Create.After))115 assert.Equal(t, task1.ref, h.Create.Before[0].ref)116 assert.Equal(t, task2.ref, h.Create.Before[1].ref)117 }118 if assert.Equal(t, 2, len(h.Install.Before)) {119 assert.Equal(t, 0, len(h.Install.After))120 assert.Equal(t, task1.ref, h.Install.Before[0].ref)121 assert.Equal(t, task2.ref, h.Install.Before[1].ref)122 }123 if assert.Equal(t, 2, len(h.Deploy.Before)) {124 assert.Equal(t, 0, len(h.Deploy.After))125 assert.Equal(t, task1.ref, h.Deploy.Before[0].ref)126 assert.Equal(t, task2.ref, h.Deploy.Before[1].ref)127 }128 if assert.Equal(t, 2, len(h.Destroy.Before)) {129 assert.Equal(t, 0, len(h.Destroy.After))130 assert.Equal(t, task1.ref, h.Destroy.Before[0].ref)131 assert.Equal(t, task2.ref, h.Destroy.Before[1].ref)132 }133}134func TestMergeEnvironmentHookAfter(t *testing.T) {135 task1 := TaskRef{ref: "ref1"}136 task2 := TaskRef{ref: "ref2"}137 h := EnvironmentHooks{}138 h.Init.After = append(h.Init.After, task1)139 h.Create.After = append(h.Create.After, task1)140 h.Install.After = append(h.Install.After, task1)141 h.Deploy.After = append(h.Deploy.After, task1)142 h.Destroy.After = append(h.Destroy.After, task1)143 o := EnvironmentHooks{}144 o.Init.After = append(o.Init.After, task2)145 o.Create.After = append(o.Create.After, task2)146 o.Install.After = append(o.Install.After, task2)147 o.Deploy.After = append(o.Deploy.After, task2)148 o.Destroy.After = append(o.Destroy.After, task2)149 err := h.customize(o)150 assert.Nil(t, err)151 assert.True(t, h.HasTasks())152 if assert.Equal(t, 2, len(h.Init.After)) {153 assert.Equal(t, 0, len(h.Init.Before))154 assert.Equal(t, task1.ref, h.Init.After[0].ref)155 assert.Equal(t, task2.ref, h.Init.After[1].ref)156 }157 if assert.Equal(t, 2, len(h.Create.After)) {158 assert.Equal(t, 0, len(h.Create.Before))159 assert.Equal(t, task1.ref, h.Create.After[0].ref)160 assert.Equal(t, task2.ref, h.Create.After[1].ref)161 }162 if assert.Equal(t, 2, len(h.Install.After)) {163 assert.Equal(t, 0, len(h.Install.Before))164 assert.Equal(t, task1.ref, h.Install.After[0].ref)165 assert.Equal(t, task2.ref, h.Install.After[1].ref)166 }167 if assert.Equal(t, 2, len(h.Deploy.After)) {168 assert.Equal(t, 0, len(h.Deploy.Before))169 assert.Equal(t, task1.ref, h.Deploy.After[0].ref)170 assert.Equal(t, task2.ref, h.Deploy.After[1].ref)171 }172 if assert.Equal(t, 2, len(h.Destroy.After)) {173 assert.Equal(t, 0, len(h.Destroy.Before))174 assert.Equal(t, task1.ref, h.Destroy.After[0].ref)175 assert.Equal(t, task2.ref, h.Destroy.After[1].ref)176 }177}178func TestMergeEnvironmentHookItself(t *testing.T) {179 task1 := TaskRef{ref: "ref1"}180 h := EnvironmentHooks{}181 h.Init.After = append(h.Init.After, task1)182 h.Create.After = append(h.Create.After, task1)183 h.Install.After = append(h.Install.After, task1)184 h.Deploy.After = append(h.Deploy.After, task1)185 h.Destroy.After = append(h.Destroy.After, task1)186 err := h.customize(h)187 assert.Nil(t, err)188 assert.True(t, h.HasTasks())189 assert.Equal(t, 0, len(h.Init.Before))190 assert.Equal(t, 0, len(h.Create.Before))191 assert.Equal(t, 0, len(h.Install.Before))192 assert.Equal(t, 0, len(h.Deploy.Before))193 assert.Equal(t, 0, len(h.Destroy.Before))194 assert.Equal(t, 1, len(h.Init.After))195 assert.Equal(t, 1, len(h.Create.After))196 assert.Equal(t, 1, len(h.Install.After))197 assert.Equal(t, 1, len(h.Deploy.After))198 assert.Equal(t, 1, len(h.Destroy.After))199 assert.Equal(t, task1.ref, h.Init.After[0].ref)200 assert.Equal(t, task1.ref, h.Create.After[0].ref)201 assert.Equal(t, task1.ref, h.Install.After[0].ref)202 assert.Equal(t, task1.ref, h.Deploy.After[0].ref)203 assert.Equal(t, task1.ref, h.Destroy.After[0].ref)204}...

Full Screen

Full Screen

install.go

Source:install.go Github

copy

Full Screen

1// Copyright (c) Cloud J Tech, Inc. All rights reserved.2// Licensed under the GPLv3 License. See License.txt in the project root for license information.3package install4import (5 "errors"6 "os"7 "strings"8 "github.com/spf13/cobra"9 "idcos.io/cloud-act2/cmd/act2ctl/aux"10 "idcos.io/cloud-act2/cmd/act2ctl/client"11)12var installFlag InstallFlag13func GetSaltInstallCmd() *cobra.Command {14 cmd := &cobra.Command{15 Use: "install",16 Short: "act2ctl install 192.168.1.1,192.168.1.2 -u root -p 111 -o linux -f http://localhost/nfs/salt_install/salt-minion-install.sh -i hangzhou -m 192.168.1.3",17 Long: "quick install puppet/salt client",18 Args: cmdArgValidate,19 RunE: runCmd,20 }21 AddCommonQuickFlags(cmd, &installFlag)22 return cmd23}24func cmdArgValidate(cmd *cobra.Command, args []string) error {25 if len(args) == 0 {26 return errors.New("requires at least one args")27 }28 if len(installFlag.User) == 0 {29 return errors.New("user is required")30 }31 if len(installFlag.Password) == 0 {32 return errors.New("password is required")33 }34 if len(installFlag.File) == 0 {35 return errors.New("file url is required")36 }37 if len(installFlag.IDC) == 0 {38 return errors.New("idc is required")39 }40 if len(installFlag.MasterIP) == 0 {41 return errors.New("masterIp is required")42 }43 return nil44}45func runCmd(cmd *cobra.Command, args []string) error {46 output := aux.NewOutput(os.Stdout, false)47 output.Verbose("start to install, args: (%s), action flag: %#v\n",48 args, installFlag)49 ipList, err := getIpList(args[0])50 if err != nil {51 return err52 }53 err = client.GetAct2Client().QuickInstall(ipList, installFlag.OsType, installFlag.IDC, installFlag.User, installFlag.Password, installFlag.File, installFlag.MasterIP)54 return err55}56func getIpList(ipStr string) (ipList []string, err error) {57 if len(ipStr) == 0 {58 return nil, errors.New("host is required")59 }60 ipList = strings.Split(ipStr, ",")61 return ipList, nil62}...

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1import (2type install struct {3}4func (i install) Len() int {5}6func main() {7 i := install{"test", 10}8 fmt.Println(i.Len())9}10import (11type install struct {12}13func (i install) Len() int {14}15func main() {16 i := install{"test", 10}17 fmt.Println(i.Len())18}19import (20type install struct {21}22func (i install) Len() int {23}24func main() {25 i := install{"test", 10}26 fmt.Println(i.Len())27}28import (29type install struct {30}31func (i install) Len() int {32}33func main() {34 i := install{"test", 10}35 fmt.Println(i.Len())36}37import (38type install struct {39}40func (i install) Len() int {41}42func main() {43 i := install{"test", 10}44 fmt.Println(i.Len())45}46import (47type install struct {48}49func (i install) Len() int {

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, playground")4}5import (6func main() {7 fmt.Println("Hello, playground")8}9import (10func main() {11 fmt.Println("Hello, playground")12}13import (14func main() {15 fmt.Println("Hello, playground")16}17import (18func main() {19 fmt.Println("Hello, playground")20}21import (22func main() {23 fmt.Println("Hello, playground")24}25import (26func main() {27 fmt.Println("Hello, playground")28}29import (30func main() {31 fmt.Println("Hello, playground")32}33import (34func main() {35 fmt.Println("Hello, playground")36}37import (38func main() {39 fmt.Println("Hello, playground")40}41import (42func main() {43 fmt.Println("Hello, playground")44}45import (46func main() {47 fmt.Println("Hello, playground")48}49import (50func main() {51 fmt.Println("Hello, playground")52}53import

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(install.Len())4}5func Len() int {6}

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1import "fmt"2type install struct {3}4func (i install) Len() float64 {5}6func main() {7 i := install{"golang", 1.10}8 fmt.Println(i.Len())9}

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 i = install{10}4 fmt.Println(i.Len())5}6import "fmt"7func main() {8 i = install{10}9 fmt.Println(i.Len())10}11import "fmt"12func main() {13 i = install{10}14 fmt.Println(i.Len())15}16import "fmt"17func main() {18 i = install{10}19 fmt.Println(i.Len())20}21import "fmt"22func main() {23 i = install{10}24 fmt.Println(i.Len())25}26import "fmt"27func main() {28 i = install{10}29 fmt.Println(i.Len())30}31import "fmt"32func main() {33 i = install{10}34 fmt.Println(i.Len())35}36import "fmt"37func main() {38 i = install{10}39 fmt.Println(i.Len())40}41import "fmt"42func main() {43 i = install{10}44 fmt.Println(i.Len())45}46import "fmt"47func main() {48 i = install{10}49 fmt.Println(i.Len())50}51import "fmt"52func main() {53 i = install{10}54 fmt.Println(i.Len

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, playground")4 i := install{}5 fmt.Println(i.Len())6}7import (8type install struct {9}10func (i install) Len() int {11}12func main() {13 fmt.Println("Hello, playground")14 i := install{}15 fmt.Println(i.Len())16}17import (18type install struct {19}20func (i install) Len() int {21}22func main() {23 fmt.Println("Hello, playground")24 i := install{}25 fmt.Println(i.Len())26}27import (28type install struct {29}30func (i install) Len() int {31}32func main() {33 fmt.Println("Hello, playground")34 i := install{}35 fmt.Println(i.Len())36}37import (38type install struct {39}40func (i install) Len() int {41}42func main() {43 fmt.Println("Hello, playground")44 i := install{}45 fmt.Println(i.Len())46}

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 i = install{4}4 fmt.Println(i.Len())5}6import "fmt"7func main() {8 i = install{4}9 fmt.Println(i.Len())10}11type install struct {12}13func (i install) Len() int {14}15import "fmt"16func main() {17 i = install{4}18 fmt.Println(i.Len())19}20type install struct {21}22func (i *install) Len() int {23}24import "fmt"25func main() {26 i = install{4}27 fmt.Println(i.Len())28}29type install struct {30}31func (i *install) Len() int {32}33import "fmt"34func main() {35 i = install{4}36 fmt.Println(i.Len())37}38type install struct {39}40func (i *install) Len() int {41}42import "fmt"43func main() {44 i = install{4}45 fmt.Println(i.Len())46}47type install struct {48}49func (i *install) Len() int {50}51import "fmt"52func main() {53 i = install{4}54 fmt.Println(i.Len())55}56type install struct {57}58func (i *install

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(models.Install.Len())4}5import (6func main() {7 fmt.Println(models.Install.Len())8}9× Email codedump link for Go: How to import the same package in multiple files in the same directory?

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 i := install.NewInstall()4 fmt.Println(i.Len())5}6import (7func main() {8 i := install.NewInstall()9 fmt.Println(i.Len())10}11import (12func main() {13 i := install.NewInstall()14 fmt.Println(i.Len())15}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Gauge automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful