Commit e6f2a84c authored by Noah Orensa's avatar Noah Orensa
Browse files

use worker id 0 for driver

parent e2281517
......@@ -227,9 +227,7 @@ public:
return _currentCtx;
}
virtual uint32_t workerId() const {
return -1;
}
virtual uint32_t workerId() const = 0;
};
class DriverContext : public Context {
......@@ -358,6 +356,10 @@ public:
void wait(uint32_t n = -1u) override;
uint32_t workerId() const {
return 0;
}
static Lazy<DriverContext> instance;
};
......@@ -393,11 +395,11 @@ public:
void wait(uint32_t n = -1u) override;
static Lazy<WorkerContext> instance;
uint32_t workerId() const override {
return _id;
}
static Lazy<WorkerContext> instance;
};
class AssertionException : public SandboxException {
......
......@@ -44,13 +44,13 @@ DRIVER=$!
id=0
WORKERS=()
for m in $(cat $DIR/workers) ; do
let id=id+1
ssh -A $CLUSTER_USER@$m "sh -c '\
cd $DTEST_HOME ; \
$ENV \
nohup $EXEC --driver $(hostname):$PORT --worker-id $id tmp > /dev/null 2>&1 & \
echo \$! > tmp/pid \
'" &
let id=id+1
done
wait $DRIVER
......
......@@ -390,7 +390,7 @@ void DriverContext::WorkerHandle::terminate() {
// DriverContext ///////////////////////////////////////////////////////////////
DriverContext::WorkerHandle DriverContext::_spawnWorker() {
uint32_t id = _workers.size();
uint32_t id = _workers.size() + 1;
pid_t pid = fork();
if (pid == 0) {
......
......@@ -93,11 +93,13 @@ dunit("unit-test", "worker-id")
dtest_recv_msg(id);
std::cout << id << '\n';
}
assert(dtest_worker_id() == 0);
})
.worker([] {
uint32_t id = dtest_worker_id();
assert(id < 4);
dtest_send_msg(id);
assert(id <= 4);
});
dunit("distributed-unit-test", "wait-notify")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment