Ejemplo n.º 1
0
class ScopeUtility(ConsoleProgram):

    description = color.format(DESCRIPTION, color.CYAN)
    epilog = color.format(EPILOG, color.MAGENTA)
    version = color.format("scope.py v{}", color.CYAN, get_version())

    @classmethod
    def load(klass, commands=COMMANDS):
        utility = klass()
        for command in commands:
            utility.register(command)
        return utility
Ejemplo n.º 2
0
    def assertReliableResults(self, results, metrics=None):
        """
        Performs generic checking for the results object.
        """
        metrics = metrics or set([])

        topkeys = [
            u'settings', u'results', u'randseed', u'simulation', u'version',
            u'timer', u'timesteps', u'topology'
        ]

        for key in topkeys:
            self.assertIn(key, results)

        self.assertEqual(results['version'], get_version())
        # self.assertEqual(results['timesteps'], 100000) # TODO: fix this to make it work!
        self.assertEqual(len(results['topology'].get('nodes', [])), 3)
        self.assertEqual(len(results['topology'].get('links', [])), 3)
        self.assertIn('meta', results['topology'])

        # Required Metrics
        required = {
            u'read',
            u'read latency',
            'visibility',
            u'write',
            u'write latency',
            u'visibility latency',
        } | metrics

        # Optional Metrics
        optional = {
            u'sent',
            u'recv',
            u'dropped',
            u'commit latency',
            u'stale reads',
            u'empty reads',
            u'missed reads',
            u'dropped writes',
            'forked writes',
            'stale writes',
        }

        for metric in required:
            self.assertIn(metric, results['results'],
                          "Missing '{}' metric from results".format(metric))
            self.assertGreater(len(results['results'][metric]), 0)

        for metric in results['results'].keys():
            self.assertIn(metric, required | optional,
                          "Unknown metric named '{}'".format(metric))
Ejemplo n.º 3
0
    def test_results_base(self):
        """
        Test the basic properties of a result object
        """

        result = Results(simulation="Test Simulation")
        output = StringIO()
        result.dump(output)

        output.seek(0)
        output = json.load(output)

        self.assertKVEqual('simulation', "Test Simulation", output)
        self.assertKVEqual('version', get_version(), output)
        self.assertIn('randseed', output)
        self.assertIn('timesteps', output)
        self.assertIn('results', output)
        self.assertIn('timer', output)
        self.assertIn('settings', output)
Ejemplo n.º 4
0
    def assertReliableResults(self, results, metrics=None):
        """
        Performs generic checking for the results object.
        """
        metrics = metrics or set([])

        topkeys = [u"settings", u"results", u"randseed", u"simulation", u"version", u"timer", u"timesteps", u"topology"]

        for key in topkeys:
            self.assertIn(key, results)

        self.assertEqual(results["version"], get_version())
        # self.assertEqual(results['timesteps'], 100000) # TODO: fix this to make it work!
        self.assertEqual(len(results["topology"].get("nodes", [])), 3)
        self.assertEqual(len(results["topology"].get("links", [])), 3)
        self.assertIn("meta", results["topology"])

        # Required Metrics
        required = {u"read", u"read latency", "visibility", u"write", u"write latency", u"visibility latency"} | metrics

        # Optional Metrics
        optional = {
            u"sent",
            u"recv",
            u"dropped",
            u"commit latency",
            u"stale reads",
            u"empty reads",
            u"missed reads",
            u"dropped writes",
            "forked writes",
            "stale writes",
        }

        for metric in required:
            self.assertIn(metric, results["results"], "Missing '{}' metric from results".format(metric))
            self.assertGreater(len(results["results"][metric]), 0)

        for metric in results["results"].keys():
            self.assertIn(metric, required | optional, "Unknown metric named '{}'".format(metric))