Merge PR #29124 into master

* refs/pull/29124/head:
	test/old/test*buffers.cc: remove tests against bufferlist
	test/old/test_*seek_read: remove this test
	test/old/test{crush,bucket}: remove stale tests
	test/old/testmpi.cc: remove this test
	test/old/testxattr.cc: remove this test
	test/old/testtree.cc: remove test for BinaryTree

Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2019-07-24 08:37:22 -05:00
commit 99d699a3d2
9 changed files with 0 additions and 678 deletions

View File

@ -1,63 +0,0 @@
#include "include/types.h"
#include "common/Clock.h"
#include <linux/fs.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
int main(int argc, char **argv)
{
char *fn = argv[1];
int fd = ::open(fn, O_RDWR|O_DIRECT);//|O_SYNC|O_DIRECT);
if (fd < 0) return 1;
uint64_t bytes = 0;
int r = ioctl(fd, BLKGETSIZE64, &bytes);
uint64_t numblocks = bytes / 4096;
//uint64_t numblocks = atoll(argv[2]) * 4;// / 4096;
int count = 1000;
cout << "fn " << fn << endl;
cout << "numblocks " << numblocks << endl;
int blocks = 1;
while (blocks <= 1024) {
//cout << "fd is " << fd << endl;
void *buf;
::posix_memalign(&buf, 4096, 4096*blocks);
int s = blocks*4096;
utime_t start = ceph_clock_now();
for (int i=0; i<count; i++) {
off64_t o = (lrand48() % numblocks) * 4096;
//cout << "s = " << s << " o = " << o << endl;
//::lseek(fd, o, SEEK_SET);
lseek64(fd, o, SEEK_SET);
int r = ::read(fd, buf, blocks*4096);
//int r = ::read(fd, buf, s);
if (r < 0) cout << "r = " << r << " " << strerror(errno) << endl;
}
utime_t end = ceph_clock_now();
double timeper = end - start;
timeper /= count;
cout << blocks << "\t" << s << "\t" << (double)timeper << endl;
blocks *= 2;
free(buf);
}
close(fd);
}

View File

@ -1,70 +0,0 @@
#include "include/types.h"
#include "common/Clock.h"
#include <linux/fs.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
int main(int argc, char **argv)
{
char *fn = argv[1];
int fd = ::open(fn, O_RDWR|O_DIRECT);//|O_SYNC|O_DIRECT);
if (fd < 0) return 1;
uint64_t bytes = 0;
int r = ioctl(fd, BLKGETSIZE64, &bytes);
uint64_t numblocks = bytes / 4096;
//uint64_t numblocks = atoll(argv[2]) * 4;// / 4096;
int count = 1000;
cout << "fn " << fn << endl;
cout << "numblocks " << numblocks << endl;
int blocks = 1;
while (blocks <= 1024) {
//cout << "fd is " << fd << endl;
void *buf;
::posix_memalign(&buf, 4096, 4096*blocks);
int s = blocks*4096;
double timeper = 0.0;
for (int i=0; i<count; i++) {
off64_t so, o = (lrand48() % numblocks) * 4096;
//cout << "s = " << s << " o = " << o << endl;
//::lseek(fd, o, SEEK_SET);
lseek64(fd, o, SEEK_SET);
int r = ::read(fd, buf, 4096);
//int r = ::read(fd, buf, s);
if (r < 0) cout << "r = " << r << " " << strerror(errno) << endl;
int range = 1000000/4096;
so = o + 4096*((rand() % range) );//- range/2);
//cout << o << " " << so << " " << (so-o) << endl;
utime_t start = ceph_clock_now();
lseek64(fd, so, SEEK_SET);
r = ::read(fd, buf, blocks*4096);
utime_t end = ceph_clock_now();
timeper += (end-start);
}
timeper /= count;
cout << blocks << "\t" << s << "\t" << (double)timeper << endl;
blocks *= 2;
free(buf);
}
close(fd);
}

View File

