| 385 | } |
| 386 | |
| 387 | void NonTransactionTest() { |
| 388 | tera::ErrorCode err; |
| 389 | tera::Client* client = tera::Client::NewClient(FLAGS_flagfile, &err); |
| 390 | // for ut test |
| 391 | EXPECT_EQ(tera::ErrorCode::kOK, err.GetType()); |
| 392 | // for no core |
| 393 | if (tera::ErrorCode::kOK != err.GetType()) { |
| 394 | LOG(ERROR) << "new client failed"; |
| 395 | return; |
| 396 | } |
| 397 | |
| 398 | // create table |
| 399 | tera::TableDescriptor table_desc("observer_table_ntx"); |
| 400 | |
| 401 | table_desc.AddLocalityGroup("lg1"); |
| 402 | tera::ColumnFamilyDescriptor* cf1 = table_desc.AddColumnFamily("cf", "lg1"); |
| 403 | cf1->EnableNotify(); |
| 404 | ExtendNotifyLgToDescriptor(&table_desc); |
| 405 | |
| 406 | client->CreateTable(table_desc, &err); |
| 407 | if (err.GetType() != tera::ErrorCode::kOK) { |
| 408 | LOG(ERROR) << "Create table fail"; |
| 409 | return; |
| 410 | } |
| 411 | |
| 412 | std::unique_ptr<Table> table(client->OpenTable("observer_table_ntx", &err)); |
| 413 | EXPECT_EQ(tera::ErrorCode::kOK, err.GetType()); |
| 414 | if (tera::ErrorCode::kOK != err.GetType()) { |
| 415 | LOG(ERROR) << "open table failed"; |
| 416 | return; |
| 417 | } |
| 418 | |
| 419 | table->Put("www.baidu.com", "_N_", "cf:Page", "I am not important", &err); |
| 420 | if (err.GetType() != tera::ErrorCode::kOK) { |
| 421 | LOG(ERROR) << "put _N_ error"; |
| 422 | return; |
| 423 | } |
| 424 | table->Put("www.baidu.com", "cf", "Page", "hello world", -1, &err); |
| 425 | if (err.GetType() != tera::ErrorCode::kOK) { |
| 426 | LOG(ERROR) << "put cf error"; |
| 427 | return; |
| 428 | } |
| 429 | |
| 430 | Observer* observer = new TestWorkerNTX(); |
| 431 | |
| 432 | Scanner* scanner = new ScannerImpl(); |
| 433 | bool ret = scanner->Init(); |
| 434 | |
| 435 | EXPECT_EQ(true, ret); |
| 436 | if (!ret) { |
| 437 | LOG(ERROR) << "fail to init scanner_impl"; |
| 438 | return; |
| 439 | } |
| 440 | |
| 441 | err = scanner->Observe("observer_table_ntx", "cf", "Page", observer); |
| 442 | EXPECT_EQ(err.GetType(), tera::ErrorCode::kOK); |
| 443 | |
| 444 | if (!scanner->Start()) { |
nothing calls this directly
no test coverage detected