func TestAvailDatacentersIntegration(t *testing.T) { c := NewClient(apiKey) datacenters, err := c.AvailDatacenters() require.NoError(t, err) require.NotEmpty(t, datacenters) // Test subset var foundDallas bool var foundFremont bool for _, dc := range datacenters { switch dc.ID { case 2: assert.Equal(t, "Dallas, TX, USA", dc.Location, "dc.Location") assert.Equal(t, "dallas", dc.Abbr, "dc.Abbr") foundDallas = true case 3: assert.Equal(t, "Fremont, CA, USA", dc.Location, "dc.Location") assert.Equal(t, "fremont", dc.Abbr, "dc.Abbr") foundFremont = true } } assert.True(t, foundDallas, "Dallas not returned.") assert.True(t, foundFremont, "Fremont not returned.") }
func TestAvailKernelsOK(t *testing.T) { c, ts := clientFor(newMockAPIServer(t, mockAvailKernelsOK())) defer ts.Close() kerns, err := c.AvailKernels(nil, nil) require.NoError(t, err) require.Len(t, kerns, 135) var sample Kernel var everXen bool var everPVOps bool for _, k := range kerns { if k.IsXen { everXen = true } if k.IsPVOps { everPVOps = true } assert.NotEmpty(t, k.Label, "k.Label") assert.NotEmpty(t, k.ID, "k.ID") if k.ID == 138 { sample = k } } assert.True(t, everXen, "everXen") assert.True(t, everPVOps, "everPVOps") assert.Equal(t, "Latest 64 bit (4.1.0-x86_64-linode59)", sample.Label, "sample.Label") assert.True(t, sample.IsXen, "sample.IsXen") assert.True(t, sample.IsPVOps, "sample.IsPVOps") assert.Equal(t, 138, sample.ID, "sample.ID") }
func TestLinodeConfigList(t *testing.T) { c, ts := clientFor(newMockAPIServer(t, mockLinodeConfigListOK())) defer ts.Close() confs, err := c.LinodeConfigList(1139016, Int(1855685)) require.NoError(t, err) require.Len(t, confs, 1) cfg := confs[0] assert.Equal(t, "bar", cfg.RootDeviceCustom) assert.Equal(t, "foo", cfg.Comments) assert.Equal(t, "test-conf1", cfg.Label) assert.Equal(t, 1855685, cfg.ID) assert.Equal(t, "3569234,3569220,,,,,,,", cfg.DiskList) assert.Equal(t, "default", cfg.RunLevel) assert.Equal(t, 1, cfg.RootDeviceNum) assert.Equal(t, 800, cfg.RAMLimit) assert.Equal(t, "paravirt", cfg.VirtMode) assert.Equal(t, 1139016, cfg.LinodeID) assert.Equal(t, 138, cfg.KernelID) assert.True(t, cfg.DevTmpFSAutomount) assert.True(t, cfg.HelperDistro) assert.True(t, cfg.HelperDisableUpdateDB) assert.True(t, cfg.HelperDepmod) assert.True(t, cfg.HelperXen) assert.True(t, cfg.RootDeviceRO) assert.True(t, cfg.HelperNetwork) assert.True(t, cfg.IsRescue) }
func TestAvailKernelsSingle(t *testing.T) { c, ts := clientFor(newMockAPIServer(t, mockAvailKernelsSingle())) defer ts.Close() kerns, err := c.AvailKernels(Int(138), Bool(true)) require.NoError(t, err) require.Len(t, kerns, 1) k := kerns[0] assert.Equal(t, "Latest 64 bit (4.1.0-x86_64-linode59)", k.Label, "k.Label") assert.True(t, k.IsXen, "k.IsXen") assert.True(t, k.IsPVOps, "k.IsPVOps") assert.Equal(t, 138, k.ID, "k.ID") }
func TestUnmarshalSingleBool(t *testing.T) { // doesn't currently get exercised in normal usage var out bool err := unmarshalSingle(json.RawMessage([]byte(`{"foo": true}`)), "foo", &out) require.NoError(t, err) assert.True(t, out) }
func testDistsNotEmpty(t *testing.T, dists []Distribution) { var everRequiresPVOps bool var ever64Bit bool for _, d := range dists { if d.RequiresPVOps { everRequiresPVOps = true } if d.Is64Bit { ever64Bit = true } assert.NotEmpty(t, d.ID, "d.ID") assert.NotEmpty(t, d.Label, "d.Label") assert.NotEmpty(t, d.MinImageSize, "d.MinImageSize") assert.NotEmpty(t, d.CreateDT, "d.CreateDT") } assert.True(t, everRequiresPVOps, "everRequiresPVOps") assert.True(t, ever64Bit, "ever64Bit") }
func testSSNotEmpty(t *testing.T, sscripts []StackScript) { var everTotalDeploys bool var everActiveDeploys bool var everPublic bool var everDescription bool var everRevNote bool for _, ss := range sscripts { if ss.TotalDeploys != 0 { everTotalDeploys = true } if ss.ActiveDeploys != 0 { everActiveDeploys = true } if ss.IsPublic == true { everPublic = true } if ss.Description != "" { everDescription = true } if ss.RevNote != "" { everRevNote = true } assert.NotEmpty(t, ss.Script, "ss.Script") assert.NotEmpty(t, ss.Label, "ss.Label") assert.NotEmpty(t, ss.CreateDT, "ss.CreateDT") assert.NotEmpty(t, ss.ID, "ss.ID") assert.NotEmpty(t, ss.RevDT, "ss.RevDT") assert.NotEmpty(t, ss.UserID, "ss.UserID") } if len(sscripts) > 1 { assert.True(t, everTotalDeploys, "everTotalDeploys") assert.True(t, everActiveDeploys, "everActiveDeploys") assert.True(t, everPublic, "everPublic") assert.True(t, everDescription, "everDescription") assert.True(t, everRevNote, "everRevNote") } }
func TestAvailKernelsIntegration(t *testing.T) { c := NewClient(apiKey) kerns, err := c.AvailKernels(nil, nil) require.NoError(t, err) require.NotEmpty(t, kerns) var everXen bool var everPVOps bool for _, k := range kerns { if k.IsXen { everXen = true } if k.IsPVOps { everPVOps = true } assert.NotEmpty(t, k.Label, "k.Label") assert.NotEmpty(t, k.ID, "k.ID") } assert.True(t, everXen, "everXen") assert.True(t, everPVOps, "everPVOps") kerns, err = c.AvailKernels(Int(138), Bool(true)) require.NoError(t, err) require.Len(t, kerns, 1) k := kerns[0] assert.True(t, k.IsXen) assert.True(t, k.IsPVOps) assert.NotEmpty(t, k.ID) assert.NotEmpty(t, k.Label) kerns, err = c.AvailKernels(Int(4389048234), Bool(false)) require.NoError(t, err) require.Empty(t, kerns) }
func TestMockAccountInfoOK(t *testing.T) { c, ts := clientFor(newMockAPIServer(t, mockAccountInfo())) defer ts.Close() i, err := c.AccountInfo() require.NoError(t, err) assert.Equal(t, 1, i.TransferUsed) assert.Equal(t, -4.8200, i.Balance) assert.Equal(t, 2, i.TransferBillable) assert.Equal(t, "metered", i.BillingMethod) assert.Equal(t, 104, i.TransferPool) assert.Equal(t, "2015-06-25 23:52:06.0", i.ActiveSince) assert.True(t, i.Managed) }
func TestLinodeDiskListOK(t *testing.T) { c, ts := clientFor(newMockAPIServer(t, mockLinodeDiskListOK())) defer ts.Close() disks, err := c.LinodeDiskList(1146420, Int(1)) require.NoError(t, err) require.Len(t, disks, 3) var foundTestSwap bool var foundTestDist bool var foundUpdatedLabel bool for _, d := range disks { if d.ID == 3582351 { foundTestSwap = true assert.True(t, d.IsReadOnly) assert.Equal(t, "test-swap", d.Label) assert.Equal(t, "2015-07-06 23:30:13.0", d.UpdateDT) assert.Equal(t, 1, d.Status) assert.Equal(t, 256, d.Size) assert.Equal(t, 1146420, d.LinodeID) assert.Equal(t, "2015-07-06 23:29:37.0", d.CreateDT) assert.Equal(t, "swap", d.Type) } if d.ID == 3582352 { foundTestDist = true } if d.ID == 3582356 { foundUpdatedLabel = true } } assert.True(t, foundTestSwap) assert.True(t, foundTestDist) assert.True(t, foundUpdatedLabel) }
func TestLinodeJobListFinishedOK(t *testing.T) { c, ts := clientFor(newMockAPIServer(t, mockLinodeJobListFinishedOK())) defer ts.Close() jobs, err := c.LinodeJobList(1139016, Int(25088076), Bool(false)) require.NoError(t, err) require.Len(t, jobs, 1) j := jobs[0] assert.True(t, j.Done()) assert.True(t, j.Success()) assert.Equal(t, "2015-07-03 23:51:41.0", j.EnteredDT) assert.Equal(t, "fs.create", j.Action) assert.Equal(t, "Create Filesystem - test-swap", j.Label) assert.Equal(t, "2015-07-03 23:51:51.0", j.HostStartDT) assert.Equal(t, 1139016, j.LinodeID) assert.Equal(t, "2015-07-03 23:51:51.0", j.HostFinishDT) assert.Equal(t, 5, j.Duration) assert.Equal(t, "foo", j.HostMessage) assert.Equal(t, 25088076, j.ID) assert.Equal(t, true, j.HostSuccess) }
func TestLinodeIPListOK(t *testing.T) { c, ts := clientFor(newMockAPIServer(t, mockLinodeIPListOK())) defer ts.Close() IPList, err := c.LinodeIPList(Int(1146420), Int(1)) require.NoError(t, err) require.Len(t, IPList, 1) IP := IPList[0] assert.Equal(t, 296963, IP.ID) assert.Equal(t, "li959-147.members.linode.com", IP.RDNSName) assert.Equal(t, 1146420, IP.LinodeID) assert.True(t, IP.IsPublic) assert.Equal(t, "45.33.5.147", IP.Address) }
func TestStackScriptIntegration(t *testing.T) { c := NewClient(apiKey) ssID, err := c.StackScriptCreate("test", "130,", "#! /bin/bash foo", String("foo"), Bool(false), String("bar")) require.NoError(t, err) require.NotEmpty(t, ssID) ssList, err := c.StackScriptList(Int(ssID)) require.NoError(t, err) require.Len(t, ssList, 1) ss := ssList[0] assert.Equal(t, "bar", ss.RevNote) assert.Equal(t, "#! /bin/bash foo", ss.Script) assert.Equal(t, "130,", ss.DistIDList) assert.Equal(t, "foo", ss.Description) assert.NotEmpty(t, ss.RevDT) assert.Equal(t, "test", ss.Label) assert.Equal(t, 0, ss.TotalDeploys) assert.NotEmpty(t, ss.LatestRev) assert.Equal(t, ssID, ss.ID) assert.False(t, ss.IsPublic) assert.Equal(t, 0, ss.ActiveDeploys) assert.NotEmpty(t, ss.CreateDT) assert.NotEmpty(t, ss.UserID) err = c.StackScriptUpdate(ssID, String("test-2"), String("quux"), String("129,130"), Bool(true), String("baz"), String("#! /bin/bash baz")) require.NoError(t, err) ssList, err = c.StackScriptList(Int(ssID)) require.NoError(t, err) require.Len(t, ssList, 1) ss = ssList[0] assert.Equal(t, "baz", ss.RevNote) assert.Equal(t, "#! /bin/bash baz", ss.Script) assert.Equal(t, "129,130", ss.DistIDList) assert.Equal(t, "quux", ss.Description) assert.Equal(t, "test-2", ss.Label) assert.Equal(t, ssID, ss.ID) assert.True(t, ss.IsPublic) err = c.StackScriptDelete(ssID) require.NoError(t, err) }
func TestImageListOK(t *testing.T) { c, ts := clientFor(newMockAPIServer(t, mockImageListOK())) defer ts.Close() imgs, err := c.ImageList(Int(402716), Bool(false)) require.NoError(t, err) require.Len(t, imgs, 1) i := imgs[0] assert.Equal(t, "baz", i.LastUsedDT) assert.Equal(t, 600, i.MinSize) assert.Equal(t, "foo", i.Description) assert.Equal(t, "bar", i.Label) assert.Equal(t, "quux", i.Creator) assert.Equal(t, "available", i.Status) assert.True(t, i.IsPublic) assert.Equal(t, "2015-07-07 23:55:59.0", i.CreateDT) assert.Equal(t, "manual", i.Type) assert.Equal(t, "ext4", i.FSType) assert.Equal(t, 402716, i.ID) }
func TestStackScriptListOK(t *testing.T) { c, ts := clientFor(newMockAPIServer(t, mockStackScriptListOK())) defer ts.Close() ssList, err := c.StackScriptList(Int(12567)) require.NoError(t, err) require.Len(t, ssList, 1) ss := ssList[0] assert.Equal(t, "bar", ss.RevNote) assert.Equal(t, "#! /bin/bash foo", ss.Script) assert.Equal(t, "130,", ss.DistIDList) assert.Equal(t, "2015-07-08 23:46:50.0", ss.RevDT) assert.Equal(t, "test", ss.Label) assert.Equal(t, 1, ss.TotalDeploys) assert.Equal(t, 60999, ss.LatestRev) assert.Equal(t, 12567, ss.ID) assert.True(t, ss.IsPublic) assert.Equal(t, 2, ss.ActiveDeploys) assert.Equal(t, "2015-07-08 23:46:50.0", ss.CreateDT) assert.Equal(t, 1337, ss.UserID) }
func TestAvailStackScriptsOK(t *testing.T) { c, ts := clientFor(newMockAPIServer(t, mockAvailStackScriptsOK())) defer ts.Close() scripts, err := c.AvailStackScripts(Int(1), String("bar"), String("baz")) require.NoError(t, err) require.Len(t, scripts, 1) s := scripts[0] assert.Equal(t, "Professional Services", s.RevNote) assert.Contains(t, s.Script, "#!/bin/bash") assert.Equal(t, "127", s.DistIDList) assert.Contains(t, s.Description, "cPanel takes an hour to install.") assert.Equal(t, "2015-01-07 15:48:57.0", s.RevDT) assert.Equal(t, "cPanel", s.Label) assert.Equal(t, 207, s.TotalDeploys) assert.Equal(t, 53081, s.LatestRev) assert.Equal(t, 11078, s.ID) assert.True(t, s.IsPublic) assert.Equal(t, 125, s.ActiveDeploys) assert.Equal(t, "2015-01-07 15:48:57.0", s.CreateDT) assert.Equal(t, 307510, s.UserID) }
func TestLinodeListOK(t *testing.T) { c, ts := clientFor(newMockAPIServer(t, mockLinodeListOK())) defer ts.Close() nodes, err := c.LinodeList(Int(1139016)) require.NoError(t, err) require.Len(t, nodes, 1) n := nodes[0] assert.True(t, n.AlertCPUEnabled, "n.AlertCPUEnabled") assert.True(t, n.AlertBWInEnabled, "n.AlertBWINEnabled") assert.True(t, n.AlertBWQuotaEnabled, "n.AlertBWQuotaEnabled") assert.Equal(t, 10000, n.AlertDiskIOThreshold, "n.AlertDiskIOThreshold") assert.Equal(t, 0, n.BackupWindow, "n.BackupWindow") assert.Equal(t, true, n.Watchdog, "n.Watchdog") assert.Equal(t, "foo", n.DistVendor, "n.DistVendor") assert.Equal(t, 2, n.DatacenterID, "n.DatacenterID") assert.Equal(t, 1, n.Status, "n.Status") assert.True(t, n.AlertDiskIOEnabled, "n.AlertDiskIOEnabled") assert.Equal(t, "2015-07-02 23:08:52.0", n.CreateDT, "n.CreateDT") assert.Equal(t, 24576, n.TotalHD, "n.TotalHD") assert.Equal(t, 80, n.AlertBWQuotaThreshold, "n.AlertBWQUotaThreshold") assert.Equal(t, 1024, n.TotalRAM, "n.TotalRAM") assert.Equal(t, 10, n.AlertBWInThreshold, "n.AlertBWInThreshold") assert.Equal(t, 1139016, n.ID, "n.ID") assert.Equal(t, 10, n.AlertBWOutThreshold, "n.AlertBWOutThreshold") assert.True(t, n.AlertBWOutEnabled, "n.AlertBWOutEnabled") assert.True(t, n.BackupsEnabled, "n.BackupsEnabled") assert.Equal(t, 90, n.AlertCPUThreshold, "n.AlertCPUThreshold") assert.Equal(t, 1, n.PlanID, "n.PlanID") assert.Equal(t, 1, n.BackupWeeklyDay, "n.BackupWeeklyDay") assert.Equal(t, "linode1139016", n.Label, "n.Label") assert.Equal(t, "bar", n.DisplayGroup, "n.DisplayGroup") assert.Equal(t, 2000, n.TotalXfer, "n.TotalXfer") }
func TestNodeBalancerIntegration(t *testing.T) { c := NewClient(apiKey) t.Log("creating test linode...") linodeID, err := c.LinodeCreate(2, 1, nil) require.NoError(t, err) require.NotEmpty(t, linodeID) err = c.WaitForAllJobs(linodeID, 3*time.Second, 60*time.Second) require.NoError(t, err) t.Log("assigning private IP...") _, linodeIP, err := c.LinodeIPAddPrivate(linodeID) require.NoError(t, err) require.NotEmpty(t, linodeIP) t.Log("nodebalancer.create...") nbID, err := c.NodeBalancerCreate(2, String("testing"), Int(5)) require.NoError(t, err) require.NotEmpty(t, nbID) t.Log("nodebalancer.list...") nbList, err := c.NodeBalancerList(Int(nbID)) require.NoError(t, err) require.Len(t, nbList, 1) n := nbList[0] assert.NotEmpty(t, n.Hostname) assert.Equal(t, "testing", n.Label) assert.Equal(t, 5, n.Throttle) assert.Equal(t, 2, n.DatacenterID) assert.NotEmpty(t, n.IPv4Addr) assert.NotEmpty(t, n.IPv6Addr) assert.Equal(t, nbID, n.ID) t.Log("nodebalancer.update...") err = c.NodeBalancerUpdate(nbID, String("testing-2"), Int(10)) require.NoError(t, err) t.Log("nodebalancer.list...") nbList, err = c.NodeBalancerList(Int(nbID)) require.NoError(t, err) require.Len(t, nbList, 1) n = nbList[0] assert.Equal(t, "testing-2", n.Label) assert.Equal(t, 10, n.Throttle) assert.Equal(t, nbID, n.ID) nbcco := NodeBalancerConfigCreateOpts{ Port: Int(80), Protocol: String("http"), Algorithm: String("roundrobin"), Stickiness: String("http_cookie"), Check: String("http"), CheckInterval: Int(30), CheckTimeout: Int(29), CheckAttempts: Int(15), CheckPath: String("/foo"), CheckBody: String("bar"), CheckPassive: Bool(false), } t.Log("nodebalancer.config.create...") confID, err := c.NodeBalancerConfigCreate(nbID, nbcco) require.NoError(t, err) require.NotEmpty(t, confID) t.Log("nodebalancer.config.list...") nbconfs, err := c.NodeBalancerConfigList(nbID, Int(confID)) require.NoError(t, err) require.Len(t, nbconfs, 1) nbc := nbconfs[0] assert.Equal(t, "http_cookie", nbc.Stickiness) assert.Equal(t, "", nbc.SSLCommonName) assert.Equal(t, "/foo", nbc.CheckPath) assert.Equal(t, "bar", nbc.CheckBody) assert.Equal(t, 30, nbc.CheckInterval) assert.Equal(t, "", nbc.SSLFingerprint) assert.Equal(t, "roundrobin", nbc.Algorithm) assert.Equal(t, confID, nbc.ID) assert.Equal(t, 15, nbc.CheckAttempts) assert.Equal(t, nbID, nbc.NodeBalancerID) assert.Equal(t, 80, nbc.Port) assert.Equal(t, "http", nbc.Check) assert.False(t, nbc.CheckPassive) assert.Equal(t, "http", nbc.Protocol) assert.Equal(t, 29, nbc.CheckTimeout) nbcuo := NodeBalancerConfigUpdateOpts{ Port: Int(90), Protocol: String("https"), Algorithm: String("leastconn"), Stickiness: String("table"), Check: String("http_body"), CheckInterval: Int(24), CheckTimeout: Int(23), CheckAttempts: Int(20), CheckPath: String("/bar"), CheckBody: String("quux"), CheckPassive: Bool(true), SSLCert: String(sslCert), SSLKey: String(sslKey), } t.Log("nodebalancer.config.update...") err = c.NodeBalancerConfigUpdate(confID, nbcuo) require.NoError(t, err) t.Log("nodebalancer.config.list...") nbconfs, err = c.NodeBalancerConfigList(nbID, Int(confID)) require.NoError(t, err) require.Len(t, nbconfs, 1) nbc = nbconfs[0] assert.Equal(t, "table", nbc.Stickiness) assert.Equal(t, "foo.com", nbc.SSLCommonName) assert.Equal(t, "/bar", nbc.CheckPath) assert.Equal(t, "quux", nbc.CheckBody) assert.Equal(t, 24, nbc.CheckInterval) assert.Equal(t, "0B:40:09:0C:4E:DA:5B:FB:2A:31:69:C9:4D:80:AE:CE:76:8F:DA:60", nbc.SSLFingerprint) assert.Equal(t, "leastconn", nbc.Algorithm) assert.Equal(t, confID, nbc.ID) assert.Equal(t, 20, nbc.CheckAttempts) assert.Equal(t, nbID, nbc.NodeBalancerID) assert.Equal(t, 90, nbc.Port) assert.Equal(t, "http_body", nbc.Check) assert.True(t, nbc.CheckPassive) assert.Equal(t, "https", nbc.Protocol) assert.Equal(t, 23, nbc.CheckTimeout) t.Log("nodebalancer.node.create...") nbNodeID, err := c.NodeBalancerNodeCreate(confID, "test", linodeIP+":90", Int(50), String("accept")) require.NoError(t, err) require.NotEmpty(t, nbNodeID) t.Log("nodebalancer.node.list...") nbNodes, err := c.NodeBalancerNodeList(confID, Int(nbNodeID)) require.NoError(t, err) require.Len(t, nbNodes, 1) node := nbNodes[0] assert.Equal(t, 50, node.Weight) assert.Equal(t, linodeIP+":90", node.Address) assert.Equal(t, "test", node.Label) assert.Equal(t, nbNodeID, node.ID) assert.Equal(t, "accept", node.Mode) assert.Equal(t, confID, node.ConfigID) assert.NotEmpty(t, node.Status) assert.Equal(t, nbID, node.NodeBalancerID) t.Log("nodebalancer.node.update...") err = c.NodeBalancerNodeUpdate(nbNodeID, String("test-2"), String(linodeIP+":80"), Int(60), String("reject")) require.NoError(t, err) t.Log("nodebalancer.node.list...") nbNodes, err = c.NodeBalancerNodeList(confID, Int(nbNodeID)) require.NoError(t, err) require.Len(t, nbNodes, 1) node = nbNodes[0] assert.Equal(t, 60, node.Weight) assert.Equal(t, linodeIP+":80", node.Address) assert.Equal(t, "test-2", node.Label) assert.Equal(t, nbNodeID, node.ID) assert.Equal(t, "reject", node.Mode) assert.Equal(t, confID, node.ConfigID) assert.NotEmpty(t, node.Status) assert.Equal(t, nbID, node.NodeBalancerID) t.Log("nodebalancer.node.delete...") err = c.NodeBalancerNodeDelete(nbNodeID) require.NoError(t, err) t.Log("nodebalancer.config.delete...") err = c.NodeBalancerConfigDelete(nbID, confID) require.NoError(t, err) t.Log("nodebalancer.delete...") err = c.NodeBalancerDelete(nbID) require.NoError(t, err) t.Log("deleting test linode...") err = c.LinodeDelete(linodeID, Bool(true)) require.NoError(t, err) }
func TestLinodeIntegration(t *testing.T) { c := NewClient(apiKey) t.Log("c.LinodeCreate...") id, err := c.LinodeCreate(2, 1, nil) require.NoError(t, err) require.NotEmpty(t, id) t.Log("c.WaitForAllJobs...") err = c.WaitForAllJobs(id, 2*time.Second, 60*time.Second) require.NoError(t, err) t.Log("c.LinodeList...") nodes, err := c.LinodeList(Int(id)) require.NoError(t, err) require.Len(t, nodes, 1) t.Log("c.LinodeResize...") err = c.LinodeResize(id, 2) require.NoError(t, err) t.Log("c.LinodeUpdate...") linodeOpts := LinodeOpts{ Label: String("integration-test"), DisplayGroup: String("tests"), AlertCPUEnabled: Bool(false), AlertCPUThreshold: Int(50), AlertDiskIOEnabled: Bool(false), AlertDiskIOThreshold: Int(500), AlertBWInEnabled: Bool(false), AlertBWInThreshold: Int(30), AlertBWOutEnabled: Bool(false), AlertBWOutThreshold: Int(31), AlertBWQuotaEnabled: Bool(false), AlertBWQuotaThreshold: Int(55), BackupWindow: Int(3), BackupWeeklyDay: Int(6), Watchdog: Bool(false), } err = c.LinodeUpdate(id, linodeOpts) require.NoError(t, err) t.Log("c.LinodeDiskCreate...") jobID, swapDiskID, err := c.LinodeDiskCreate(id, "test-swap", "swap", 256) require.NoError(t, err) require.NotEmpty(t, swapDiskID, "swapDiskID") require.NotEmpty(t, jobID, "jobID") t.Log("c.WaitForJob...") ok, err := c.WaitForJob(id, jobID, 2*time.Second, 60*time.Second) require.NoError(t, err) require.True(t, ok, "creating swap failed") t.Log("c.LinodeDiskCreateFromDistribution...") jobID, distDiskID, err := c.LinodeDiskCreateFromDistribution(id, 130, "test-dist", 600, rootPass, String(rootSSHKey)) require.NoError(t, err) require.NotEmpty(t, jobID) require.NotEmpty(t, distDiskID) t.Log("c.WaitForJob...") ok, err = c.WaitForJob(id, jobID, 2*time.Second, 80*time.Second) require.NoError(t, err) require.True(t, ok) t.Log("c.LinodeConfigCreate...") lcco := LinodeConfigCreateOpts{ Comments: String("foo"), RAMLimit: Int(800), VirtMode: String("paravirt"), RunLevel: String("default"), RootDeviceNum: Int(1), RootDeviceRO: Bool(true), HelperDisableUpdateDB: Bool(true), HelperDistro: Bool(true), HelperXen: Bool(true), HelperDepmod: Bool(true), HelperNetwork: Bool(true), DevTmpFSAutomount: Bool(true), } diskList := strconv.Itoa(distDiskID) + "," + strconv.Itoa(swapDiskID) + "," confID, err := c.LinodeConfigCreate(id, 138, "test-conf1", diskList, lcco) require.NoError(t, err) require.NotEmpty(t, confID) t.Log("c.LinodeConfigList...") confs, err := c.LinodeConfigList(id, Int(confID)) require.NoError(t, err) require.Len(t, confs, 1) cfg := confs[0] assert.Equal(t, "", cfg.RootDeviceCustom) assert.Equal(t, "foo", cfg.Comments) assert.Equal(t, "test-conf1", cfg.Label) assert.Equal(t, confID, cfg.ID) assert.NotEmpty(t, cfg.DiskList) assert.Equal(t, "default", cfg.RunLevel) assert.Equal(t, 1, cfg.RootDeviceNum) assert.Equal(t, 800, cfg.RAMLimit) assert.Equal(t, "paravirt", cfg.VirtMode) assert.Equal(t, id, cfg.LinodeID) assert.Equal(t, 138, cfg.KernelID) assert.True(t, cfg.DevTmpFSAutomount) assert.True(t, cfg.HelperDistro) assert.True(t, cfg.HelperDisableUpdateDB) assert.True(t, cfg.HelperDepmod) assert.True(t, cfg.HelperXen) assert.True(t, cfg.RootDeviceRO) assert.True(t, cfg.HelperNetwork) assert.False(t, cfg.IsRescue) t.Log("c.LinodeConfigUpdate...") lcuo := LinodeConfigUpdateOpts{ LinodeID: Int(id), KernelID: Int(138), Comments: String("foo"), RAMLimit: Int(800), VirtMode: String("paravirt"), RunLevel: String("default"), RootDeviceNum: Int(1), RootDeviceRO: Bool(true), HelperDisableUpdateDB: Bool(true), HelperDistro: Bool(true), HelperXen: Bool(true), HelperDepmod: Bool(true), HelperNetwork: Bool(true), DevTmpFSAutomount: Bool(true), } err = c.LinodeConfigUpdate(confID, lcuo) require.NoError(t, err) t.Log("c.LinodeDiskImagize...") jobID, imgID, err := c.LinodeDiskImagize(id, distDiskID, String("test-image desc"), String("test-image label")) require.NoError(t, err) require.NotEmpty(t, jobID) require.NotEmpty(t, imgID) t.Log("c.WaitForJob...") ok, err = c.WaitForJob(id, jobID, 2*time.Second, 120*time.Second) require.NoError(t, err) require.True(t, ok) t.Log("c.LinodeDiskCreateFromImage...") jobID, imgDiskID, err := c.LinodeDiskCreateFromImage(imgID, id, "test-image", Int(800), String(rootPass), String(rootSSHKey)) require.NoError(t, err) require.NotEmpty(t, jobID) require.NotEmpty(t, imgDiskID) t.Log("c.WaitForJob...") ok, err = c.WaitForJob(id, jobID, 2*time.Second, 120*time.Second) require.NoError(t, err) require.True(t, ok) t.Log("deleting image...") err = c.ImageDelete(imgID) assert.NoError(t, err) t.Log("c.LinodeDiskDelete...") jobID, err = c.LinodeDiskDelete(id, imgDiskID) require.NoError(t, err) require.NotEmpty(t, jobID) t.Log("c.WaitForJob...") ok, err = c.WaitForJob(id, jobID, 2*time.Second, 60*time.Second) require.NoError(t, err) require.True(t, ok) t.Log("c.LinodeDiskDuplicate...") jobID, dupeDiskID, err := c.LinodeDiskDuplicate(id, swapDiskID) require.NoError(t, err) require.NotEmpty(t, dupeDiskID) require.NotEmpty(t, jobID) t.Log("c.WaitForJob...") ok, err = c.WaitForJob(id, jobID, 2*time.Second, 60*time.Second) require.NoError(t, err) require.True(t, ok) t.Log("c.LinodeDiskResize...") jobID, err = c.LinodeDiskResize(id, dupeDiskID, 512) require.NoError(t, err) require.NotEmpty(t, jobID) t.Log("c.WaitForJob...") ok, err = c.WaitForJob(id, jobID, 1*time.Second, 60*time.Second) require.NoError(t, err) require.True(t, ok) t.Log("c.LinodeDiskUpdate...") err = c.LinodeDiskUpdate(id, dupeDiskID, String("updated-label"), Bool(true)) require.NoError(t, err) curDisks, err := c.LinodeDiskList(id, nil) require.NoError(t, err) require.Len(t, curDisks, 3) t.Log("c.LinodeIPList...") ipList, err := c.LinodeIPList(Int(id), nil) require.NoError(t, err) require.Len(t, ipList, 1) pubID := ipList[0].ID t.Log("c.LinodeIPAddPrivate...") _, _, err = c.LinodeIPAddPrivate(id) require.NoError(t, err) t.Log("c.LinodeIPList...") ipList, err = c.LinodeIPList(Int(id), nil) require.NoError(t, err) require.Len(t, ipList, 2) t.Log("c.LinodeClone...") cloneID, err := c.LinodeClone(id, 2, 1, nil, nil) require.NoError(t, err) require.NotEmpty(t, cloneID) t.Log("c.WaitForAllJobs...") err = c.WaitForAllJobs(cloneID, 2*time.Second, 60*time.Second) require.NoError(t, err) t.Log("c.LinodeIPList...") ipList, err = c.LinodeIPList(Int(cloneID), nil) require.NoError(t, err) require.Len(t, ipList, 1) clonePubID := ipList[0].ID t.Log("c.LinodeIPSwap...") err = c.LinodeIPSwap(pubID, Int(clonePubID), nil) require.NoError(t, err) t.Log("c.WaitForAllJobs...") err = c.WaitForAllJobs(cloneID, 2*time.Second, 60*time.Second) require.NoError(t, err) t.Log("c.LinodeDelete...") err = c.LinodeDelete(cloneID, Bool(true)) require.NoError(t, err) ssOpts := struct { DBPassword string `json:"db_password"` DBName string `json:"db_name"` MySQLUsername string `json:"db_user"` MySQLUserpass string `json:"db_user_password"` }{ "foo", "bar", "baz", "quux", } ssUDFResp, err := json.Marshal(ssOpts) require.NoError(t, err) t.Log("c.DiskCreateFromStackScript") jobID, diskID, err := c.LinodeDiskCreateFromStackScript(id, linodeLampStackSS, string(ssUDFResp), 130, "test-ss", 600, rootPass, String(rootSSHKey)) require.NoError(t, err) require.NotEmpty(t, jobID) require.NotEmpty(t, diskID) t.Log("c.WaitForJob...") ok, err = c.WaitForJob(id, jobID, 2*time.Second, 120*time.Second) require.NoError(t, err) require.True(t, ok) t.Log("c.LinodeBoot...") jobID, err = c.LinodeBoot(id, Int(confID)) require.NoError(t, err) require.NotEmpty(t, jobID) t.Log("c.WaitForJob...") ok, err = c.WaitForJob(id, jobID, 2*time.Second, 120*time.Second) require.NoError(t, err) require.True(t, ok) t.Log("c.LinodeReboot...") jobID, err = c.LinodeReboot(id, Int(confID)) require.NoError(t, err) require.NotEmpty(t, jobID) t.Log("c.WaitForJob...") ok, err = c.WaitForJob(id, jobID, 2*time.Second, 120*time.Second) require.NoError(t, err) require.True(t, ok) t.Log("c.LinodeShutdown...") jobID, err = c.LinodeShutdown(id) require.NoError(t, err) require.NotEmpty(t, jobID) t.Log("c.WaitForJob...") ok, err = c.WaitForJob(id, jobID, 2*time.Second, 120*time.Second) require.NoError(t, err) require.True(t, ok) err = c.LinodeConfigDelete(id, confID) require.NoError(t, err) t.Log("c.LinodeDelete...") err = c.LinodeDelete(id, Bool(true)) }