github.com/jlmeeker/kismatic@v1.10.1-0.20180612190640-57f9005a1f1a/integration-tests/packet/node_test.go (about) 1 // +build packet_integration 2 3 package packet 4 5 import ( 6 "os" 7 "testing" 8 "time" 9 ) 10 11 func TestNode(t *testing.T) { 12 // Create node 13 c := Client{ 14 Token: os.Getenv("PACKET_TOKEN"), 15 ProjectID: os.Getenv("PACKET_PROJECT_ID"), 16 } 17 18 hostname := "testNode" 19 osImage := CentOS7 20 dev, err := c.CreateNode(hostname, osImage) 21 if err != nil { 22 t.Errorf("failed to create node: %v", err) 23 } 24 // Block until ssh is up 25 deviceID := dev.ID 26 timeout := 10 * time.Minute 27 if err := c.BlockUntilNodeAccessible(deviceID, timeout, os.Getenv("PACKET_SSH_KEY"), "root"); err != nil { 28 t.Errorf("node did not become accessible") 29 } 30 // Delete node 31 time.Sleep(5 * time.Second) 32 if err := c.DeleteNode(deviceID); err != nil { 33 t.Errorf("node %q was not deleted. MANUALLY CLEAN UP NODE IN PACKET.NET", deviceID) 34 } 35 }