libec_missing_entry_point_la_LDFLAGS = ${AM_LDFLAGS} -export-symbols-regex '.*__erasure_code_.*'
erasure_codelib_LTLIBRARIES += libec_missing_entry_point.la
+libec_hangs_la_SOURCES = test/osd/ErasureCodePluginHangs.cc
+libec_hangs_la_CFLAGS = ${AM_CFLAGS}
+libec_hangs_la_CXXFLAGS= ${AM_CXXFLAGS}
+libec_hangs_la_LIBADD = $(PTHREAD_LIBS) $(EXTRALIBS)
+libec_hangs_la_LDFLAGS = ${AM_LDFLAGS} -export-symbols-regex '.*__erasure_code_.*'
+erasure_codelib_LTLIBRARIES += libec_hangs.la
+
libec_fail_to_initialize_la_SOURCES = test/osd/ErasureCodePluginFailToInitialize.cc
libec_fail_to_initialize_la_CFLAGS = ${AM_CFLAGS}
libec_fail_to_initialize_la_CXXFLAGS= ${AM_CXXFLAGS}
class ErasureCodeExample : public ErasureCodeInterface {
public:
- useconds_t delay;
- ErasureCodeExample(const map<std::string,std::string> ¶meters) :
- delay(0)
- {
- if (parameters.find("usleep") != parameters.end()) {
- std::istringstream ss(parameters.find("usleep")->second);
- ss >> delay;
- usleep(delay);
- }
- }
-
virtual ~ErasureCodeExample() {}
virtual int minimum_to_decode(const set<int> &want_to_read,
*
*/
+#include <unistd.h>
+
#include "osd/ErasureCodePlugin.h"
#include "ErasureCodeExample.h"
virtual int factory(const map<std::string,std::string> ¶meters,
ErasureCodeInterfaceRef *erasure_code)
{
- *erasure_code = ErasureCodeInterfaceRef(new ErasureCodeExample(parameters));
+ *erasure_code = ErasureCodeInterfaceRef(new ErasureCodeExample());
return 0;
}
};
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2013 Cloudwatt <libre.licensing@cloudwatt.com>
+ *
+ * Author: Loic Dachary <loic@dachary.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ */
+
+#include <unistd.h>
+#include "osd/ErasureCodePlugin.h"
+
+int __erasure_code_init(char *plugin_name)
+{
+ sleep(1000);
+ return 0;
+}
#include "global/global_context.h"
#include "gtest/gtest.h"
-TEST(ErasureCodeExample, constructor)
-{
- map<std::string,std::string> parameters;
- {
- ErasureCodeExample example(parameters);
- EXPECT_EQ(0u, example.delay);
- }
- parameters["usleep"] = "10";
- {
- ErasureCodeExample example(parameters);
- EXPECT_EQ(10u, example.delay);
- }
-}
-
TEST(ErasureCodeExample, minimum_to_decode)
{
- map<std::string,std::string> parameters;
- ErasureCodeExample example(parameters);
+ ErasureCodeExample example;
set<int> available_chunks;
set<int> want_to_read;
want_to_read.insert(1);
TEST(ErasureCodeExample, minimum_to_decode_with_cost)
{
- map<std::string,std::string> parameters;
- ErasureCodeExample example(parameters);
+ ErasureCodeExample example;
map<int,int> available;
set<int> want_to_read;
want_to_read.insert(1);
TEST(ErasureCodeExample, encode_decode)
{
- map<std::string,std::string> parameters;
- ErasureCodeExample example(parameters);
+ ErasureCodeExample example;
bufferlist in;
in.append("ABCDE");
class Thread_factory : public Thread {
public:
- useconds_t delay;
-
- Thread_factory(useconds_t _delay) :
- delay(_delay)
- {}
-
virtual void *entry() {
map<std::string,std::string> parameters;
parameters["erasure-code-directory"] = ".libs";
- parameters["usleep"] = delay;
ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
ErasureCodeInterfaceRef erasure_code;
- instance.factory("example", parameters, &erasure_code);
+ instance.factory("hangs", parameters, &erasure_code);
return NULL;
}
};
//
useconds_t delay = 0;
const useconds_t DELAY_MAX = 20 * 1000 * 1000;
- Thread_factory sleep_forever(1024 * 1024 * 1024);
+ Thread_factory sleep_forever;
sleep_forever.create();
do {
cout << "Trying (1) with delay " << delay << "us\n";
EXPECT_FALSE(instance.lock.TryLock());
- EXPECT_EQ(0, sleep_forever.detach());
+ EXPECT_EQ(0, pthread_cancel(sleep_forever.get_thread_id()));
+ EXPECT_EQ(0, sleep_forever.join());
}
TEST_F(ErasureCodePluginRegistryTest, all)