<commit_before>########
# Copyright (c) 2019 Cloudify Platform Ltd. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
#    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    * See the License for the specific language governing permissions and
#    * limitations under the License.

import time

import pytest

from .test_hosts import (
    TestHosts,
)


SKIP_SANITY = {'skip_sanity': 'true'}
DATABASE_SERVICES_TO_INSTALL = ['database_service']
QUEUE_SERVICES_TO_INSTALL = ['queue_service']
MANAGER_SERVICES_TO_INSTALL = ['manager_service']


@pytest.fixture(scope='module')
def image_based_manager(
        request, cfy, ssh_key, module_tmpdir, attributes, logger):
    """Creates a cloudify manager from an image in rackspace OpenStack."""
    hosts = TestHosts(
            cfy, ssh_key, module_tmpdir, attributes, logger, request=request)
    try:
        hosts.create()
        hosts.instances[0].use()
        yield hosts.instances[0]
    finally:
        hosts.destroy()


@pytest.fixture(scope='module')
def image_based_manager_without_plugins(
        request, cfy, ssh_key, module_tmpdir, attributes, logger):
    """Creates a cloudify manager from an image in rackspace OpenStack."""
    """Creates a cloudify manager from an image in rackspace OpenStack."""
    hosts = TestHosts(
            cfy, ssh_key, module_tmpdir, attributes, logger, request=request,
            upload_plugins=False)
    try:
        hosts.create()
        hosts.instances[0].use()
        yield hosts.instances[0]
    finally:
        hosts.destroy()


@pytest.fixture(scope='module')
def bootstrap_based_manager(
        request, cfy, ssh_key, module_tmpdir, attributes, logger):
    """Bootstraps a cloudify manager on a VM in rackspace OpenStack."""
    hosts = TestHosts(
            cfy, ssh_key, module_tmpdir, attributes, logger,
            bootstrappable=True)
    try:
        hosts.create()
        for instance in hosts.instances:
            instance.bootstrap(blocking=False, upload_license=True)
        for instance in hosts.instances:
            logger.info('Waiting for bootstrap of {}'.format(
                instance.server_id
            ))
            while not instance.bootstrap_is_complete():<commit_msg>CY-2392 Wait for restservice on image based<commit_after>########
# Copyright (c) 2019 Cloudify Platform Ltd. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
#    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    * See the License for the specific language governing permissions and
#    * limitations under the License.

import time

import pytest

from .test_hosts import (
    TestHosts,
)


SKIP_SANITY = {'skip_sanity': 'true'}
DATABASE_SERVICES_TO_INSTALL = ['database_service']
QUEUE_SERVICES_TO_INSTALL = ['queue_service']
MANAGER_SERVICES_TO_INSTALL = ['manager_service']


@pytest.fixture(scope='module')
def image_based_manager(
        request, cfy, ssh_key, module_tmpdir, attributes, logger):
    """Creates a cloudify manager from an image in rackspace OpenStack."""
    hosts = TestHosts(
            cfy, ssh_key, module_tmpdir, attributes, logger, request=request)
    try:
        hosts.create()
        hosts.instances[0].restservice_expected = True
        hosts.instances[0].finalize_preparation()
        hosts.instances[0].use()
        yield hosts.instances[0]
    finally:
        hosts.destroy()


@pytest.fixture(scope='module')
def image_based_manager_without_plugins(
        request, cfy, ssh_key, module_tmpdir, attributes, logger):
    """Creates a cloudify manager from an image in rackspace OpenStack."""
    """Creates a cloudify manager from an image in rackspace OpenStack."""
    hosts = TestHosts(
            cfy, ssh_key, module_tmpdir, attributes, logger, request=request,
            upload_plugins=False)
    try:
        hosts.create()
        hosts.instances[0].restservice_expected = True
        hosts.instances[0].finalize_preparation()
        hosts.instances[0].use()
        yield hosts.instances[0]
    finally:
        hosts.destroy()


@pytest.fixture(scope='module')
def bootstrap_based_manager(
        request, cfy, ssh_key, module_tmpdir, attributes, logger):
    """Bootstraps a cloudify manager on a VM in rackspace OpenStack."""
    hosts = TestHosts(
            cfy, ssh_key, module_tmpdir, attributes, logger,
            bootstrappable=True)
    try:
        hosts.create()
        for instance in hosts.instances:
            instance.bootstrap(blocking=False, upload_license=True)
        for instance in hosts.instances:
            logger.info('Waiting for bootstrap of {}'.format(
                instance.server_id
            ))
            while not instance.bootstrap_is_complete():
{'fraction_non_alphanumeric': 0.0949834009590557, 'fraction_numerical': 0.005901881224640354, 'mean_word_length': 3.2433489827856024, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1765977', 'n_tokens_mistral': 1573, 'n_tokens_neox': 1528, 'n_words': 475}