Example #1
0
    def test_visibility_metric(self):
        """
        Test that the visibility metric is tracked
        """
        v1 = Version(self.replica)

        calls = []
        replicas = [r for r in self.sim.replicas if r != self.replica]

        for idx, replica in enumerate(replicas):

            self.sim.env.now += (2 * (idx + 1))
            v1.update(replica)

            self.assertGreater(v1.updated, v1.created)
            self.assertEqual(v1.updated, self.sim.env.now)

            pcent = float(idx + 2) / float(len(self.sim.replicas))
            calls.append(
                mock.call('visibility', (self.replica.id, str(v1), pcent,
                                         v1.created, self.sim.env.now)))

        # Check that this is the last call
        self.sim.results.update.assert_has_calls(calls + [
            mock.call('visibility latency',
                      (self.replica.id, str(v1), v1.created, v1.updated))
        ],
                                                 any_order=True)

        self.assertTrue(v1.is_visible())
Example #2
0
    def test_visibility_metric(self):
        """
        Test that the visibility metric is tracked
        """
        v1 = Version(self.replica)

        calls = []
        replicas = [
            r for r in self.sim.replicas if r!= self.replica
        ]

        for idx, replica in enumerate(replicas):

            self.sim.env.now += (2*(idx+1))
            v1.update(replica)

            self.assertGreater(v1.updated, v1.created)
            self.assertEqual(v1.updated, self.sim.env.now)

            pcent = float(idx+2) / float(len(self.sim.replicas))
            calls.append(
                mock.call('visibility', (self.replica.id, str(v1), pcent, v1.created, self.sim.env.now))
            )

        # Check that this is the last call
        self.sim.results.update.assert_has_calls(calls + [
            mock.call('visibility latency', (self.replica.id, str(v1), v1.created, v1.updated))
        ], any_order=True)

        self.assertTrue(v1.is_visible())
Example #3
0
    def test_update(self):
        """
        Test the update of a version over time.
        """
        v1 = Version(self.replica)

        for idx, replica in enumerate(self.sim.replicas):
            if replica == self.replica: continue

            self.sim.env.now += (2 * (idx + 1))
            v1.update(replica)
            self.assertGreater(v1.updated, v1.created)
            self.assertEqual(v1.updated, self.sim.env.now)

        # Check that this is the last call
        self.sim.results.update.assert_called_with(
            'visibility latency',
            (self.replica.id, str(v1), v1.created, v1.updated))

        self.assertTrue(v1.is_visible())
Example #4
0
    def test_update(self):
        """
        Test the update of a version over time.
        """
        v1 = Version(self.replica)

        for idx, replica in enumerate(self.sim.replicas):
            if replica == self.replica: continue

            self.sim.env.now += (2*(idx+1))
            v1.update(replica)
            self.assertGreater(v1.updated, v1.created)
            self.assertEqual(v1.updated, self.sim.env.now)

        # Check that this is the last call
        self.sim.results.update.assert_called_with(
            'visibility latency', (self.replica.id, str(v1), v1.created, v1.updated)
        )

        self.assertTrue(v1.is_visible())
Example #5
0
    def test_commit(self):
        """
        Test the commit of a version over time.
        """
        v1 = Version(self.replica)

        for idx, replica in enumerate(self.sim.replicas):
            if replica == self.replica: continue
            self.sim.env.now += (2 * (idx + 1))
            v1.update(replica)

        self.sim.results.update.assert_called_with(
            'visibility latency',
            (self.replica.id, str(v1), v1.created, v1.updated))

        self.assertTrue(v1.is_visible())

        v1.update(self.replica, commit=True)
        self.assertTrue(v1.committed)
        self.assertTrue(v1.is_committed())

        self.sim.results.update.assert_called_with(
            'commit latency',
            (self.replica.id, str(v1), v1.created, v1.updated))
Example #6
0
    def test_commit(self):
        """
        Test the commit of a version over time.
        """
        v1 = Version(self.replica)

        for idx, replica in enumerate(self.sim.replicas):
            if replica == self.replica: continue
            self.sim.env.now += (2*(idx+1))
            v1.update(replica)

        self.sim.results.update.assert_called_with(
            'visibility latency', (self.replica.id, str(v1), v1.created, v1.updated)
        )

        self.assertTrue(v1.is_visible())

        v1.update(self.replica, commit=True)
        self.assertTrue(v1.committed)
        self.assertTrue(v1.is_committed())

        self.sim.results.update.assert_called_with(
            'commit latency', (self.replica.id, str(v1), v1.created, v1.updated)
        )