| 780 | } |
| 781 | |
| 782 | void |
| 783 | hstest_thread::test_10(int test_num) |
| 784 | { |
| 785 | const int keep_connection = arg.sh.conf.get_int("keep_connection", 1); |
| 786 | unsigned int seed = time(0) + arg.id + 1; |
| 787 | seed ^= arg.sh.conf.get_int("seed_xor", 0); |
| 788 | drand48_data randbuf; |
| 789 | srand48_r(seed, &randbuf); |
| 790 | std::string err; |
| 791 | int keepconn_count = 0; |
| 792 | const char op = arg.sh.op; |
| 793 | const int verbose = arg.sh.conf.get_int("verbose", 1); |
| 794 | const std::string suffix = arg.sh.conf.get_str("value_suffix", "upd"); |
| 795 | const int tablesize = arg.sh.conf.get_int("tablesize", 10000); |
| 796 | const int firstkey = arg.sh.conf.get_int("firstkey", 0); |
| 797 | const int sched_flag = arg.sh.conf.get_int("sched", 0); |
| 798 | const int moreflds = arg.sh.conf.get_int("moreflds", 0); |
| 799 | const std::string dbname = arg.sh.conf.get_str("dbname", "hstest"); |
| 800 | const std::string table = arg.sh.conf.get_str("table", "hstest_table1"); |
| 801 | const std::string index = arg.sh.conf.get_str("index", "PRIMARY"); |
| 802 | const std::string field = arg.sh.conf.get_str("field", "v"); |
| 803 | const int use_in = arg.sh.conf.get_int("in", 0); |
| 804 | const std::string moreflds_prefix = arg.sh.conf.get_str( |
| 805 | "moreflds_prefix", "column0123456789_"); |
| 806 | const int dump = arg.sh.dump; |
| 807 | const int nodup = arg.sh.conf.get_int("nodup", 0); |
| 808 | std::string moreflds_str; |
| 809 | for (int i = 0; i < moreflds; ++i) { |
| 810 | char sbuf[1024]; |
| 811 | snprintf(sbuf, sizeof(sbuf), ",%s%d", moreflds_prefix.c_str(), i); |
| 812 | moreflds_str += std::string(sbuf); |
| 813 | } |
| 814 | string_buffer wbuf; |
| 815 | char rbuf[16384]; |
| 816 | for (size_t i = 0; i < arg.sh.loop; ++i) { |
| 817 | int len = 0, rlen = 0, wlen = 0; |
| 818 | #if 0 |
| 819 | const double tm1 = gettimeofday_double(); |
| 820 | #endif |
| 821 | if (fd.get() < 0) { |
| 822 | if (socket_connect(fd, arg.sh.arg, err) != 0) { |
| 823 | fprintf(stderr, "connect: %d %s\n", errno, strerror(errno)); |
| 824 | return; |
| 825 | } |
| 826 | char *wp = wbuf.make_space(1024); |
| 827 | len = snprintf(wp, 1024, |
| 828 | "P\t1\t%s\t%s\tPRIMARY\t%s%s\n", dbname.c_str(), table.c_str(), |
| 829 | field.c_str(), moreflds_str.c_str()); |
| 830 | /* pst_num, db, table, index, retflds */ |
| 831 | wbuf.space_wrote(len); |
| 832 | wlen = write(fd.get(), wbuf.begin(), len); |
| 833 | if (len != wlen) { |
| 834 | fprintf(stderr, "write: %d %d\n", len, wlen); |
| 835 | return; |
| 836 | } |
| 837 | wbuf.clear(); |
| 838 | rlen = read(fd.get(), rbuf, sizeof(rbuf)); |
| 839 | if (rlen <= 0 || rbuf[rlen - 1] != '\n') { |
nothing calls this directly
no test coverage detected