Exemplo n.º 1
0
        protected override void Context()
        {
            if (!_arrangementCompleted)
            {
                // at present, no tables are modified so only arrange the tables once per test pass
                // and putting the arrangement into a static context.
                // (this knocked test runs down to ~30 seconds from ~5 minutes).

                _credentials = ClusterCredentialsFactory.CreateFromFile(@".\credentials.txt");
                var client = new HBaseClient(_credentials);

                // ensure tables from previous tests are cleaned up
                TableList tables = client.ListTables();
                foreach (string name in tables.name)
                {
                    string pinnedName = name;
                    if (name.StartsWith(TableNamePrefix, StringComparison.Ordinal))
                    {
                        client.DeleteTable(pinnedName);
                    }
                }

                AddTable();
                PopulateTable();

                _arrangementCompleted = true;
            }
        }
Exemplo n.º 2
0
        protected override void Context()
        {
            _credentials = ClusterCredentialsFactory.CreateFromFile(@".\credentials.txt");
            var client = new HBaseClient(_credentials);

            // ensure tables from previous tests are cleaned up

            TableList tables = client.ListTables();

            foreach (string name in tables.name)
            {
                if (name.StartsWith(TestTablePrefix, StringComparison.Ordinal))
                {
                    client.DeleteTable(name);
                }
            }

            // add a table specific to this test
            _testTableName        = TestTablePrefix + _random.Next(10000);
            _testTableSchema      = new TableSchema();
            _testTableSchema.name = _testTableName;
            _testTableSchema.columns.Add(new ColumnSchema {
                name = "d"
            });

            client.CreateTable(_testTableSchema);
        }
Exemplo n.º 3
0
        private HBaseClient GetClient()
        {
            _credentials = ClusterCredentialsFactory.CreateFromFile(@".\credentials.txt");
            var options = RequestOptions.GetDefaultOptions();

            options.RetryPolicy = RetryPolicy.NoRetry;

            var client = new HBaseClient(_credentials, options);

            #region VNet
            //options.TimeoutMillis = 30000;
            //options.KeepAlive = false;
            //options.Port = 8090;
            //options.AlternativeEndpoint = "/";
            //var client = new HBaseClient(null, options, new LoadBalancerRoundRobin(new List<string> { "ip address" }));
            #endregion

            return(client);
        }
        public void It_should_throw_the_file_does_not_exist()
        {
            string path = Path.Combine(Directory.GetCurrentDirectory(), Guid.NewGuid().ToString());
            var    fnfe =
                (FileNotFoundException)
                typeof(FileNotFoundException).ShouldBeThrownBy(() => DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromFile(path)));

            fnfe.FileName.ShouldEqual(path);
        }
        public void It_should_throw_when_the_list_is_too_short()
        {
            var lst = new List <string>();

            // empty
            var ae =
                (ArgumentException)
                typeof(ArgumentException).ShouldBeThrownBy(() => DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromList(lst)));

            ae.ParamName.ShouldEqual("lines");

            // one
            lst.Add(Guid.NewGuid().ToString());
            ae =
                (ArgumentException)
                typeof(ArgumentException).ShouldBeThrownBy(() => DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromList(lst)));
            ae.ParamName.ShouldEqual("lines");

            // two
            lst.Add(Guid.NewGuid().ToString());
            ae =
                (ArgumentException)
                typeof(ArgumentException).ShouldBeThrownBy(() => DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromList(lst)));
            ae.ParamName.ShouldEqual("lines");
        }
        public void It_should_throw_when_the_list_is_null()
        {
            var ane =
                (ArgumentNullException)
                typeof(ArgumentNullException).ShouldBeThrownBy(() => DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromList(null)));

            ane.ParamName.ShouldEqual("lines");
        }