-
Notifications
You must be signed in to change notification settings - Fork 6
/
dnsping.txtar
86 lines (68 loc) · 2.23 KB
/
dnsping.txtar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# testscript framework tests for dnsping command line
# Basic usage test
!dnsping
!stdout .
stderr 'Exactly 2 arguments expected, got 0'
# (short) version
dnsping version
stdout '^dev$'
!stderr .
# (long) version
dnsping buildinfo
stdout '^dev go'
stdout 'path fortio.org/dnsping'
!stderr .
# bad -q type
!dnsping -q foo www.google.com 8.8.8.8
!stdout .
stderr '\[F\] Invalid -q type name "foo", should be one of'
# good -q type
dnsping -c 1 -q aaaa www.google.com 8.8.8.8
stderr 'IN\tAAAA'
stdout '0 errors'
# ipv6 server
dnsping -c 1 www.google.com 2001:4860:4860::8888
stderr 'Adding \[] around detected input IPv6 server ip info: \[2001:4860:4860::8888]'
# -foo (bad flag)
!dnsping -foo
!stdout .
stderr 'flag provided but not defined: -foo'
# basic test
dnsping -c 2 www.google.com 8.8.8.8
stderr 'will query 2 times, sleeping 1s in between, the server 8\.8\.8\.8:53 for A \(1\) record for www\.google\.com\.'
stdout '0 errors \(0.00%\), 2 success.'
# fixed id
dnsping -loglevel debug -c 1 -fixed-id 42 www.google.com 8.8.8.8
stderr 'id: 42'
# sequential id
dnsping -loglevel debug -c 2 -sequential-id www.google.com 8.8.8.8
stderr 'id: 1'
stderr 'id: 2'
# error (without plural)
dnsping -c 1 doesnnotexist.fortio.org 8.8.8.8
stdout '1 error \(100.00%\), 0 success.'
stderr 'server error'
!stderr '1: \[]'
# json stdout
dnsping -c 1 -json - www.google.com 8.8.8.8
stdout '"HowMany": 1,'
stderr 'Successfully wrote .* bytes of Json data to stdout'
# json can't write to file
[unix] chmod 000 notwriteable.json
[unix] !dnsping -c 1 -json notwriteable.json www.google.com 8.8.8.8
[unix] stderr '\[F\] Unable to create notwriteable.json: open notwriteable.json: permission denied'
# windows workaround for chmod etc...
[windows] dnsping -c 1 -json notwriteable.json www.google.com 8.8.8.8
# how to do this without pkill?
[unix] dnsping www.google.com 8.8.8.8 &
[unix] exec sleep 3
[unix] exec pkill -x dnsping # todo want something like kill %1 instead
[unix] wait
[unix] stderr 'will query until interrupted'
[unix] stdout '0 errors \(0.00%\), [34] success.'
# json writing to file
dnsping -c 1 -json ok.json www.google.com 8.8.8.8
stderr 'Successfully wrote .* bytes of Json data to ok\.json'
grep '"Server": "8.8.8.8:53",' ok.json
-- notwriteable.json --
empty