@ -1,67 +0,0 @@
#include "../crush/Bucket.h"
using namespace crush;
#include <iostream>
#include <vector>
using namespace std;
ostream& operator<<(ostream &out, const vector<int> &v)
{
out << "[";
for (int i=0; i<v.size(); i++) {
if (i) out << " ";
out << v[i];
}
out << "]";
return out;
}
int main()
{
Hash h(73);
vector<int> disks;
for (int i=0; i<20; i++)
disks.push_back(i);
/*
UniformBucket ub(1, 1, 0, 10, disks);
ub.make_primes(h);
cout << "primes are " << ub.primes << endl;
*/
MixedBucket mb(2, 1);
for (int i=0;i<20;i++)
mb.add_item(i, 10);
/*
MixedBucket b(3, 1);
b.add_item(1, ub.get_weight());
b.add_item(2, mb.get_weight());
*/
MixedBucket b= mb;
vector<int> ocount(disks.size());
int numrep = 3;
vector<int> v(numrep);
for (int x=1; x<1000000; x++) {
//cout << H(x) << "\t" << h(x) << endl;
for (int i=0; i<numrep; i++) {
int d = b.choose_r(x, i, h);
v[i] = d;
ocount[d]++;
}
//cout << v << "\t" << endl;//ocount << endl;
}
for (int i=0; i<ocount.size(); i++) {
cout << "disk " << i << " has " << ocount[i] << endl;
}
}

View File

@ -1,40 +0,0 @@
#include <iostream>
using namespace std;
#include "include/bufferlist.h"
int main()
{
bufferptr p1 = new buffer("123456",6);
bufferptr p2 = p1;
cout << "it is '" << p1.c_str() << "'" << endl;
bufferptr p3 = new buffer("abcdef",6);
cout << "p3 is " << p3 << endl;
bufferlist bl;
bl.push_back(p2);
bl.push_back(p1);
bl.push_back(p3);
cout << "bl is " << bl << endl;
cout << "len is " << bl.length() << endl;
bufferlist took;
bl.splice(10,4,&took);
cout << "took out " << took << "leftover is " << bl << endl;
//cout << "len is " << bl.length() << endl;
bufferlist bl2;
bl2.substr_of(bl, 3, 5);
cout << "bl2 is " << bl2 << endl;
}

View File

