Exemple #1
0
        // create collection space, if the collection space exists then return
        public static CollectionSpace CreateCollecitonSpace(Sequoiadb sdb, string csName, int pageSize)
        {
            CollectionSpace cs = null;
            try
            {
                cs = sdb.CreateCollectionSpace(csName, pageSize);
            }
            catch (BaseException e)
            {
                // verify whether the collection space exists
                if ("SDB_DMS_CS_EXIST" == e.ErrorType)
                    cs = GetCollecitonSpace(sdb, csName);
                // invalid page size argument
                else if ("SDB_INVALIDARG" == e.ErrorType)
                {
                    Console.WriteLine("Failed to create collection space {0}, invalid page size {1}", csName, pageSize);
                    Environment.Exit(0);
                }
                else
                {
                    Console.WriteLine("Failed to create collection space {0},ErrorType = {1}", csName, e.ErrorType);
                    Environment.Exit(0);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Environment.Exit(0);
            }

            return cs;
        }
 public void CollectionTest()
 {
     string csName = "testCS1";
     string clName = "testCL1";
     CollectionSpace cs = null;
     Sequoiadb sdb = new Sequoiadb(config.conf.Coord.Address);
     sdb.Connect(config.conf.UserName, config.conf.Password);
     if(sdb.IsCollectionSpaceExist(csName))
         cs = sdb.GetCollecitonSpace(csName);
     else
         cs = sdb.CreateCollectionSpace(csName);
     if (!cs.IsCollectionExist(clName))
         cs.CreateCollection(clName);
     cs.DropCollection(clName);
     Assert.IsFalse(cs.IsCollectionExist(clName));
     sdb.DropCollectionSpace(csName);
     sdb.Disconnect();
 }
 public void MyTestInitialize()
 {
     try
     {
         sdb = new Sequoiadb(config.conf.Coord.Address);
         sdb.Connect(config.conf.UserName, config.conf.Password);
         if (sdb.IsCollectionSpaceExist(csName))
             sdb.DropCollectionSpace(csName);
         cs = sdb.CreateCollectionSpace(csName);
         coll = cs.CreateCollection(cName);
     }
     catch (BaseException e)
     {
         Console.WriteLine("Failed to Initialize in DBCollectionTest, ErrorType = {0}", e.ErrorType);
         Environment.Exit(0);
     }
 }
Exemple #4
0
 public void MyTestInitialize()
 {
     sdb = new Sequoiadb(config.conf.Coord.Address);
     sdb.Connect(config.conf.UserName, config.conf.Password);
     if (sdb.IsCollectionSpaceExist(csName))
         sdb.DropCollectionSpace(csName);
     cs = sdb.CreateCollectionSpace(csName);
     coll = cs.CreateCollection(cName);
 }
Exemple #5
0
        public void ConnectWithSSLTest()
        {
            ConfigOptions cfgOpt = null ;
            CollectionSpace cs2 = null;
            DBCollection coll2 = null;
            Sequoiadb sdb2 = new Sequoiadb(config.conf.Coord.Address);
            System.Console.WriteLine(config.conf.Coord.Address.ToString());

            // set connect using ssl
            cfgOpt = new ConfigOptions();
            cfgOpt.UseSSL = true;

            // connect to database
            sdb2.Connect("", "", cfgOpt);
            if (true == sdb2.IsCollectionSpaceExist("testSSL"))
                cs2 = sdb2.GetCollecitonSpace("testSSL");
            else
                cs2 = sdb2.CreateCollectionSpace("testSSL");
            if (true == cs2.IsCollectionExist("testSSL"))
                coll2 = cs2.GetCollection("testSSL");
            else
                coll2 = cs2.CreateCollection("testSSL");

            sdb2.DropCollectionSpace("testSSL");
        }