<commit_before>import os

from unittest import TestCase

from integration.helpers import HTTPClient, SSHClient
from . import ci

class TestMysql(TestCase):
    def setUp(self):
        self.ip = ci.environment.node['cookbooks'].ip_address
        self.cookbooks_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), \
                "..", "..", "cooks", "cookbooks")
        self.remote = SSHClient()
        self.remote.connect_ssh(str(self.ip), "root", "r00tme")

    def test_mysql_deploy(self):
        self.remote.mkdir("/opt/os-cookbooks/")
        self.remote.scp_d(self.cookbooks_dir + "/mysql", "/opt/os-cookbooks/")
        self.remote.exec_cmd("chef-solo")<commit_msg>[cooks test] mysql deployment test is done<commit_after>import os
import simplejson as json
from unittest import TestCase
from nose.tools import eq_

from integration.helpers import HTTPClient, SSHClient
from . import ci


class TestMysql(TestCase):

    def setUp(self):
        self.ip = ci.environment.node['cookbooks'].ip_address
        self.cookbooks_dir = os.path.join(os.path.dirname(
                os.path.abspath(__file__)),
                "..", "..", "cooks", "cookbooks")
        self.remote = SSHClient()
        self.remote.connect_ssh(str(self.ip), "root", "r00tme")
        self.remote.mkdir("/opt/os-cookbooks/")
        solo_rb = """file_cache_path "/tmp/chef"
cookbook_path "/opt/os-cookbooks"
"""
        with open('/tmp/solo.rb', 'w') as f:
            f.write(solo_rb)
        self.remote.scp('/tmp/solo.rb', '/tmp/solo.rb')

    def test_mysql_deploy(self):
        self.remote.scp_d(self.cookbooks_dir + "/mysql", "/opt/os-cookbooks/")
        mysql_solo = {'recipes': ["mysql::server"]}
        with open('/tmp/mysql_solo.json', 'w') as f:
            f.write(json.dumps(mysql_solo))
        self.remote.scp('/tmp/mysql_solo.json', '/tmp/mysql_solo.json')

        res = self.remote.exec_cmd(
                "chef-solo -l debug -c /tmp/solo.rb -j /tmp/mysql_solo.json")
        print "*******************STDOUT*******************"
        for line in res['stdout']:
            print line
        print "*******************STDERR*******************"
        for line in res['stderr']:
            print line
        eq_(res['exit_status'], 0)
{'fraction_non_alphanumeric': 0.18053097345132743, 'fraction_numerical': 0.0022123893805309734, 'mean_word_length': 2.7065573770491804, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4413192', 'n_tokens_mistral': 759, 'n_tokens_neox': 732, 'n_words': 136}