@ -1,219 +0,0 @@
#include "../crush/crush.h"
using namespace crush;
#include <math.h>
#include <iostream>
#include <vector>
using namespace std;
void make_disks(int n, int& no, vector<int>& d)
{
d.clear();
while (n) {
d.push_back(no);
no++;
n--;
}
}
Bucket *make_bucket(Crush& c, vector<int>& wid, int h, int& ndisks, int& nbuckets)
{
if (h == 0) {
// uniform
Hash hash(123);
vector<int> disks;
for (int i=0; i<wid[h]; i++)
disks.push_back(ndisks++);
UniformBucket *b = new UniformBucket(nbuckets--, 1, 0, 10, disks);
b->make_primes(hash);
c.add_bucket(b);
return b;
} else {
// mixed
MixedBucket *b = new MixedBucket(nbuckets--, h+1);
for (int i=0; i<wid[h]; i++) {
Bucket *n = make_bucket(c, wid, h-1, ndisks, nbuckets);
b->add_item(n->get_id(), n->get_weight());
}
c.add_bucket(b);
return b;
}
}
int make_hierarchy(Crush& c, vector<int>& wid, int& ndisks, int& nbuckets)
{
Bucket *b = make_bucket(c, wid, wid.size()-1, ndisks, nbuckets);
return b->get_id();
}
int main()
{
Hash h(73232313);
// crush
Crush c;
// buckets
vector<int> disks;
int root = -1;
int nbuckets = -1;
int ndisks = 0;
if (0) {
make_disks(12, ndisks, disks);
UniformBucket ub1(-1, 1, 0, 30, disks);
ub1.make_primes(h);
cout << "ub1 primes are " << ub1.primes << endl;
c.add_bucket(&ub1);
make_disks(17, ndisks, disks);
UniformBucket ub2(-2, 1, 0, 30, disks);
ub2.make_primes(h);
cout << "ub2 primes are " << ub2.primes << endl;
c.add_bucket(&ub2);
make_disks(4, ndisks, disks);
UniformBucket ub3(-3, 1, 0, 30, disks);
ub3.make_primes(h);
cout << "ub3 primes are " << ub3.primes << endl;
c.add_bucket(&ub3);
make_disks(20, ndisks, disks);
MixedBucket umb1(-4, 1);
for (int i=0; i<20; i++)
umb1.add_item(disks[i], 30);
c.add_bucket(&umb1);
MixedBucket b(-100, 1);
b.add_item(-4, umb1.get_weight());
}
if (0) {
int bucket = -1;
MixedBucket *root = new MixedBucket(bucket--, 2);
for (int i=0; i<5; i++) {
MixedBucket *b = new MixedBucket(bucket--, 1);
int n = 5;
if (1) {
// add n buckets of n disks
for (int j=0; j<n; j++) {
MixedBucket *d = new MixedBucket(bucket--, 1);
make_disks(n, ndisks, disks);
for (int k=0; k<n; k++)
d->add_item(disks[k], 10);
c.add_bucket(d);
b->add_item(d->get_id(), d->get_weight());
}
c.add_bucket(b);
root->add_item(b->get_id(), b->get_weight());
} else {
// add n*n disks
make_disks(n*n, ndisks, disks);
for (int k=0; k<n*n; k++)
b->add_item(disks[k], 10);
c.add_bucket(b);
root->add_item(b->get_id(), b->get_weight());
}
}
c.add_bucket(root);
}
if (1) {
vector<int> wid;
for (int d=0; d<5; d++)
wid.push_back(10);
root = make_hierarchy(c, wid, ndisks, nbuckets);
}
// rule
int numrep = 1;
Rule rule;
if (0) {
rule.steps.push_back(RuleStep(CRUSH_RULE_TAKE, -100));
rule.steps.push_back(RuleStep(CRUSH_RULE_CHOOSE, numrep, 0));
}
if (1) {
rule.steps.push_back(RuleStep(CRUSH_RULE_TAKE, root));
rule.steps.push_back(RuleStep(CRUSH_RULE_CHOOSE, 1, 0));
rule.steps.push_back(RuleStep(CRUSH_RULE_EMIT));
}
int pg_per = 100;
int numpg = pg_per*ndisks/numrep;
vector<int> ocount(ndisks);
cout << ndisks << " disks, " << 1-nbuckets << " buckets" << endl;
cout << pg_per << " pgs per disk" << endl;
cout << numpg << " logical pgs" << endl;
cout << "numrep is " << numrep << endl;
int place = 1000000;
int times = place / numpg;
if (!times) times = 1;
cout << "looping " << times << " times" << endl;
float tvar = 0;
int tvarnum = 0;
int x = 0;
for (int t=0; t<times; t++) {
vector<int> v(numrep);
for (int z=0; z<ndisks; z++) ocount[z] = 0;
for (int xx=1; xx<numpg; xx++) {
x++;
c.do_rule(rule, x, v);
bool bad = false;
for (int i=0; i<numrep; i++) {
ocount[v[i]]++;
for (int j=i+1; j<numrep; j++) {
if (v[i] == v[j])
bad = true;
}
}
if (bad)
cout << "bad set " << x << ": " << v << endl;
}
cout << "collisions: " << c.collisions << endl;
cout << "r bumps: " << c.bumps << endl;
float avg = 0.0;
for (int i=0; i<ocount.size(); i++)
avg += ocount[i];
avg /= ocount.size();
float var = 0.0;
for (int i=0; i<ocount.size(); i++)
var += (ocount[i] - avg) * (ocount[i] - avg);
var /= ocount.size();
cout << "avg " << avg << " var " << var << " sd " << sqrt(var) << endl;
tvar += var;
tvarnum++;
}
tvar /= tvarnum;
cout << "total variance " << tvar << endl;
}

View File

@ -1,53 +0,0 @@
#include <sys/stat.h>
#include <iostream>
#include <string>
using namespace std;
#include "common/config.h"
#include "messages/MPing.h"
#include "common/Mutex.h"
#include "msg/MPIMessenger.h"
class Pinger : public Dispatcher {
public:
Messenger *messenger;
explicit Pinger(Messenger *m) : messenger(m) {
m->set_dispatcher(this);
}
void dispatch(Message *m) {
//dout(1) << "got incoming " << m << endl;
delete m;
}
};
int main(int argc, char **argv) {
int num = 1000;
int myrank = mpimessenger_init(argc, argv);
int world = mpimessenger_world();
Pinger *p = new Pinger( new MPIMessenger(myrank) );
mpimessenger_start();
//while (1) {
for (int i=0; i<10000; i++) {
// ping random nodes
int d = rand() % world;
if (d != myrank) {
//cout << "sending " << i << " to " << d << endl;
p->messenger->send_message(new MPing(), d);
}
}
//cout << "shutting down" << endl;
//p->messenger->shutdown();
mpimessenger_wait();
mpimessenger_shutdown(); // shutdown MPI
}

