Exemplo n.º 1
0
  def test_rudder_reporting_with_variable_content(self):


    expected_result = []
    expected_result.append('bundle agent Test_technique_with_variable_rudder_reporting')
    expected_result.append('{')
    expected_result.append('  vars:')
    expected_result.append('    "args"               slist => {  };')
    expected_result.append('    "report_param"      string => join("_", args);')
    expected_result.append('    "full_class_prefix" string => canonify("Test_technique_with_variable_rudder_reporting_${report_param}");')
    expected_result.append('    "class_prefix"      string => string_head("${full_class_prefix}", "1000");')
    expected_result.append('')
    expected_result.append('  methods:')
    expected_result.append('')
    expected_result.append('      "dummy_report" usebundle => _classes_noop("${class_prefix}_file_create_${sys.workdir}_module_env"),')
    expected_result.append('                    ifvarclass => concat("!(directory_create_",canonify("${sys.workdir}"),"_module_repaired)");')
    expected_result.append('      "dummy_report_1" usebundle => _method_reporting_context("ph2", "${sys.workdir}/module/env"),')
    expected_result.append('                    ifvarclass => concat("!(directory_create_",canonify("${sys.workdir}"),"_module_repaired)");')
    expected_result.append('      "dummy_report" usebundle => log_rudder("File create ${sys.workdir}/module/env if directory_create_${sys.workdir}_module_repaired", "${sys.workdir}/module/env", "${class_prefix}_file_create_${sys.workdir}_module_env", "${class_prefix}_file_create_${sys.workdir}_module_env", @{args}),')
    expected_result.append('                    ifvarclass => concat("!(directory_create_",canonify("${sys.workdir}"),"_module_repaired)");')
    expected_result.append('}')

    # Join all lines with \n
    result = '\n'.join(expected_result)+"\n"

    generated_result = ncf_rudder.generate_rudder_reporting(self.reporting_with_var_metadata)

    diff = self._unidiff_output(result, generated_result)

    if len(diff):
        print()
        print("Test test_rudder_reporting_with_variable_content failed, this is the diff between expected and actual result:")
        print(diff)

    self.assertEqual(result, generated_result)
Exemplo n.º 2
0
  def test_rudder_reporting_content(self):

    expected_result = []
    expected_result.append('bundle agent bla_rudder_reporting')
    expected_result.append('{')
    expected_result.append('  methods:')
    expected_result.append('')
    expected_result.append('    !(debian)::')
    expected_result.append('      "dummy_report" usebundle => _classes_noop("service_start_apache2");')
    expected_result.append('      "dummy_report" usebundle => logger_rudder("Not applicable", "service_start_apache2");')
    expected_result.append('')
    expected_result.append('    !(service_start_apache2_repaired)::')
    expected_result.append('      "dummy_report" usebundle => _classes_noop("package_install_openssh_server");')
    expected_result.append('      "dummy_report" usebundle => logger_rudder("Not applicable", "package_install_openssh_server");')
    expected_result.append('')
    expected_result.append('    !(!service_start_apache2_repaired.debian)::')
    expected_result.append('      "dummy_report" usebundle => _classes_noop("command_execution__bin_date");')
    expected_result.append('      "dummy_report" usebundle => logger_rudder("Not applicable", "command_execution__bin_date");')
    expected_result.append('}')

    # Join all lines with \n
    result = '\n'.join(expected_result)+"\n"

    generated_result = ncf_rudder.generate_rudder_reporting(self.reporting_metadata)

    self.assertEquals(result, generated_result)
Exemplo n.º 3
0
  def test_rudder_reporting_with_variable_content(self):


    expected_result = []
    expected_result.append('bundle agent Test_technique_with_variable_rudder_reporting')
    expected_result.append('{')
    expected_result.append('  vars:')
    expected_result.append('    "promisers"          slist => { @{this.callers_promisers}, cf_null }, policy => "ifdefined";')
    expected_result.append('    "class_prefix"      string => canonify(join("_", "promisers"));')
    expected_result.append('    "args"               slist => { };')
    expected_result.append('')
    expected_result.append('  methods:')
    expected_result.append('')
    expected_result.append('      "dummy_report" usebundle => _classes_noop("file_create_${sys.workdir}_module_env"),')
    expected_result.append('                    ifvarclass => concat("!(directory_create_",canonify("${sys.workdir}"),"_module_repaired)");')
    expected_result.append('      "dummy_report" usebundle => log_rudder("File create ${sys.workdir}/module/env if directory_create_${sys.workdir}_module_repaired", "file_create_${sys.workdir}_module_env", "${class_prefix}", @{args}),')
    expected_result.append('                    ifvarclass => concat("!(directory_create_",canonify("${sys.workdir}"),"_module_repaired)");')
    expected_result.append('}')

    # Join all lines with \n
    result = '\n'.join(expected_result)+"\n"

    generated_result = ncf_rudder.generate_rudder_reporting(self.reporting_with_var_metadata)

    diff = self._unidiff_output(result, generated_result)

    if len(diff):
        print
        print "Test test_rudder_reporting_with_variable_content failed, this is the diff between expected and actual result:"
        print diff

    self.assertEqual(result, generated_result)
