From c5a4086ed73cff81423e99f0536f04779b0a5c92 Mon Sep 17 00:00:00 2001 From: Mike Wiebe Date: Wed, 11 Sep 2019 10:10:14 -0400 Subject: [PATCH] Add proper hostname cleanup for nxos tests (#61810) --- .../targets/nxos_config/tasks/main.yaml | 17 ++++++++++++++--- .../targets/nxos_smoke/tasks/main.yaml | 15 +++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/test/integration/targets/nxos_config/tasks/main.yaml b/test/integration/targets/nxos_config/tasks/main.yaml index 82ce6f12b29..f882511828c 100644 --- a/test/integration/targets/nxos_config/tasks/main.yaml +++ b/test/integration/targets/nxos_config/tasks/main.yaml @@ -1,4 +1,15 @@ --- -- { include: cli.yaml, tags: ['cli'] } -- { include: nxapi.yaml, tags: ['nxapi'] } -- { include: cli_config.yaml, tags: ['cli_config'] } +# Some of the tests in this suite change the hostname to switch. +# This block/always ensures the hostname gets changed back to +# the correct name. +- block: + - { include: cli.yaml, tags: ['cli'] } + - { include: nxapi.yaml, tags: ['nxapi'] } + - { include: cli_config.yaml, tags: ['cli_config'] } + + always: + - name: "Change hostname back to {{ inventory_hostname_short }}" + nxos_config: + lines: + - "hostname {{ inventory_hostname_short }}" + match: none diff --git a/test/integration/targets/nxos_smoke/tasks/main.yaml b/test/integration/targets/nxos_smoke/tasks/main.yaml index 4b0f8c64d90..b165a5f6e11 100644 --- a/test/integration/targets/nxos_smoke/tasks/main.yaml +++ b/test/integration/targets/nxos_smoke/tasks/main.yaml @@ -1,3 +1,14 @@ --- -- { include: cli.yaml, tags: ['cli'] } -- { include: nxapi.yaml, tags: ['nxapi'] } +# Some of the tests in this suite change the hostname to switch. +# This block/always ensures the hostname gets changed back to +# the correct name. +- block: + - { include: cli.yaml, tags: ['cli'] } + - { include: nxapi.yaml, tags: ['nxapi'] } + + always: + - name: "Change hostname back to {{ inventory_hostname_short }}" + nxos_config: + lines: + - "hostname {{ inventory_hostname_short }}" + match: none