from perfrunner.helpers.cbmonitor import with_stats
from perfrunner.helpers.local import clone_ycsb
from perfrunner.helpers.worker import ycsb_data_load_task, ycsb_task
from perfrunner.tests import PerfTest
from perfrunner.tests.n1ql import N1QLTest


class YCSBTest(PerfTest):

    def download_ycsb(self):
        clone_ycsb(repo=self.test_config.ycsb_settings.repo,
                   branch=self.test_config.ycsb_settings.branch)

    def load(self, *args, **kwargs):
        PerfTest.load(self, task=ycsb_data_load_task)
        self.check_num_items()

    @with_stats
    def access(self, *args, **kwargs):
        PerfTest.access(self, task=ycsb_task)

    def _report_kpi(self):
        self.reporter.post_to_sf(
            self.metric_helper.parse_ycsb_throughput()
        )

    def run(self):
        self.download_ycsb()

        self.load()
        self.wait_for_persistence()

        self.access()

        self.report_kpi()


class YCSBN1QLTest(YCSBTest, N1QLTest):

    def run(self):
        self.download_ycsb()

        self.load()
        self.wait_for_persistence()

        self.build_index()

        self.access()

        self.report_kpi()

from perfrunner.helpers.cbmonitor import with_stats
from perfrunner.helpers.local import clone_ycsb
from perfrunner.helpers.worker import ycsb_data_load_task, ycsb_task
from perfrunner.tests import PerfTest
from perfrunner.tests.n1ql import N1QLTest


class YCSBTest(PerfTest):

    def download_ycsb(self):
        clone_ycsb(repo=self.test_config.ycsb_settings.repo,
                   branch=self.test_config.ycsb_settings.branch)

    def load(self, *args, **kwargs):
        PerfTest.load(self, task=ycsb_data_load_task)

    @with_stats
    def access(self, *args, **kwargs):
        PerfTest.access(self, task=ycsb_task)

    def _report_kpi(self):
        self.reporter.post_to_sf(
            self.metric_helper.parse_ycsb_throughput()
        )

    def run(self):
        self.download_ycsb()

        self.load()
        self.wait_for_persistence()
        self.check_num_items()

        self.access()

        self.report_kpi()


class YCSBN1QLTest(YCSBTest, N1QLTest):

    def run(self):
        self.download_ycsb()

        self.load()
        self.wait_for_persistence()
        self.check_num_items()

        self.build_index()

        self.access()

        self.report_kpi()

Check the number of items a little bit later
Check the number of items a little bit later

Due to MB-22749

Change-Id: Icffe46201223efa5645644ca40b99dffe4f0fb31
Reviewed-on: http://review.couchbase.org/76413
Tested-by: Build Bot <80754af91bfb6d1073585b046fe0a474ce868509@couchbase.com>
Reviewed-by: Pavel Paulau <dd88eded64e90046a680e3a6c0828ceb8fe8a0e7@gmail.com>