Exemplo n.º 4
0
 def test_rudder_reporting_from_technique(self):
     """The rudder-reporting.cf content generated from a ncf technique must match the reporting we expect for our technique"""
     rudder_reporting_string = ncf_rudder.generate_rudder_reporting(
         self.technique_metadata)
     expected_rudder_reporting = self.test_rudder_reporting_content
     self.assertEqual(expected_rudder_reporting.split("\n"),
                      rudder_reporting_string.split("\n"))
Exemplo n.º 5
0
    def test_rudder_reporting_with_variable_content(self):

        expected_result = []
        expected_result.append(
            'bundle agent Test_technique_with_variable_rudder_reporting')
        expected_result.append('{')
        expected_result.append('  methods:')
        expected_result.append('')
        expected_result.append(
            '      "dummy_report" usebundle => _classes_noop("file_create_${sys.workdir}_module_env"),'
        )
        expected_result.append(
            '                    ifvarclass => concat("!(directory_create_",canonify("${sys.workdir}"),"_module_repaired)");'
        )
        expected_result.append(
            '      "dummy_report" usebundle => logger_rudder("Not applicable", "file_create_${sys.workdir}_module_env"),'
        )
        expected_result.append(
            '                    ifvarclass => concat("!(directory_create_",canonify("${sys.workdir}"),"_module_repaired)");'
        )
        expected_result.append('}')

        # Join all lines with \n
        result = '\n'.join(expected_result) + "\n"

        generated_result = ncf_rudder.generate_rudder_reporting(
            self.reporting_with_var_metadata)

        self.assertEqual(result, generated_result)
Exemplo n.º 6
0
  def test_rudder_reporting_with_variable_content(self):


    expected_result = []
    expected_result.append('bundle agent Test_technique_with_variable_rudder_reporting')
    expected_result.append('{')
    expected_result.append('  vars:')
    expected_result.append('    "promisers"          slist => { @{this.callers_promisers}, cf_null }, policy => "ifdefined";')
    expected_result.append('    "class_prefix"      string => canonify(join("_", "promisers"));')
    expected_result.append('    "args"               slist => { };')
    expected_result.append('')
    expected_result.append('  methods:')
    expected_result.append('')
    expected_result.append('      "dummy_report" usebundle => _classes_noop("file_create_${sys.workdir}_module_env"),')
    expected_result.append('                    ifvarclass => concat("!(directory_create_",canonify("${sys.workdir}"),"_module_repaired)");')
    expected_result.append('      "dummy_report_1" usebundle => _method_reporting_context("File create", "${sys.workdir}/module/env"),')
    expected_result.append('                    ifvarclass => concat("!(directory_create_",canonify("${sys.workdir}"),"_module_repaired)");')
    expected_result.append('      "dummy_report" usebundle => log_rudder("File create ${sys.workdir}/module/env if directory_create_${sys.workdir}_module_repaired", "${sys.workdir}/module/env", "file_create_${sys.workdir}_module_env", "${class_prefix}", @{args}),')
    expected_result.append('                    ifvarclass => concat("!(directory_create_",canonify("${sys.workdir}"),"_module_repaired)");')
    expected_result.append('}')

    # Join all lines with \n
    result = '\n'.join(expected_result)+"\n"

    generated_result = ncf_rudder.generate_rudder_reporting(self.reporting_with_var_metadata)

    diff = self._unidiff_output(result, generated_result)

    if len(diff):
        print()
        print("Test test_rudder_reporting_with_variable_content failed, this is the diff between expected and actual result:")
        print(diff)

    self.assertEqual(result, generated_result)
