Project

General

Profile

Actions

Bug #7528

closed

Extend tests for non-existant files with file_remove

Added by Florian Heigl almost 9 years ago. Updated over 2 years ago.

Status:
Released
Priority:
N/A
Category:
Generic methods
Target version:
Severity:
UX impact:
User visibility:
Effort required:
Priority:
0
Name check:
Fix check:
Regression:

Description

Hi,

we've seen an issue with a missing report from "file_remove", depending on rudder agent version.

If the file in question does not exist, it'll NOT run success_if_nothing.

For ref:

bundle agent file_remove(target)
{
  vars:
    "class_prefix" string => canonify("file_remove_${target}");

  files:
    "${target}" 
      delete        => tidy,
      classes       => classes_generic("${class_prefix}");

  methods:
    "success_if_nothing" usebundle => _classes_success("${class_prefix}"),
                         ifvarclass => "!${class_prefix}_reached";

    "report" usebundle  => _logger("Remove file ${target}", "${class_prefix}");

}

Our directive is called leap_second_something

CFEngine Core 3.6.3

node:~ # cf-agent -KI | grep leap
node:~ # 

On 3.6.0 you will see output from this and a report will be sent.

In debug (cf-agent --debug 2>&1 | grep leap) both report the same stuff.

Please let me know if you can't reproduce it.

Actions #1

Updated by Jonathan CLARKE almost 9 years ago

  • Project changed from Rudder to 41
  • Description updated (diff)
  • Target version set to 0.x

Adding "pre" tags for readability, and moving to the ncf project.

Actions #2

Updated by Jonathan CLARKE almost 9 years ago

  • Status changed from New to In progress
  • Assignee set to Jonathan CLARKE
Actions #3

Updated by Jonathan CLARKE almost 9 years ago

  • Status changed from In progress to Discussion
  • Assignee changed from Jonathan CLARKE to Florian Heigl

I can't reproduce this. I'm using CFEngine 3.6.3 as you suggested:

$ cf-agent -V
CFEngine Core 3.6.3

I'm testing file_remove on a non-existant filename - I think this is right?
However, I'm getting the right reports.

I've written a test to check for this, that you can get in this PR: https://github.com/Normation/ncf/pull/278

Would you run it for me? Steps should be quite simple:

Please let me know if this test passes or fails for you on one a machine where you're seeing this issue.

Actions #4

Updated by Jonathan CLARKE almost 9 years ago

Florian Heigl wrote:

If the file in question does not exist, it'll NOT run success_if_nothing.

By the way, this is by design:

     .........................................................
      Promise's handle: ''
      Promise made by: '/tmp/nonexistantfilenamefromncftests'
     .........................................................
...
File '/tmp/nonexistantfilenamefromncftests' does not exist as promised
Defining promise result class 'file_remove__tmp_nonexistantfilenamefromncftests_kept'
Defining promise result class 'file_remove__tmp_nonexistantfilenamefromncftests_ok'
Defining promise result class 'file_remove__tmp_nonexistantfilenamefromncftests_not_repaired'
Defining promise result class 'file_remove__tmp_nonexistantfilenamefromncftests_reached'

As you can see, the required result classes are already defined by CFEngine, so we don't need to explicitly create them.

Actions #5

Updated by Florian Heigl almost 9 years ago

I need to look at this in a isolated env.
Something was off, otherwise we'd not have gone digging into this - we started from a missing report.

Ah, just saw you made a test for it - wow. We'll start from that.

Actions #6

Updated by Jonathan CLARKE almost 9 years ago

Hey Florian - just a friendly ping to see if you were able to run the test and/or reproduce this issue yet?

Actions #7

Updated by Florian Heigl almost 9 years ago

hi,

colleague ran the test case.
I'll ask him to also update the ticket.

Actions #8

Updated by Ferenc Ulrich almost 9 years ago

Hi Jonathan,

I ran the test and got the following result:

@server:~/ncf_test/tests/acceptance # ./testall 30_generic_methods/file_remove.cf

=== Test environment: ===
AGENT=
CF_PROMISES=
CF_SERVERD=
CF_KEY= =========================

======================================================================
Testsuite started at 2015-12-03 16:47:52
----------------------------------------------------------------------
Total tests: 1

./30_generic_methods/file_remove.cf Pass

======================================================================
Testsuite finished at 2015-12-03 16:47:53 (1 seconds)

Passed tests: 1
Failed tests: 0
Failed to crash tests: 0
Skipped tests: 0
server:~/ncf_test/tests/acceptance # cat test.log ======================================================================
Testsuite started at 2015-12-03 16:47:52
----------------------------------------------------------------------
Total tests: 1

----------------------------------------------------------------------
./30_generic_methods/file_remove.cf
----------------------------------------------------------------------
R: First test OK (removing existing file, /root/ncf_test/tests/acceptance/workdir/__30_generic_methods_file_remove_cf/tmp/remove_test)
R: Second test OK (removing a non existant file, root_ncf_test_tests_acceptance_workdir__30_generic_methods_file_remove_cf_tmp_nonexistantfilenamefromncftests)
R: /root/ncf_test/tests/acceptance/./30_generic_methods/file_remove.cf Pass

Return code is 0.

> Pass ====================================================================
Testsuite finished at 2015-12-03 16:47:53 (1 seconds)

Passed tests: 1
Failed tests: 0
Failed to crash tests: 0
Skipped tests: 0
server:~/ncf_test/tests/acceptance #@

Actions #9

Updated by Jonathan CLARKE over 8 years ago

  • Status changed from Discussion to Pending technical review
  • Assignee changed from Florian Heigl to Benoît PECCATTE
  • Pull Request set to https://github.com/Normation/ncf/pull/351
Actions #10

Updated by Jonathan CLARKE over 8 years ago

  • Subject changed from Missing report from NCF depending on cf-agent version (yay) to Extend tests for non-existant files with file_remove

Thanks for the test results. This shows there is no bug, I guess it came from something else. Please reopen this ticket if it occurs again.

In the meantime, I'm going to add the test case I previously proposed as a regular test, so we can detect any similar problems in the future.

Actions #11

Updated by Jonathan CLARKE over 8 years ago

  • Status changed from Pending technical review to Pending release
  • % Done changed from 0 to 100

Applied in changeset commit:a779c1156effb7063b303662cc89dae17f0cd5a8.

Actions #12

Updated by Vincent MEMBRÉ about 8 years ago

  • Status changed from Pending release to Released
Actions #13

Updated by Alexis Mousset over 2 years ago

  • Target version changed from 0.x to ncf-0.x
  • Priority set to 0
Actions #14

Updated by Alexis Mousset over 2 years ago

  • Project changed from 41 to Rudder
  • Category set to Generic methods
Actions

Also available in: Atom PDF