Robot Framework 사용해보기④
7697 단어 centos7robotframework
원격 호스트에서 명령을 실행해보십시오 (3 번째)
Robot Framework 사용해보기①
하고 싶은 것의 3번째:vyos→vyos2에의 ping을 실행해 100% 성공하는 것을 확인한다에 도전한다.
show version 때와 같은 느낌으로 갈 것 같다.
우선 수동.
vyos@vyos:~$ ping 172.17.0.3 count 5
PING 172.17.0.3 (172.17.0.3) 56(84) bytes of data.
64 bytes from 172.17.0.3: icmp_req=1 ttl=64 time=0.064 ms
64 bytes from 172.17.0.3: icmp_req=2 ttl=64 time=0.092 ms
64 bytes from 172.17.0.3: icmp_req=3 ttl=64 time=0.094 ms
64 bytes from 172.17.0.3: icmp_req=4 ttl=64 time=0.056 ms
64 bytes from 172.17.0.3: icmp_req=5 ttl=64 time=0.096 ms
--- 172.17.0.3 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3999ms
rtt min/avg/max/mdev = 0.056/0.080/0.096/0.018 ms
vyos@vyos:~$
Write & Read until
test06.robot# cat test06.robot
*** Settings ***
Library SSHLibrary
*** Variables ***
${user} vyos
${password} vyos
${ip1} 172.17.0.2
${ip2} 172.17.0.3
*** Test Cases ***
ssh test of vyos
vyosに接続
vyosにログイン
${output} = Execute Command echo SSH to vyos is OK!
Log To Console ${\n}${output}
Should Be Equal ${output} SSH to vyos is OK!
ping test
Write ping 172.17.0.3 count 5
${out} = Read Until ~$
Should Contain ${out} 0% packet loss
Close All Connections
*** Keywords ***
vyosに接続
Open Connection ${ip1}
vyosにログイン
Login ${user} ${password}
#
에서 실행.
결과# robot test06.robot
==============================================================================
Test06
==============================================================================
ssh test of vyos ...
SSH to vyos is OK!
ssh test of vyos | PASS |
------------------------------------------------------------------------------
ping test | FAIL |
No match found for '~$' in 3 seconds
Output:
PING 172.17.0.3 (172.17.0.3) 56(84) bytes of data.
64 bytes from 172.17.0.3: icmp_req=1 ttl=64 time=0.105 ms
64 bytes from 172.17.0.3: icmp_req=2 ttl=64 time=0.091 ms
64 bytes from 172.17.0.3: icmp_req=3 ttl=64 time=0.083 ms
.
------------------------------------------------------------------------------
Test06 | FAIL |
2 critical tests, 1 passed, 1 failed
2 tests total, 1 passed, 1 failed
==============================================================================
Output: /root/output.xml
Log: /root/log.html
Report: /root/report.html
#
FAIL 출력의 3초내에 ~$ 가 없다고 말해지고 있는구나. . .
3s 이내에 처리가 끝나도록,,,
ping test
Write ping 172.17.0.3 count 2
${out} = Read Until ~$
Should Contain ${out} 0% packet loss
Close All Connections
에서 다시 실행.
# robot test06.robot
==============================================================================
Test06
==============================================================================
ssh test of vyos ...
SSH to vyos is OK!
ssh test of vyos | PASS |
------------------------------------------------------------------------------
ping test | PASS |
------------------------------------------------------------------------------
Test06 | PASS |
2 critical tests, 2 passed, 0 failed
2 tests total, 2 passed, 0 failed
==============================================================================
Output: /root/output.xml
Log: /root/log.html
Report: /root/report.html
#
좋아 PASS했다.
그리고 timeout 값을 늘리면 괜찮습니다.
Timeout
Argument timeout is used by Read Until variants. The default value is 3 seconds. See time
format below for supported timeout syntax.
Time format
All timeouts, delays or retry intervals can be given as numbers considered seconds (e.g. 0.5 or 42) or in Robot Framework's time syntax (e.g. 1.5 seconds or 1 min 30 s). For more information about the Time syntax .
데포 3s로 변경도 할 수 있을 것 같다.
*** Settings ***
Library SSHLibrary
Test Timeout 30
Test Case의 timeout을 30s로 재실행
# robot test06.robot
==============================================================================
Test06
==============================================================================
ssh test of vyos ...
SSH to vyos is OK!
ssh test of vyos | PASS |
------------------------------------------------------------------------------
ping test | FAIL |
No match found for '~$' in 3 seconds
Output:
PING 172.17.0.3 (172.17.0.3) 56(84) bytes of data.
64 bytes from 172.17.0.3: icmp_req=1 ttl=64 time=0.063 ms
64 bytes from 172.17.0.3: icmp_req=2 ttl=64 time=0.053 ms
64 bytes from 172.17.0.3: icmp_req=3 ttl=64 time=0.098 ms
.
------------------------------------------------------------------------------
Test06 | FAIL |
2 critical tests, 1 passed, 1 failed
2 tests total, 1 passed, 1 failed
==============================================================================
Output: /root/output.xml
Log: /root/log.html
Report: /root/report.html
#
응? ? ? 효과가 없다. . . 왠지 장절한 착각하고 있니? ? ?
타임 아웃 초과의 메세지는 Test timeout exceeded 라고 쓰고 있지만 출력 다르다. . .
google 선생님에게 물어봐도 가르쳐주지 마. . . .
포기하는 것도 필요할까.
그 밖에 사용할 수 있을 것 같은 것을 치트 시트로 찾으자. . .
Builtin에는 sleep 있다.
ping 실행하고 나서 저장 기다리면 좋을까?
test06.robot# cat test06.robot
*** Settings ***
Library SSHLibrary
*** Variables ***
${user} vyos
${password} vyos
${ip1} 172.17.0.2
${ip2} 172.17.0.3
*** Test Cases ***
ssh test of vyos
vyosに接続
vyosにログイン
${output} = Execute Command echo SSH to vyos is OK!
Log To Console ${\n}${output}
Should Be Equal ${output} SSH to vyos is OK!
ping test
Write ping 172.17.0.3 count 5
sleep 10
${out} = Read Until ~$
Should Contain ${out} 0% packet loss
Close All Connections
*** Keywords ***
vyosに接続
Open Connection ${ip1}
vyosにログイン
Login ${user} ${password}
#
실행
결과# robot test06.robot
==============================================================================
Test06
==============================================================================
ssh test of vyos ...
SSH to vyos is OK!
ssh test of vyos | PASS |
------------------------------------------------------------------------------
ping test | PASS |
------------------------------------------------------------------------------
Test06 | PASS |
2 critical tests, 2 passed, 0 failed
2 tests total, 2 passed, 0 failed
==============================================================================
Output: /root/output.xml
Log: /root/log.html
Report: /root/report.html
#
PASS했다.
일단 해보고 싶은 것은 할 수 있었구나.
Reference
이 문제에 관하여(Robot Framework 사용해보기④), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/navasato/items/345af005b79d54dc717c
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
vyos@vyos:~$ ping 172.17.0.3 count 5
PING 172.17.0.3 (172.17.0.3) 56(84) bytes of data.
64 bytes from 172.17.0.3: icmp_req=1 ttl=64 time=0.064 ms
64 bytes from 172.17.0.3: icmp_req=2 ttl=64 time=0.092 ms
64 bytes from 172.17.0.3: icmp_req=3 ttl=64 time=0.094 ms
64 bytes from 172.17.0.3: icmp_req=4 ttl=64 time=0.056 ms
64 bytes from 172.17.0.3: icmp_req=5 ttl=64 time=0.096 ms
--- 172.17.0.3 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3999ms
rtt min/avg/max/mdev = 0.056/0.080/0.096/0.018 ms
vyos@vyos:~$
# cat test06.robot
*** Settings ***
Library SSHLibrary
*** Variables ***
${user} vyos
${password} vyos
${ip1} 172.17.0.2
${ip2} 172.17.0.3
*** Test Cases ***
ssh test of vyos
vyosに接続
vyosにログイン
${output} = Execute Command echo SSH to vyos is OK!
Log To Console ${\n}${output}
Should Be Equal ${output} SSH to vyos is OK!
ping test
Write ping 172.17.0.3 count 5
${out} = Read Until ~$
Should Contain ${out} 0% packet loss
Close All Connections
*** Keywords ***
vyosに接続
Open Connection ${ip1}
vyosにログイン
Login ${user} ${password}
#
# robot test06.robot
==============================================================================
Test06
==============================================================================
ssh test of vyos ...
SSH to vyos is OK!
ssh test of vyos | PASS |
------------------------------------------------------------------------------
ping test | FAIL |
No match found for '~$' in 3 seconds
Output:
PING 172.17.0.3 (172.17.0.3) 56(84) bytes of data.
64 bytes from 172.17.0.3: icmp_req=1 ttl=64 time=0.105 ms
64 bytes from 172.17.0.3: icmp_req=2 ttl=64 time=0.091 ms
64 bytes from 172.17.0.3: icmp_req=3 ttl=64 time=0.083 ms
.
------------------------------------------------------------------------------
Test06 | FAIL |
2 critical tests, 1 passed, 1 failed
2 tests total, 1 passed, 1 failed
==============================================================================
Output: /root/output.xml
Log: /root/log.html
Report: /root/report.html
#
ping test
Write ping 172.17.0.3 count 2
${out} = Read Until ~$
Should Contain ${out} 0% packet loss
Close All Connections
# robot test06.robot
==============================================================================
Test06
==============================================================================
ssh test of vyos ...
SSH to vyos is OK!
ssh test of vyos | PASS |
------------------------------------------------------------------------------
ping test | PASS |
------------------------------------------------------------------------------
Test06 | PASS |
2 critical tests, 2 passed, 0 failed
2 tests total, 2 passed, 0 failed
==============================================================================
Output: /root/output.xml
Log: /root/log.html
Report: /root/report.html
#
*** Settings ***
Library SSHLibrary
Test Timeout 30
# robot test06.robot
==============================================================================
Test06
==============================================================================
ssh test of vyos ...
SSH to vyos is OK!
ssh test of vyos | PASS |
------------------------------------------------------------------------------
ping test | FAIL |
No match found for '~$' in 3 seconds
Output:
PING 172.17.0.3 (172.17.0.3) 56(84) bytes of data.
64 bytes from 172.17.0.3: icmp_req=1 ttl=64 time=0.063 ms
64 bytes from 172.17.0.3: icmp_req=2 ttl=64 time=0.053 ms
64 bytes from 172.17.0.3: icmp_req=3 ttl=64 time=0.098 ms
.
------------------------------------------------------------------------------
Test06 | FAIL |
2 critical tests, 1 passed, 1 failed
2 tests total, 1 passed, 1 failed
==============================================================================
Output: /root/output.xml
Log: /root/log.html
Report: /root/report.html
#
# cat test06.robot
*** Settings ***
Library SSHLibrary
*** Variables ***
${user} vyos
${password} vyos
${ip1} 172.17.0.2
${ip2} 172.17.0.3
*** Test Cases ***
ssh test of vyos
vyosに接続
vyosにログイン
${output} = Execute Command echo SSH to vyos is OK!
Log To Console ${\n}${output}
Should Be Equal ${output} SSH to vyos is OK!
ping test
Write ping 172.17.0.3 count 5
sleep 10
${out} = Read Until ~$
Should Contain ${out} 0% packet loss
Close All Connections
*** Keywords ***
vyosに接続
Open Connection ${ip1}
vyosにログイン
Login ${user} ${password}
#
# robot test06.robot
==============================================================================
Test06
==============================================================================
ssh test of vyos ...
SSH to vyos is OK!
ssh test of vyos | PASS |
------------------------------------------------------------------------------
ping test | PASS |
------------------------------------------------------------------------------
Test06 | PASS |
2 critical tests, 2 passed, 0 failed
2 tests total, 2 passed, 0 failed
==============================================================================
Output: /root/output.xml
Log: /root/log.html
Report: /root/report.html
#
Reference
이 문제에 관하여(Robot Framework 사용해보기④), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/navasato/items/345af005b79d54dc717c텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)