~ubuntu-branches/ubuntu/trusty/ceph/trusty

« back to all changes in this revision

Viewing changes to src/test/librados/watch_notify.cc

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-04-09 11:14:03 UTC
  • mfrom: (49.1.6 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20140409111403-ejsqcnimtg4or7rl
Tags: 0.79-0ubuntu1
* New upstream release (LP: #1278466):
  - d/p/modules.patch: Refreshed.
  - d/ceph.install: Install all jerasure modules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 
13
13
typedef RadosTest LibRadosWatchNotify;
14
14
typedef RadosTestPP LibRadosWatchNotifyPP;
 
15
typedef RadosTestEC LibRadosWatchNotifyEC;
 
16
typedef RadosTestECPP LibRadosWatchNotifyECPP;
15
17
 
16
18
static sem_t sem;
17
19
 
80
82
  ASSERT_EQ(0, ioctx.watch("foo", 0, &handle, &ctx));
81
83
  sem_destroy(&sem);
82
84
}
 
85
 
 
86
TEST_F(LibRadosWatchNotifyEC, WatchNotifyTest) {
 
87
  ASSERT_EQ(0, sem_init(&sem, 0, 0));
 
88
  char buf[128];
 
89
  memset(buf, 0xcc, sizeof(buf));
 
90
  ASSERT_EQ((int)sizeof(buf), rados_write(ioctx, "foo", buf, sizeof(buf), 0));
 
91
  uint64_t handle;
 
92
  ASSERT_EQ(0,
 
93
      rados_watch(ioctx, "foo", 0, &handle, watch_notify_test_cb, NULL));
 
94
  ASSERT_EQ(0, rados_notify(ioctx, "foo", 0, NULL, 0));
 
95
  TestAlarm alarm;
 
96
  sem_wait(&sem);
 
97
  rados_unwatch(ioctx, "foo", handle);
 
98
  sem_destroy(&sem);
 
99
}
 
100
 
 
101
TEST_F(LibRadosWatchNotifyECPP, WatchNotifyTestPP) {
 
102
  ASSERT_EQ(0, sem_init(&sem, 0, 0));
 
103
  char buf[128];
 
104
  memset(buf, 0xcc, sizeof(buf));
 
105
  bufferlist bl1;
 
106
  bl1.append(buf, sizeof(buf));
 
107
  ASSERT_EQ((int)sizeof(buf), ioctx.write("foo", bl1, sizeof(buf), 0));
 
108
  uint64_t handle;
 
109
  WatchNotifyTestCtx ctx;
 
110
  ASSERT_EQ(0, ioctx.watch("foo", 0, &handle, &ctx));
 
111
  std::list<obj_watch_t> watches;
 
112
  ASSERT_EQ(0, ioctx.list_watchers("foo", &watches));
 
113
  ASSERT_EQ(watches.size(), 1u);
 
114
  bufferlist bl2;
 
115
  ASSERT_EQ(0, ioctx.notify("foo", 0, bl2));
 
116
  TestAlarm alarm;
 
117
  sem_wait(&sem);
 
118
  ioctx.unwatch("foo", handle);
 
119
  sem_destroy(&sem);
 
120
}
 
121
 
 
122
TEST_F(LibRadosWatchNotifyECPP, WatchNotifyTimeoutTestPP) {
 
123
  ASSERT_EQ(0, sem_init(&sem, 0, 0));
 
124
  ioctx.set_notify_timeout(1);
 
125
  uint64_t handle;
 
126
  WatchNotifyTestCtx ctx;
 
127
 
 
128
  char buf[128];
 
129
  memset(buf, 0xcc, sizeof(buf));
 
130
  bufferlist bl1;
 
131
  bl1.append(buf, sizeof(buf));
 
132
  ASSERT_EQ((int)sizeof(buf), ioctx.write("foo", bl1, sizeof(buf), 0));
 
133
 
 
134
  ASSERT_EQ(0, ioctx.watch("foo", 0, &handle, &ctx));
 
135
  sem_destroy(&sem);
 
136
}