<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015-2015: Alignak team, see AUTHORS.txt file for contributors
#
# This file is part of Alignak.
#
# Alignak is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alignak is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Alignak.  If not, see <http://www.gnu.org/licenses/>.
#

import subprocess
import json
from time import sleep
import requests
import shutil

from alignak_test import unittest

from alignak.misc.serialization import unserialize
from alignak.http.generic_interface import GenericInterface
from alignak.http.receiver_interface import ReceiverInterface
from alignak.http.arbiter_interface import ArbiterInterface
from alignak.http.scheduler_interface import SchedulerInterface
from alignak.http.broker_interface import BrokerInterface
from alignak.check import Check


class fullTest(unittest.TestCase):
    def _get_subproc_data(self, name):
        try:
            print("Try to end %s" % name)
            self.procs[name].send_signal(2)
            self.procs[name].send_signal(15)
            self.procs[name].wait()
        except Exception as err:
            print("prob on terminate and wait subproc %s: %s" % (name, err))
        data = {}
        data['out'] = self.procs[name].stdout.read()
        data['err'] = self.procs[name].stderr.read()
        data['rc'] = self.procs[name].returncode
        return data

    def tearDown(self):
        for name, proc in self.procs.items():
            if proc:
                self._get_subproc_data(name)  # so to terminate / wait it..

    def test_daemons_outputs(self):

        req = requests.Session()

        # copy etc config files in test/cfg/full and change folder in files for run and log of
        # alignak
        shutil.copytree('../etc', 'cfg/full')
        files = ['cfg/full/daemons/brokerd.ini', 'cfg/full/daemons/pollerd.ini',
                 'cfg/full/daemons/reactionnerd.ini', 'cfg/full/daemons/receiverd.ini',
                 'cfg/full/daemons/schedulerd.ini', 'cfg/full/alignak.cfg']
        replacements = {'/var/run/alignak': '/tmp', '/var/log/alignak': '/tmp'}
        for filename in files:
            lines = []
            with open(filename) as infile:
                for line in infile:
                    for src, target in replacements.iteritems():
                        line = line.replace(src, target)
                    lines.append(line)
            with open(filename, 'w') as outfile:
                for line in lines:
                    outfile.write(line)

        self.procs = {}
        satellite_map = {'arbiter': '7770',
                         'scheduler': '7768',
                         'broker': '7772',
                         'poller': '7771',
                         'reactionner': '7769',
                         'receiver': '7773'<commit_msg>Update full_tst to comply with the new default configuration (/usr/local/ prefixed directories<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015-2015: Alignak team, see AUTHORS.txt file for contributors
#
# This file is part of Alignak.
#
# Alignak is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alignak is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Alignak.  If not, see <http://www.gnu.org/licenses/>.
#

import subprocess
import json
from time import sleep
import requests
import shutil

from alignak_test import unittest

from alignak.misc.serialization import unserialize
from alignak.http.generic_interface import GenericInterface
from alignak.http.receiver_interface import ReceiverInterface
from alignak.http.arbiter_interface import ArbiterInterface
from alignak.http.scheduler_interface import SchedulerInterface
from alignak.http.broker_interface import BrokerInterface
from alignak.check import Check


class fullTest(unittest.TestCase):
    def _get_subproc_data(self, name):
        try:
            print("Try to end %s" % name)
            self.procs[name].send_signal(2)
            self.procs[name].send_signal(15)
            self.procs[name].wait()
        except Exception as err:
            print("prob on terminate and wait subproc %s: %s" % (name, err))
        data = {}
        data['out'] = self.procs[name].stdout.read()
        data['err'] = self.procs[name].stderr.read()
        data['rc'] = self.procs[name].returncode
        return data

    def tearDown(self):
        for name, proc in self.procs.items():
            if proc:
                self._get_subproc_data(name)  # so to terminate / wait it..

    def test_daemons_outputs(self):

        req = requests.Session()

        # copy etc config files in test/cfg/full and change folder in files for run and log of
        # alignak
        shutil.copytree('../etc', 'cfg/full')
        files = ['cfg/full/daemons/brokerd.ini', 'cfg/full/daemons/pollerd.ini',
                 'cfg/full/daemons/reactionnerd.ini', 'cfg/full/daemons/receiverd.ini',
                 'cfg/full/daemons/schedulerd.ini', 'cfg/full/alignak.cfg']
        replacements = {'/usr/local/var/run/alignak': '/tmp', '/usr/local/var/log/alignak': '/tmp'}
        for filename in files:
            lines = []
            with open(filename) as infile:
                for line in infile:
                    for src, target in replacements.iteritems():
                        line = line.replace(src, target)
                    lines.append(line)
            with open(filename, 'w') as outfile:
                for line in lines:
                    outfile.write(line)

        self.procs = {}
        satellite_map = {'arbiter': '7770',
                         'scheduler': '7768',
                         'broker': '7772',
                         'poller': '7771',
                         'reactionner': '7769',
                         'receiver': '7773'
{'fraction_non_alphanumeric': 0.10051736881005174, 'fraction_numerical': 0.010938654841093865, 'mean_word_length': 2.3611525086934924, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6226816', 'n_tokens_mistral': 1976, 'n_tokens_neox': 1881, 'n_words': 602}