~celebdor/charms/trusty/cassandra/trunk

« back to all changes in this revision

Viewing changes to tests/test_integration.py

  • Committer: Stuart Bishop
  • Date: 2015-04-27 14:47:52 UTC
  • Revision ID: stuart.bishop@canonical.com-20150427144752-zhihtaqhbr1sjhz3
It might take time for data to settle post node decommission

Show diffs side-by-side

added added

removed removed

Lines of Context:
362
362
            s.execute(q, (str(uuid.uuid1()),))
363
363
        cluster.shutdown()
364
364
 
365
 
        def count():
 
365
        def count(expected):
366
366
            until = time.time() + 180
367
367
            while True:
368
368
                cluster = self.cluster()
371
371
                    results = s.execute(SimpleStatement(
372
372
                        'SELECT count(*) FROM dat',
373
373
                        consistency_level=ConsistencyLevel.QUORUM))
374
 
                    return results[0][0]
 
374
                    found = results[0][0]
 
375
                    if found == expected or time.time() > until:
 
376
                        return found
 
377
                    time.sleep(0.2)
375
378
                except Unavailable:
376
379
                    if time.time() > until:
377
380
                        raise
378
381
                finally:
379
382
                    cluster.shutdown()
380
383
 
381
 
        self.assertEqual(count(), total)
 
384
        self.assertEqual(count(total), total)
382
385
 
383
386
        self.deployment.add_unit('cassandra')
384
387
        self.deployment.wait()
385
388
        status = self.juju_status()
386
389
        unit = sorted(status['services']['cassandra']['units'].keys())[-1]
387
390
        try:
388
 
            self.assertEqual(count(), total)
 
391
            self.assertEqual(count(total), total)
389
392
        finally:
390
393
            # When a node is dropped, it needs to decommission itself and
391
394
            # move its data to the remaining nodes so no data is lost.
396
399
            self.deployment.remove_unit(unit)
397
400
            self.deployment.wait()
398
401
 
399
 
        self.assertEqual(count(), total)
 
402
        self.assertEqual(count(total), total)
400
403
 
401
404
    def _decommission(self, unit):
402
405
        until = time.time() + WAIT_TIMEOUT