sonic-net / sonic-mgmt

Configuration management examples for SONiC
Other
196 stars 716 forks source link

[Everflow]: Testfails as variable is not defined #334

Open chitra-raghavan opened 6 years ago

chitra-raghavan commented 6 years ago

Everflow testcase in ptf topology fails in middle of execution that ansible_date_time is not defined. script : ansible/roles/test/tasks/everflow/config_test/config_test.yml The script executes few test cases from config_test.yml. After some 5-6 testcases , it terminates saying that the variable "ansible_date_time" is not defined.

For initial testcases , the variable "ansible_date_time" is defined and didn't see any issues. It fails when it executes 6th testcase

When i comment the initial 5 testcases and run the script , it runs for 6-10 testcases, but failed in 11th testcase with same error.

snip from log :

TASK [test : debug] ************************************************************
Monday 06 November 2017  10:11:15 +0000 (0:00:00.877)       0:11:43.494 *******
ok: [sonic-s6100-01] => {
    "ansible_date_time": "VARIABLE IS NOT DEFINED!"
}

TASK [test : include_vars] *****************************************************
Monday 06 November 2017  10:11:15 +0000 (0:00:00.110)       0:11:43.605 *******
ok: [sonic-s6100-01]

TASK [test : debug] ************************************************************
Monday 06 November 2017  10:11:16 +0000 (0:00:00.207)       0:11:43.812 *******
ok: [sonic-s6100-01] => {
    "testname_unique": "VARIABLE IS NOT DEFINED!"
}

TASK [test : set_fact] *********************************************************
Monday 06 November 2017  10:11:17 +0000 (0:00:00.150)       0:11:45.202 *******
fatal: [sonic-s6100-01]: FAILED! => {"failed": true, "msg": "ERROR! The conditional check 'testname_unique is not defined' failed. The error was: ERROR! error while evaluating conditional (testname_unique is not defined): ERROR! ERROR! 'ansible_date_time' is undefined\n\nThe error appears to have been in '/var/johnar/sonic-mgmt/ansible/roles/test/files/tools/loganalyzer/loganalyzer_init.yml': line 20, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- set_fact:\n  ^ here\n"}

In Previous testcases , the ansible_date_time variable is defined and the script proceeded fine.

TASK [test : Config tests - invalid GRE type (value > that min bound).] ********
Monday 06 November 2017  10:09:11 +0000 (0:00:40.097)       0:09:38.847 *******
included: /var/johnar/sonic-mgmt/ansible/roles/test/tasks/run_config_test.yml for sonic-s6100-01

TASK [test : debug] ************************************************************
Monday 06 November 2017  10:09:12 +0000 (0:00:00.971)       0:09:39.819 *******
ok: [sonic-s6100-01] => {
    "ansible_date_time": {
        "date": "2017-11-06",
        "day": "06",
        "epoch": "1509961043",
        "hour": "09",
        "iso8601": "2017-11-06T09:37:23Z",
        "iso8601_basic": "20171106T093723342566",
        "iso8601_basic_short": "20171106T093723",
        "iso8601_micro": "2017-11-06T09:37:23.342745Z",
        "minute": "37",
        "month": "11",
        "second": "23",
        "time": "09:37:23",
        "tz": "UTC",
        "tz_offset": "+0000",
        "weekday": "Monday",
        "weekday_number": "1",
        "weeknumber": "45",
        "year": "2017"
    }
}

TASK [test : include_vars] *****************************************************
Monday 06 November 2017  10:09:12 +0000 (0:00:00.125)       0:09:39.945 *******
ok: [sonic-s6100-01]

TASK [test : debug] ************************************************************
Monday 06 November 2017  10:09:12 +0000 (0:00:00.205)       0:09:40.150 *******
ok: [sonic-s6100-01] => {
    "testname_unique": "config_test.2017-11-06.09:37:23"
}

    TASK [test : set_fact] *********************************************************
    Monday 06 November 2017  10:11:17 +0000 (0:00:00.150)       0:11:45.202 *******
    fatal: [sonic-s6100-01]: FAILED! => {"failed": true, "msg": "ERROR! The conditional check 'testname_unique is not defined' failed. The error was: ERROR! error while evaluating conditional (testname_unique is not defined): ERROR! ERROR! 'ansible_date_time' is undefined\n\nThe error appears to have been in '/var/johnar/sonic-mgmt/ansible/roles/test/files/tools/loganalyzer/loganalyzer_init.yml': line 20, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- set_fact:\n  ^ here\n"}
dawnbeauty commented 6 years ago

It's due to timout of ansible facts. You may check the ansible.cfg:

 fact_caching = jsonfile
  fact_caching_connection = ~/.ansible/cache
  fact_caching_timeout = 600

According to your log, the last time the script proceeded ok is "0:09:39.819" and failed time is "0:11:45.202". Just change fact_caching_timeout to 3600 or any time you want.

maggiemsft commented 6 years ago

either try to change ansible.cfg gathering=implicit

or add : gather_facts: True for playbooks that depends on ansible_facts, like loganalyzer related playbooks.

I'll try to fix this later.