예제 #1
0
파일: test_js.py 프로젝트: chrisspen/burlap
    def test_jshint1(self):

        set_verbose(True)
        jshint.genv.ROLE = 'local'
        jshint.genv.services = ['jshint']
        jshint.clear_caches()

#         packager.update()
#         packager.upgrade(full=1)

        print('Installing jshint...')
        jshint.env.enabled = True
        jshint.clear_local_renderer()
        #jshint.install_packages() # fails on Ubuntu 14 under Travis-CI?
        #jshint.sudo('apt-get purge nodejs-legacy nodejs')
        #jshint.sudo('apt-get update --fix-missing; DEBIAN_FRONTEND=noninteractive apt-get -f -o Dpkg::Options::="--force-overwrite" install --yes npm')
        jshint.configure()
        deploy_satchel.purge()
        print('-'*80)
        print('Thumbprinting...')
        deploy_satchel.fake(components=jshint.name)
        print('-'*80)

        # Confirm jshint was installed.
        #assert exists('/usr/local/bin/jshint')
        output = jshint.run('jshint --version')
        print('output:', output)
        assert 'jshint v' in output

        print('Disabling jshint...')
        jshint.env.enabled = False
        jshint.clear_local_renderer()
        jshint.configure()
예제 #2
0
파일: test_js.py 프로젝트: broxeph/burlap
    def test_jshint1(self):

        set_verbose(True)
        jshint.genv.ROLE = 'local'
        jshint.genv.services = ['jshint']
        jshint.clear_caches()

        #         packager.update()
        #         packager.upgrade(full=1)

        print('Installing jshint...')
        jshint.env.enabled = True
        jshint.clear_local_renderer()
        #jshint.install_packages() # fails on Ubuntu 14 under Travis-CI?
        #jshint.sudo('apt-get purge nodejs-legacy nodejs')
        #jshint.sudo('apt-get update --fix-missing; DEBIAN_FRONTEND=noninteractive apt-get -f -o Dpkg::Options::="--force-overwrite" install --yes npm')
        jshint.configure()
        deploy_satchel.purge()
        print('-' * 80)
        print('Thumbprinting...')
        deploy_satchel.fake(components=jshint.name)
        print('-' * 80)

        # Confirm jshint was installed.
        #assert exists('/usr/local/bin/jshint')
        output = jshint.run('jshint --version')
        print('output:', output)
        assert 'jshint v' in output

        print('Disabling jshint...')
        jshint.env.enabled = False
        jshint.clear_local_renderer()
        jshint.configure()
예제 #3
0
    def test_hooks(self):

        set_verbose(True)
        git.genv.ROLE = 'prod'
        git.genv.services = ['git']
        git.clear_caches()

        print('Installing git...')
        git.install_packages() # fails on Ubuntu 14 under Travis-CI?

        print('Setting up sample git repo...')
        run('mkdir /tmp/mygithookrepo || true')
        with cd('/tmp/mygithookrepo'):
            run('git init')
        assert not exists('/tmp/mygithookrepo/.git/hooks/post-checkout')

        print('Configuring git...')
        git.env.enabled = True
        git.env.hooks = {'/tmp/mygithookrepo': ['git/post-checkout']}
        git.clear_local_renderer()
        deploy_satchel.purge()
        cm = git.current_manifest
        print('cm1:', cm)
        assert 'hooks' in cm

        added_hooks, removed_hooks = git.get_changed_hooks()
        print('added_hooks:', added_hooks)
        assert added_hooks == {'/tmp/mygithookrepo': ['git/post-checkout']}
        print('removed_hooks:', removed_hooks)
        assert removed_hooks == {}

        print('Installing git hooks...')
        git.clear_local_renderer()
        git.configure()
        deploy_satchel.purge()
        print('-'*80)
        print('Thumbprinting...')
        #thumbprint(components=git.name)
        deploy_satchel.fake(components=git.name)
        print('-'*80)

        assert exists('/tmp/mygithookrepo/.git/hooks/post-checkout')