Exemplo n.º 7
0
    def test_rudder_reporting_content(self):

        expected_result = []
        expected_result.append('bundle agent bla_rudder_reporting')
        expected_result.append('{')
        expected_result.append('  vars:')
        expected_result.append(
            '    "promisers"          slist => { @{this.callers_promisers}, cf_null }, policy => "ifdefined";'
        )
        expected_result.append(
            '    "class_prefix"      string => canonify(join("_", "promisers"));'
        )
        expected_result.append('    "args"               slist => { };')
        expected_result.append('')
        expected_result.append('  methods:')
        expected_result.append('')
        expected_result.append('    !(debian)::')
        expected_result.append(
            '      "dummy_report" usebundle => _classes_noop("service_start_apache2");'
        )
        expected_result.append(
            '      "dummy_report" usebundle => log_rudder("Service start apache2 if debian", "service_start_apache2", "${class_prefix}", @{args});'
        )
        expected_result.append('')
        expected_result.append('    !(service_start_apache2_repaired)::')
        expected_result.append(
            '      "dummy_report" usebundle => _classes_noop("package_install_openssh_server");'
        )
        expected_result.append(
            '      "dummy_report" usebundle => log_rudder("Package install openssh-server if service_start_apache2_repaired", "package_install_openssh_server", "${class_prefix}", @{args});'
        )
        expected_result.append('')
        expected_result.append(
            '    !(!service_start_apache2_repaired.debian)::')
        expected_result.append(
            '      "dummy_report" usebundle => _classes_noop("command_execution__bin_date");'
        )
        expected_result.append(
            '      "dummy_report" usebundle => log_rudder("Command execution /bin/date if !service_start_apache2_repaired.debian", "command_execution__bin_date", "${class_prefix}", @{args});'
        )
        expected_result.append('}')

        # Join all lines with \n
        result = '\n'.join(expected_result) + "\n"

        generated_result = ncf_rudder.generate_rudder_reporting(
            self.reporting_metadata)

        diff = self._unidiff_output(result, generated_result)

        if len(diff):
            print
            print "Test test_rudder_reporting_content failed, this is the diff between expected and actual result:"
            print diff

        self.assertEqual(result, generated_result)
Exemplo n.º 8
0
  def test_rudder_reporting_content(self):

    expected_result = []
    expected_result.append('bundle agent bla_rudder_reporting')
    expected_result.append('{')
    expected_result.append('  vars:')
    expected_result.append('    "args"               slist => {  };')
    expected_result.append('    "report_param"      string => join("_", args);')
    expected_result.append('    "full_class_prefix" string => canonify("bla_rudder_reporting_${report_param}");')
    expected_result.append('    "class_prefix"      string => string_head("${full_class_prefix}", "1000");')

    expected_result.append('')
    expected_result.append('  methods:')
    expected_result.append('')
    expected_result.append('    !(debian)::')
    expected_result.append('      "dummy_report" usebundle => _classes_noop("${class_prefix}_service_start_apache2");')
    expected_result.append('      "dummy_report_1" usebundle => _method_reporting_context("ph2", "apache2");')
    expected_result.append('      "dummy_report" usebundle => log_rudder("Service start apache2 if debian", "apache2", "${class_prefix}_service_start_apache2", "${class_prefix}_service_start_apache2", @{args});')
    expected_result.append('')
    expected_result.append('    !(service_start_apache2_repaired)::')
    expected_result.append('      "dummy_report" usebundle => _classes_noop("${class_prefix}_package_install_openssh_server");')
    expected_result.append('      "dummy_report_2" usebundle => _method_reporting_context("ph3", "openssh-server");')
    expected_result.append('      "dummy_report" usebundle => log_rudder("Package install openssh-server if service_start_apache2_repaired", "openssh-server", "${class_prefix}_package_install_openssh_server", "${class_prefix}_package_install_openssh_server", @{args});')
    expected_result.append('')
    expected_result.append('    !(!service_start_apache2_repaired.debian)::')
    expected_result.append('      "dummy_report" usebundle => _classes_noop("${class_prefix}_command_execution__bin_date");')
    expected_result.append('      "dummy_report_3" usebundle => _method_reporting_context("ph4", "/bin/date");')
    expected_result.append('      "dummy_report" usebundle => log_rudder("Command execution /bin/date if !service_start_apache2_repaired.debian", "/bin/date", "${class_prefix}_command_execution__bin_date", "${class_prefix}_command_execution__bin_date", @{args});')
    expected_result.append('}')

    # Join all lines with \n
    result = '\n'.join(expected_result)+"\n"

    generated_result = ncf_rudder.generate_rudder_reporting(self.reporting_metadata)

    diff = self._unidiff_output(result, generated_result)

    if len(diff):
        print()
        print("Test test_rudder_reporting_content failed, this is the diff between expected and actual result:")
        print(diff)

    self.assertEqual(result, generated_result)