View File

@ -1,91 +0,0 @@
#include <list>
#include <iostream>
using namespace std;
#include "include/newbuffer.h"
//#include "include/bufferlist.h"
#include "common/Thread.h"
class Th : public Thread {
public:
bufferlist bl;
explicit Th(bufferlist& o) : bl(o) { }
void *entry() {
//cout << "start" << endl;
// thrash it a bit.
for (int n=0; n<10000; n++) {
bufferlist bl2;
unsigned off = rand() % (bl.length() -1);
unsigned len = 1 + rand() % (bl.length() - off - 1);
bl2.substr_of(bl, off, len);
bufferlist bl3;
bl3.append(bl);
bl3.append(bl2);
//cout << bl3 << endl;
bl2.clear();
bl3.clear();
}
//cout << "end" << endl;
}
};
int main()
{
bufferptr p1 = buffer::copy("123456",7);
//bufferptr p1 = new buffer("123456",7);
bufferptr p2 = p1;
cout << "p1 is '" << p1.c_str() << "'" << " " << p1 << endl;
cout << "p2 is '" << p2.c_str() << "'" << " " << p2 << endl;
bufferptr p3 = buffer::copy("abcdef",7);
//bufferptr p3 = new buffer("abcdef",7);
cout << "p3 is " << p3.c_str() << " " << p3 << endl;
bufferlist bl;
bl.push_back(p2);
bl.push_back(p1);
bl.push_back(p3);
cout << "bl is " << bl << endl;
bufferlist took;
bl.splice(10,4,&took);
cout << "took out " << took << ", leftover is " << bl << endl;
//cout << "len is " << bl.length() << endl;
bufferlist bl2;
bl2.substr_of(bl, 3, 5);
cout << "bl2 is " << bl2 << endl;
cout << "bl before " << bl << endl;
list<Th*> ls;
for (int t=0; t<40; t++) {
Th *t = new Th(bl);
cout << "create" << endl;
t->create();
ls.push_back(t);
}
bl.clear();
while (!ls.empty()) {
cout << "join" << endl;
ls.front()->join();
delete ls.front();
ls.pop_front();
}
cout << "bl after " << bl << endl;
}

View File

@ -1,46 +0,0 @@
#include "../crush/BinaryTree.h"
using namespace crush;
#include <iostream>
#include <vector>
using namespace std;
int main()
{
BinaryTree t;
vector<int> nodes;
for (int i=0; i<30; i++) {
cout << "adding " << i << endl;
int n = t.add_node(1);
nodes.push_back(n);
//cout << t << endl;
}
cout << t << endl;
for (int k=0; k<10000; k++) {
if (rand() % 2) {
cout << "adding" << endl;
nodes.push_back( t.add_node(1) );
} else {
if (!nodes.empty()) {
//for (int i=0; i<nodes.size(); i++) {
int p = rand() % nodes.size();
int n = nodes[p];
assert (t.exists(n));
cout << "removing " << n << endl;
t.remove_node(n);
for (int j=p; j<nodes.size(); j++)
nodes[j] = nodes[j+1];
nodes.pop_back();
}
}
cout << t << endl;
}
}

View File

@ -1,29 +0,0 @@
#include <iostream>
using namespace std;
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/file.h>
#include <errno.h>
#include <dirent.h>
#include <sys/xattr.h>
int main(int argc, char**argv)
{
int a = 1;
int b = 2;
mknod("test", 0600, 0);
cout << "setxattr " << setxattr("test", "asdf", &a, sizeof(a), 0) << endl;
cout << "errno " << errno << " " << strerror(errno) << endl;
cout << "getxattr " << getxattr("test", "asdf", &b, sizeof(b)) << endl;
cout << "errno " << errno << " " << strerror(errno) << endl;
cout << "a is " << a << " and b is " << b << endl;
return 0;
}