예제 #4
0
파일: test_git.py 프로젝트: broxeph/burlap
    def test_hooks(self):

        set_verbose(True)
        git.genv.ROLE = 'prod'
        git.genv.services = ['git']
        git.clear_caches()

        print('Installing git...')
        git.install_packages()  # fails on Ubuntu 14 under Travis-CI?

        print('Setting up sample git repo...')
        run('mkdir /tmp/mygithookrepo || true')
        with cd('/tmp/mygithookrepo'):
            run('git init')
        assert not exists('/tmp/mygithookrepo/.git/hooks/post-checkout')

        print('Configuring git...')
        git.env.enabled = True
        git.env.hooks = {'/tmp/mygithookrepo': ['git/post-checkout']}
        git.clear_local_renderer()
        deploy_satchel.purge()
        cm = git.current_manifest
        print('cm1:', cm)
        assert 'hooks' in cm

        added_hooks, removed_hooks = git.get_changed_hooks()
        print('added_hooks:', added_hooks)
        assert added_hooks == {'/tmp/mygithookrepo': ['git/post-checkout']}
        print('removed_hooks:', removed_hooks)
        assert removed_hooks == {}

        print('Installing git hooks...')
        git.clear_local_renderer()
        git.configure()
        deploy_satchel.purge()
        print('-' * 80)
        print('Thumbprinting...')
        #thumbprint(components=git.name)
        deploy_satchel.fake(components=git.name)
        print('-' * 80)

        assert exists('/tmp/mygithookrepo/.git/hooks/post-checkout')
예제 #5
0
    def setUp(self):
        from burlap import deploy, manifest
        from burlap.deploy import deploy as deploy_satchel

        # Always print the current test name before the test.
        # _, columns = map(int, os.popen('stty size', 'r').read().split()) # TODO:fix? broke in Ubuntu16+Python3
        columns = 80
        kwargs = dict(
            bar='#' * columns,
            name=self._testMethodName,
        )
        print(self.test_name_format.format(**kwargs), file=self.test_name_fout)

        # Save fabric state.
        self._env = env.copy()
        #         print('before env clear:')
        #         pprint(env, indent=4)

        # Reset fabric state.
        #self.clear_env()
        #self.update_env(default_env)
        print('setUp: initializing env...')
        init_env()
        #deploy_init_env()

        if not env.host_string:
            env.host_string = 'localhost'
            env.hosts = [env.host_string]

        # Save cwd.
        self._cwd = os.getcwd()
        print('cwd:', self._cwd)

        # Save burlap state.
        print('setUp: Saving burlap state...')
        self._burlap_state = get_state()

        self._dryrun = get_dryrun()
        self._verbose = get_verbose()

        # Clear runs_once on legacy runs_once methods.
        print('setUp: Clearing runs_once methods...')
        modules = [deploy, deploy_satchel, manifest]
        for module in modules:
            print('setUp: Checking module:', module)
            for name in dir(module):
                print('setUp: Checking name:', name)
                #func = getattr(module, name)
                #if not callable(func):
                if not is_callable(module, name):
                    continue
                func = getattr(module, name)
                print('clearing:', func)
                clear_runs_once(func)

        # Clear runs_once on our custom runs_once methods.
        print('setUp: Clearing custom runs_once methods...')
        from burlap.common import runs_once_methods
        for meth in runs_once_methods:
            clear_runs_once(func)

        # Ensure all satchels re-push all their local variables back into the global env.
        print('setUp: Clearing satchels...')
        for satchel in all_satchels.values():
            satchel.register()
            satchel.clear_caches()

        # Set satchel variables that should be customized just for unittests.
        # For example, so we can run unittests locally, we want to change the default burlap paths so they don't conflict with the defaults,
        # in case we're using burlap to deploy locally.
        deploy_satchel.env.lockfile_path = '/tmp/burlap_unittests/deploy.lock'
        deploy_satchel.env.data_dir = '/tmp/burlap_unittests'

        # Since these tests are automated, if we ever get a prompt, we should immediately fail,
        # because no action should ever be user-interactive.
        env.abort_on_prompts = True
        env.always_use_pty = False

        print('setUp: Purging deployments...')
        #delete_plan_data_dir()
        deploy_satchel.purge()

        #clear_fs_cache()

        super(TestCase, self).setUp()