Exemplo n.º 9
0
  def test_rudder_reporting_with_variable_content(self):


    expected_result = []
    expected_result.append('bundle agent Test_technique_with_variable_rudder_reporting')
    expected_result.append('{')
    expected_result.append('  methods:')
    expected_result.append('')
    expected_result.append('      "dummy_report" usebundle => _classes_noop("file_create_${sys.workdir}_module_env"),')
    expected_result.append('                    ifvarclass => concat("!(directory_create_",canonify("${sys.workdir}"),"_module_repaired)");')
    expected_result.append('      "dummy_report" usebundle => logger_rudder("Not applicable", "file_create_${sys.workdir}_module_env"),')
    expected_result.append('                    ifvarclass => concat("!(directory_create_",canonify("${sys.workdir}"),"_module_repaired)");')
    expected_result.append('}')

    # Join all lines with \n
    result = '\n'.join(expected_result)+"\n"

    generated_result = ncf_rudder.generate_rudder_reporting(self.reporting_with_var_metadata)

    self.assertEquals(result, generated_result)
Exemplo n.º 10
0
    def test_rudder_reporting_content(self):

        expected_result = []
        expected_result.append('bundle agent bla_rudder_reporting')
        expected_result.append('{')
        expected_result.append('  methods:')
        expected_result.append('')
        expected_result.append('    !(debian)::')
        expected_result.append(
            '      "dummy_report" usebundle => _classes_noop("service_start_apache2");'
        )
        expected_result.append(
            '      "dummy_report" usebundle => logger_rudder("Not applicable", "service_start_apache2");'
        )
        expected_result.append('')
        expected_result.append('    !(service_start_apache2_repaired)::')
        expected_result.append(
            '      "dummy_report" usebundle => _classes_noop("package_install_openssh_server");'
        )
        expected_result.append(
            '      "dummy_report" usebundle => logger_rudder("Not applicable", "package_install_openssh_server");'
        )
        expected_result.append('')
        expected_result.append(
            '    !(!service_start_apache2_repaired.debian)::')
        expected_result.append(
            '      "dummy_report" usebundle => _classes_noop("command_execution__bin_date");'
        )
        expected_result.append(
            '      "dummy_report" usebundle => logger_rudder("Not applicable", "command_execution__bin_date");'
        )
        expected_result.append('}')

        # Join all lines with \n
        result = '\n'.join(expected_result) + "\n"

        generated_result = ncf_rudder.generate_rudder_reporting(
            self.reporting_metadata)

        self.assertEqual(result, generated_result)
Exemplo n.º 11
0
  def test_rudder_reporting_content(self):

    expected_result = []
    expected_result.append('bundle agent bla_rudder_reporting')
    expected_result.append('{')
    expected_result.append('  vars:')
    expected_result.append('    "promisers"          slist => { @{this.callers_promisers}, cf_null }, policy => "ifdefined";')
    expected_result.append('    "class_prefix"      string => canonify(join("_", "promisers"));')
    expected_result.append('    "args"               slist => { };')
    expected_result.append('')
    expected_result.append('  methods:')
    expected_result.append('')
    expected_result.append('    !(debian)::')
    expected_result.append('      "dummy_report" usebundle => _classes_noop("service_start_apache2");')
    expected_result.append('      "dummy_report" usebundle => log_rudder("Service start apache2 if debian", "service_start_apache2", "${class_prefix}", @{args});')
    expected_result.append('')
    expected_result.append('    !(service_start_apache2_repaired)::')
    expected_result.append('      "dummy_report" usebundle => _classes_noop("package_install_openssh_server");')
    expected_result.append('      "dummy_report" usebundle => log_rudder("Package install openssh-server if service_start_apache2_repaired", "package_install_openssh_server", "${class_prefix}", @{args});')
    expected_result.append('')
    expected_result.append('    !(!service_start_apache2_repaired.debian)::')
    expected_result.append('      "dummy_report" usebundle => _classes_noop("command_execution__bin_date");')
    expected_result.append('      "dummy_report" usebundle => log_rudder("Command execution /bin/date if !service_start_apache2_repaired.debian", "command_execution__bin_date", "${class_prefix}", @{args});')
    expected_result.append('}')

    # Join all lines with \n
    result = '\n'.join(expected_result)+"\n"

    generated_result = ncf_rudder.generate_rudder_reporting(self.reporting_metadata)

    diff = self._unidiff_output(result, generated_result)

    if len(diff):
        print
        print "Test test_rudder_reporting_content failed, this is the diff between expected and actual result:"
        print diff

    self.assertEqual(result, generated_result)
Exemplo n.º 12
0
 def test_rudder_reporting_from_technique(self):
   """The rudder-reporting.cf content generated from a ncf technique must match the reporting we expect for our technique"""
   rudder_reporting_string = ncf_rudder.generate_rudder_reporting(self.technique_metadata)
   expected_rudder_reporting = self.rudder_reporting_content
   self.assertEqual(expected_rudder_reporting.split("\n"), rudder_reporting_string.split("\n"))