~ubuntu-branches/ubuntu/utopic/maas/utopic-security

« back to all changes in this revision

Viewing changes to src/provisioningserver/utils/tests/test_twisted.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez, Jeroen Vermeulen, Andres Rodriguez, Jason Hobbs, Raphaël Badin, Louis Bouchard, Gavin Panella
  • Date: 2014-08-21 19:36:30 UTC
  • mfrom: (1.3.1)
  • Revision ID: package-import@ubuntu.com-20140821193630-kertpu5hd8yyss8h
Tags: 1.7.0~beta7+bzr3266-0ubuntu1
* New Upstream Snapshot, Beta 7 bzr3266

[ Jeroen Vermeulen ]
* debian/extras/99-maas-sudoers
  debian/maas-dhcp.postinst
  debian/rules
  - Add second DHCP server instance for IPv6.
* debian/maas-region-controller-min.install
  debian/maas-region-controller-min.lintian-overrides
  - Install deployment user-data: maas_configure_interfaces.py script.
* debian/maas-cluster-controller.links
  debian/maas-cluster-controller.install
  debian/maas-cluster-controller.postinst
  - Reflect Celery removal changes made in trunk r3067.
  - Don't install celeryconfig_cluster.py any longer. 
  - Don't install maas_local_celeryconfig_cluster.py any longer.
  - Don't symlink maas_local_celeryconfig_cluster.py from /etc to /usr.
  - Don't insert UUID into maas_local_celeryconfig_cluster.py.

[ Andres Rodriguez ]
* debian/maas-region-controller-min.postrm: Cleanup lefover files.
* debian/maas-dhcp.postrm: Clean leftover configs.
* Provide new maas-proxy package that replaces the usage of
  squid-deb-proxy:
  - debian/control: New maas-proxy package that replaces the usage
    of squid-deb-proxy; Drop depends on squid-deb-proxy.
  - Add upstrart job.
  - Ensure squid3 is stopped as maas-proxy uses a caching proxy.
* Remove Celery references to cluster controller:
  - Rename upstart job from maas-pserv to maas-cluster; rename
    maas-cluster-celery to maas-cluster-register. Ensure services
    are stopped on upgrade.
  - debian/maintscript: Cleanup config files.
  - Remove all references to the MAAS celery daemon and config
    files as we don't use it like that anymore
* Move some entries in debian/maintscript to
  debian/maas-cluster-controller.maintscript
* Remove usage of txlongpoll and rabbitmq-server. Handle upgrades
  to ensure these are removed correctly.

[ Jason Hobbs ]
* debian/maas-region-controller-min.install: Install
  maas-generate-winrm-cert script.

[ Raphaël Badin ]
* debian/extras/maas-region-admin: Bypass django-admin as it prints
  spurious messages to stdout (LP: #1365130).

[Louis Bouchard]
* debian/maas-cluster-controller.postinst:
  - Exclude /var/log/maas/rsyslog when changing ownership
    (LP: #1346703)

[Gavin Panella]
* debian/maas-cluster-controller.maas-clusterd.upstart:
  - Don't start-up the cluster controller unless a shared-secret has
    been installed.
* debian/maas-cluster-controller.maas-cluster-register.upstart: Drop.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    IsCallable,
28
28
    MockCalledOnceWith,
29
29
    )
30
 
from maastesting.testcase import MAASTestCase
 
30
from maastesting.testcase import (
 
31
    MAASTestCase,
 
32
    MAASTwistedRunTest,
 
33
    )
31
34
from mock import (
32
35
    Mock,
33
36
    sentinel,
43
46
    retries,
44
47
    synchronous,
45
48
    )
46
 
from testtools.deferredruntest import (
47
 
    AsynchronousDeferredRunTest,
48
 
    extract_result,
49
 
    )
 
49
from testtools.deferredruntest import extract_result
50
50
from testtools.matchers import (
51
51
    AfterPreprocessing,
52
52
    Equals,
79
79
 
80
80
class TestAsynchronousDecorator(MAASTestCase):
81
81
 
82
 
    run_tests_with = AsynchronousDeferredRunTest.make_factory(timeout=5)
 
82
    run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)
83
83
 
84
84
    def test_in_reactor_thread(self):
85
85
        result = asynchronous(return_args)(1, 2, three=3)
104
104
 
105
105
class TestAsynchronousDecoratorWithTimeout(MAASTestCase):
106
106
 
107
 
    run_tests_with = AsynchronousDeferredRunTest.make_factory(timeout=5)
 
107
    run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)
108
108
 
109
109
    def test_timeout_cannot_be_None(self):
110
110
        self.assertRaises(ValueError, asynchronous, noop, timeout=None)
127
127
 
128
128
class TestAsynchronousDecoratorWithTimeoutDefined(MAASTestCase):
129
129
 
130
 
    run_tests_with = AsynchronousDeferredRunTest.make_factory(timeout=5)
 
130
    run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)
131
131
 
132
132
    scenarios = (
133
133
        ("finite", {"timeout": random()}),
183
183
 
184
184
class TestSynchronousDecorator(MAASTestCase):
185
185
 
186
 
    run_tests_with = AsynchronousDeferredRunTest.make_factory(timeout=5)
 
186
    run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)
187
187
 
188
188
    @synchronous
189
189
    def return_args(self, *args, **kwargs):
215
215
class TestReactorSync(MAASTestCase):
216
216
    """Tests for `reactor_sync`."""
217
217
 
218
 
    run_tests_with = AsynchronousDeferredRunTest.make_factory(timeout=5)
 
218
    run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)
219
219
 
220
220
    def test__does_what_it_claims(self):
221
221
        whence = []
336
336
            Equals(expected_wait),  # wait
337
337
        ]))
338
338
 
339
 
    def test_yields_elapsed_remaining_and_sleeper(self):
 
339
    def test_yields_elapsed_remaining_and_wait(self):
340
340
        # Take control of time.
341
341
        clock = Clock()
342
342
 
356
356
        self.assertRetry(clock, next(gen_retries), 4, 1, 1)
357
357
        # Mimic sleeping for the suggested sleep time.
358
358
        clock.advance(1)
 
359
        # There's always a final chance to try something.
 
360
        self.assertRetry(clock, next(gen_retries), 5, 0, 0)
359
361
        # All done.
360
362
        self.assertRaises(StopIteration, next, gen_retries)
361
363
 
376
378
        self.assertRetry(clock, next(gen_retries), 4, 1, 1)
377
379
        # Mimic sleeping for 100 seconds, much more than the suggested.
378
380
        clock.advance(100)
 
381
        # There's always a final chance to try something, but the elapsed and
 
382
        # remaining figures are still calculated with reference to the current
 
383
        # time. The wait time never goes below zero.
 
384
        self.assertRetry(clock, next(gen_retries), 104, -99, 0)
379
385
        # All done.
380
386
        self.assertRaises(StopIteration, next, gen_retries)
381
387