예제 #6
0
    def test_selenium(self):
        try:
            print('deploy_satchel.env.lockfile_path:', deploy_satchel.env.lockfile_path)
            print('deploy_satchel.env.data_dir:', deploy_satchel.env.data_dir)
            assert deploy_satchel.env.lockfile_path == '/tmp/burlap_unittests/deploy.lock'
            assert deploy_satchel.env.data_dir == '/tmp/burlap_unittests'
            assert deploy_satchel.manifest_filename == '/tmp/burlap_unittests/manifest.yaml'

            set_verbose(True)
            print('selenium.geckodriver_path:', selenium.geckodriver_path)
            selenium.genv.ROLE = 'local'
            selenium.genv.services = ['selenium']
            selenium.clear_caches()

            print('Enabling selenium/gecko to install and track old version.')
            print('selenium._last_manifest.1:', selenium._last_manifest)
            print('selenium.last_manifest.1:', selenium.last_manifest)
            selenium.env.enabled = True
            selenium.env.geckodriver_version = '0.13.0'
            selenium.clear_local_renderer()
            assert selenium.get_target_geckodriver_version_number() == '0.13.0'
            print('Configuring selenium...')
            selenium.configure()
            print('selenium._last_manifest.2:', selenium._last_manifest)
            print('selenium.last_manifest.2:', selenium.last_manifest)
            print('Writing manifest...')
            deploy_satchel.fake(components=selenium.name)
            deploy_satchel.run('ls -lah %s' % deploy_satchel.manifest_filename)
            deploy_satchel.run('cat %s' % deploy_satchel.manifest_filename)
            print('selenium._last_manifest.3:', selenium._last_manifest)
            print('selenium.last_manifest.3:', selenium.last_manifest)

            print('Confirming install succeeded...')
            assert exists(selenium.geckodriver_path)
            assert not selenium.check_for_change()
            output = selenium.run('geckodriver --version')
            print('Geckodriver version:', output)
            expected_version = selenium.env.geckodriver_version
            assert expected_version in output

            print('Updating configuration to track the most recent version...')
            selenium.env.geckodriver_version = None
            selenium.clear_local_renderer()
            assert selenium.get_target_geckodriver_version_number() != '0.13.0'
            assert selenium.last_manifest.fingerprint == '0.13.0'

            print('Confirm we now see a pending change...')
            assert selenium.check_for_change()

            print('-'*80)
            print('Applying change...')
            selenium.configure()
            deploy_satchel.purge()
            print('-'*80)
            print('Thumbprinting...')
            deploy_satchel.fake(components=selenium.name)
            print('-'*80)

            print('Confirming the most recent version was installed...')
            expected_version = selenium.get_most_recent_version()
            selenium.clear_caches()
            assert selenium.last_manifest.fingerprint == expected_version
            output = selenium.run('geckodriver --version')
            expected_version = selenium.get_latest_geckodriver_version_number()
            assert expected_version in output
            assert not selenium.check_for_change()

            print('Update configuration to not manage gecko and apply...')
            selenium.env.enabled = False
            selenium.clear_local_renderer()
            selenium.configure()

            # Confirm gecko was uninstalled.
            assert not exists(selenium.geckodriver_path)

        finally:
            selenium.uninstall_geckodriver()
예제 #7
0
 def thumbprint(self, components=None):
     deploy_satchel.purge()
     deploy_satchel.fake(components=components)