Esempio n. 1
0
        public void Test2()
        {
            string dbname = IntegrationTestsCommons.genDbname("testcsharpclient");

            CloudConnection cloudConn = new CloudConnection(
                new LocalConnection(dbname),
                creds: new RAICredentials(
                    "e3536f8d-cbc6-4ed8-9de6-74cf4cb724a1",
                    "krnXRBoE0lX6NddvryxKIE+7RWrkWg6xk8NcGaSOdCo="
                    ),
                verifySSL: false
                );

            HttpRequestMessage httpReq = new HttpRequestMessage();

            httpReq.Method     = HttpMethod.Get;
            httpReq.RequestUri = new Uri("https://127.0.0.1:8443/database");
            httpReq.Content    = new StringContent("{}");
            httpReq.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            httpReq.Headers.Host = "127.0.0.1";
            RAIRequest req = new RAIRequest(httpReq, cloudConn, service: "database+list");

            req.Sign(DateTime.Parse("2020-05-04T10:36:00"), debugLevel: cloudConn.DebugLevel);

            string output = string.Join(
                "\n",
                from header in req.InnerReq.Headers.Union(req.InnerReq.Content.Headers)
                orderby header.Key.ToLower()
                select string.Format(
                    "{0}: {1}",
                    header.Key.ToLower(),
                    string.Join(",", header.Value).Trim()
                    )
                ) + "\n";
            string expected =
                "authorization: RAI01-ED25519-SHA256 " +
                "Credential=e3536f8d-cbc6-4ed8-9de6-74cf4cb724a1/20200504/us-east/database+list/rai01_request, " +
                "SignedHeaders=content-type;host;x-rai-date, " +
                "Signature=77d211417454ded42dc931d25c57af6cab6cbc70f75bef4c849d37585188d659158c8c944eab866e3147bbcde21257ae0a1dfece3c0f3f43a838b3f9524e0f0a\n" +
                "content-type: application/json\n" +
                "host: 127.0.0.1\n" +
                "x-rai-date: 20200504T103600Z\n";

            Assert.AreEqual(output, expected);
        }
 public void Test1()
 {
     IntegrationTestsCommons.RunAllTests(CreateCloudConnection);
 }
        public static CloudConnection CreateCloudConnection()
        {
            ManagementConnection mgmtConn = new ManagementConnection(
                scheme: "https",
                host: "azure-ssh.relationalai.com",
                port: 443,
                verifySSL: false
                );

            ComputeInfoProtocol provisionedCompute = null;
            bool requestedOrProvisioning           = true;

            string dbname = "";

            while (requestedOrProvisioning)
            {
                requestedOrProvisioning = false;

                var computes = mgmtConn.ListComputes();

                foreach (var comp in computes)
                {
                    if ("PROVISIONED".Equals(comp.State))
                    {
                        var databases = mgmtConn.ListDatabases();
                        foreach (var db in databases)
                        {
                            if (comp.Name.Equals(db.Default_compute_name))
                            {
                                return(CreateCloudConnection(db.Name, comp.Name, mgmtConn));
                            }
                        }

                        provisionedCompute = comp;
                        break;
                    }
                    else if ("REQUESTED".Equals(comp.State) || "PROVISIONING".Equals(comp.State))
                    {
                        requestedOrProvisioning = true;
                    }
                }

                dbname = IntegrationTestsCommons.genDbname("testcsharpclient");

                if (!requestedOrProvisioning)
                {
                    if (provisionedCompute == null)
                    {
                        provisionedCompute = mgmtConn.CreateCompute(dbname, RAIComputeSize.XS);

                        requestedOrProvisioning = true;
                    }
                }

                if (requestedOrProvisioning)
                {
                    Console.WriteLine("An instance is being requested or provisioned. Will try again in 10 seconds.");
                    Thread.Sleep(10000);
                }
            }
            return(CreateCloudConnection(dbname, provisionedCompute.Name, mgmtConn));
        }
Esempio n. 4
0
        public static LocalConnection CreateLocalConnection()
        {
            string dbname = IntegrationTestsCommons.genDbname("testcsharpclient");

            return(CreateLocalConnection(dbname));
        }