Skip to content

Instantly share code, notes, and snippets.

@kskmori
Last active September 11, 2019 10:00
Show Gist options
  • Save kskmori/65a715627be207c3353cd31bad485a8c to your computer and use it in GitHub Desktop.
Save kskmori/65a715627be207c3353cd31bad485a8c to your computer and use it in GitHub Desktop.
OCFT test case for IPaddr2 IPv6 address sanitization
# IPaddr2-ipv6-sanitize
#
# usage:
# ocft make -d . IPaddr2-ipv6-sanitize
# ocft test -v -X IPaddr2-ipv6-sanitize
#
# inspect log files:
# /var/lib/resource-agents/ocft/cases/logs/IPaddr2-ipv6-sanitize.log
# /var/lib/heartbeat/trace_ra/IPaddr2/*
CONFIG
Agent IPaddr2
#Agent IPaddr2-ipv6-sanitize
AgentRoot /usr/lib/ocf/resource.d/heartbeat
HangTimeout 20
VARIABLE
OCFT_target_nic=ocft0
OCFT_target_prefix=64
SETUP-AGENT
modprobe dummy
CLEANUP-AGENT
modprobe -r dummy
CASE-BLOCK init_nic_reachable
Bash ip link delete $OCFT_target_nic 2> /dev/null || true
Bash ip link add $OCFT_target_nic type dummy
Bash ip link set $OCFT_target_nic up
Bash ip addr add 2001:db8::ffff/$OCFT_target_prefix dev $OCFT_target_nic
CASE-BLOCK init_nic_unreachable
Bash ip link delete $OCFT_target_nic 2> /dev/null || true
Bash ip link add $OCFT_target_nic type dummy
Bash ip link set $OCFT_target_nic up
CASE-BLOCK required_args
# ip is required and should be set for each test cases
# Env OCF_RESKEY_ip=2001:db8::1
Env OCF_RESKEY_nic=$OCFT_target_nic
Env OCF_RESKEY_cidr_netmask=$OCFT_target_prefix
CASE-BLOCK prepare
Include init_nic_reachable
Include required_args
# CASE 0
CASE "normal: already sanitized address"
Include prepare
Env OCF_RESKEY_ip=2001:db8::1
AgentRun start OCF_SUCCESS
AgentRun monitor OCF_SUCCESS
AgentRun stop OCF_SUCCESS
AgentRun monitor OCF_NOT_RUNNING
# CASE 1
CASE "rewrite: RFC5952 4.1 - Leading Zeros"
Include prepare
Env OCF_RESKEY_ip=2001:db8::0001
AgentRun start OCF_SUCCESS
AgentRun monitor OCF_SUCCESS
AgentRun stop OCF_SUCCESS
AgentRun monitor OCF_NOT_RUNNING
# CASE 2
CASE "rewrite: RFC5952 4.2.1 - Shorten as much as possible"
Include prepare
Env OCF_RESKEY_ip=2001:db8:0:0:0:0:2:1
AgentRun start OCF_SUCCESS
AgentRun monitor OCF_SUCCESS
AgentRun stop OCF_SUCCESS
AgentRun monitor OCF_NOT_RUNNING
# CASE 3
CASE "rewrite: RFC5952 4.2.2 - One 0 Field"
Include prepare
Env OCF_RESKEY_ip=2001:db8::1:1:1:1:1
AgentRun start OCF_SUCCESS
AgentRun monitor OCF_SUCCESS
AgentRun stop OCF_SUCCESS
AgentRun monitor OCF_NOT_RUNNING
# CASE 4
CASE "rewrite: RFC5952 4.2.3 - Choice in placement of ::"
Include prepare
Env OCF_RESKEY_ip=2001:db8:0:0:1::1
AgentRun start OCF_SUCCESS
AgentRun monitor OCF_SUCCESS
AgentRun stop OCF_SUCCESS
AgentRun monitor OCF_NOT_RUNNING
# CASE 5
CASE "rewrite: RFC5952 4.3 - Lowercase"
Include prepare
Env OCF_RESKEY_ip=2001:DB8::1
AgentRun start OCF_SUCCESS
AgentRun monitor OCF_SUCCESS
AgentRun stop OCF_SUCCESS
AgentRun monitor OCF_NOT_RUNNING
# CASE 6
CASE "different notations should be treated as the same"
Include prepare
Env OCF_RESKEY_ip=2001:db8::1
AgentRun start OCF_SUCCESS
AgentRun monitor OCF_SUCCESS
Env OCF_RESKEY_ip=2001:db8::0001
AgentRun monitor OCF_SUCCESS
Env OCF_RESKEY_ip=2001:db8::1
AgentRun stop OCF_SUCCESS
AgentRun monitor OCF_NOT_RUNNING
Env OCF_RESKEY_ip=2001:db8::0001
AgentRun monitor OCF_NOT_RUNNING
# CASE 7
CASE "error: invalid address format"
Include prepare
Env OCF_RESKEY_ip=2001:db8:::1
AgentRun start OCF_ERR_GENERIC
#AgentRun start OCF_ERR_CONFIGURED
# CASE 8
CASE "rewrite: unreachable route"
Include init_nic_unreachable
Include required_args
Env OCF_RESKEY_ip=2001:db8::0001
AgentRun start OCF_SUCCESS
AgentRun monitor OCF_SUCCESS
AgentRun stop OCF_SUCCESS
AgentRun monitor OCF_NOT_RUNNING
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment