projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
15003: Merge branch 'master'
[arvados.git]
/
lib
/
cloud
/
azure
/
azure_test.go
diff --git
a/lib/cloud/azure/azure_test.go
b/lib/cloud/azure/azure_test.go
index 850a3fb4270fd9c5da7b7829e9f00fa27c630a49..96bfb4fefbfd8c8c13c199a5621977776f762505 100644
(file)
--- a/
lib/cloud/azure/azure_test.go
+++ b/
lib/cloud/azure/azure_test.go
@@
-25,6
+25,7
@@
// StorageAccount: example
// BlobContainer: vhds
// DeleteDanglingResourcesAfter: 20s
// StorageAccount: example
// BlobContainer: vhds
// DeleteDanglingResourcesAfter: 20s
+// AdminUsername: crunch
package azure
package azure
@@
-42,6
+43,7
@@
import (
"time"
"git.curoverse.com/arvados.git/lib/cloud"
"time"
"git.curoverse.com/arvados.git/lib/cloud"
+ "git.curoverse.com/arvados.git/lib/dispatchcloud/test"
"git.curoverse.com/arvados.git/sdk/go/arvados"
"git.curoverse.com/arvados.git/sdk/go/config"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute"
"git.curoverse.com/arvados.git/sdk/go/arvados"
"git.curoverse.com/arvados.git/sdk/go/config"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute"
@@
-50,7
+52,6
@@
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/to"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/to"
- "github.com/jmcvetta/randutil"
"github.com/sirupsen/logrus"
"golang.org/x/crypto/ssh"
check "gopkg.in/check.v1"
"github.com/sirupsen/logrus"
"golang.org/x/crypto/ssh"
check "gopkg.in/check.v1"
@@
-67,8
+68,6
@@
var _ = check.Suite(&AzureInstanceSetSuite{})
type VirtualMachinesClientStub struct{}
type VirtualMachinesClientStub struct{}
-var testKey = []byte(`ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLQS1ExT2+WjA0d/hntEAyAtgeN1W2ik2QX8c2zO6HjlPHWXL92r07W0WMuDib40Pcevpi1BXeBWXA9ZB5KKMJB+ukaAu22KklnQuUmNvk6ZXnPKSkGxuCYvPQb08WhHf3p1VxiKfP3iauedBDM4x9/bkJohlBBQiFXzNUcQ+a6rKiMzmJN2gbL8ncyUzc+XQ5q4JndTwTGtOlzDiGOc9O4z5Dd76wtAVJneOuuNpwfFRVHThpJM6VThpCZOnl8APaceWXKeuwOuCae3COZMz++xQfxOfZ9Z8aIwo+TlQhsRaNfZ4Vjrop6ej8dtfZtgUFKfbXEOYaHrGrWGotFDTD example@example`)
-
func (*VirtualMachinesClientStub) createOrUpdate(ctx context.Context,
resourceGroupName string,
VMName string,
func (*VirtualMachinesClientStub) createOrUpdate(ctx context.Context,
resourceGroupName string,
VMName string,
@@
-105,6
+104,16
@@
func (*InterfacesClientStub) listComplete(ctx context.Context, resourceGroupName
return network.InterfaceListResultIterator{}, nil
}
return network.InterfaceListResultIterator{}, nil
}
+type BlobContainerStub struct{}
+
+func (*BlobContainerStub) GetBlobReference(name string) *storage.Blob {
+ return nil
+}
+
+func (*BlobContainerStub) ListBlobs(params storage.ListBlobsParameters) (storage.BlobListResponse, error) {
+ return storage.BlobListResponse{}, nil
+}
+
type testConfig struct {
ImageIDForTestSuite string
DriverParameters json.RawMessage
type testConfig struct {
ImageIDForTestSuite string
DriverParameters json.RawMessage
@@
-148,6
+157,7
@@
func GetInstanceSet() (cloud.InstanceSet, cloud.ImageID, arvados.Cluster, error)
ap.ctx, ap.stopFunc = context.WithCancel(context.Background())
ap.vmClient = &VirtualMachinesClientStub{}
ap.netClient = &InterfacesClientStub{}
ap.ctx, ap.stopFunc = context.WithCancel(context.Background())
ap.vmClient = &VirtualMachinesClientStub{}
ap.netClient = &InterfacesClientStub{}
+ ap.blobcont = &BlobContainerStub{}
return &ap, cloud.ImageID("blob"), cluster, nil
}
return &ap, cloud.ImageID("blob"), cluster, nil
}
@@
-157,21
+167,19
@@
func (*AzureInstanceSetSuite) TestCreate(c *check.C) {
c.Fatal("Error making provider", err)
}
c.Fatal("Error making provider", err)
}
- pk, _, _, _, err := ssh.ParseAuthorizedKey(testKey)
- c.Assert(err, check.IsNil)
-
- nodetoken, err := randutil.String(40, "abcdefghijklmnopqrstuvwxyz0123456789")
+ pk, _ := test.LoadTestKey(c, "../../dispatchcloud/test/sshkey_dispatch")
c.Assert(err, check.IsNil)
inst, err := ap.Create(cluster.InstanceTypes["tiny"],
img, map[string]string{
c.Assert(err, check.IsNil)
inst, err := ap.Create(cluster.InstanceTypes["tiny"],
img, map[string]string{
- "
node-token": nodetoken}
,
- pk)
+ "
TestTagName": "test tag value"
,
+
}, "umask 0600; echo -n test-file-data >/var/run/test-file",
pk)
c.Assert(err, check.IsNil)
c.Assert(err, check.IsNil)
- tg := inst.Tags()
- log.Printf("Result %v %v %v", inst.String(), inst.Address(), tg)
+ tags := inst.Tags()
+ c.Check(tags["TestTagName"], check.Equals, "test tag value")
+ c.Logf("inst.String()=%v Address()=%v Tags()=%v", inst.String(), inst.Address(), tags)
}
}
@@
-306,19
+314,22
@@
func (*AzureInstanceSetSuite) TestSSH(c *check.C) {
c.Assert(err, check.IsNil)
if len(l) > 0 {
c.Assert(err, check.IsNil)
if len(l) > 0 {
-
sshclient, err := SetupSSHClient(c, l[0])
c.Assert(err, check.IsNil)
sshclient, err := SetupSSHClient(c, l[0])
c.Assert(err, check.IsNil)
+ defer sshclient.Conn.Close()
sess, err := sshclient.NewSession()
c.Assert(err, check.IsNil)
sess, err := sshclient.NewSession()
c.Assert(err, check.IsNil)
-
-
out, err := sess.Output("cat /home/crunch/node-token
")
+ defer sess.Close()
+
_, err = sess.Output("find /var/run/test-file -maxdepth 0 -user root -perm 0600
")
c.Assert(err, check.IsNil)
c.Assert(err, check.IsNil)
- log.Printf("%v", string(out))
-
- sshclient.Conn.Close()
+ sess, err = sshclient.NewSession()
+ c.Assert(err, check.IsNil)
+ defer sess.Close()
+ out, err := sess.Output("sudo cat /var/run/test-file")
+ c.Assert(err, check.IsNil)
+ c.Check(string(out), check.Equals, "test-file-data")
}
}
}
}