[VOL-5486] Fix deprecated versions

Change-Id: If0b888d6c2f33b2f415c8b03b08dc994bb3df3f4
Signed-off-by: Abhay Kumar <abhay.kumar@radisys.com>
diff --git a/vendor/go.etcd.io/gofail/runtime/failpoint.go b/vendor/go.etcd.io/gofail/runtime/failpoint.go
new file mode 100644
index 0000000..ea8db3f
--- /dev/null
+++ b/vendor/go.etcd.io/gofail/runtime/failpoint.go
@@ -0,0 +1,86 @@
+// Copyright 2016 CoreOS, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package runtime
+
+import (
+	"fmt"
+	"sync"
+)
+
+type Failpoint struct {
+	t   *terms
+	mux sync.RWMutex
+}
+
+func NewFailpoint(name string) *Failpoint {
+	return register(name)
+}
+
+// Acquire gets evalutes the failpoint terms; if the failpoint
+// is active, it will return a value. Otherwise, returns a non-nil error.
+//
+// Notice that during the exection of Acquire(), the failpoint can be disabled,
+// but the already in-flight execution won't be terminated
+func (fp *Failpoint) Acquire() (interface{}, error) {
+	fp.mux.RLock()
+	// terms are locked during execution, so deepcopy is not required as no change can be made during execution
+	cachedT := fp.t
+	fp.mux.RUnlock()
+
+	if cachedT == nil {
+		return nil, ErrDisabled
+	}
+	result := cachedT.eval()
+	if result == nil {
+		return nil, ErrDisabled
+	}
+	return result, nil
+}
+
+// BadType is called when the failpoint evaluates to the wrong type.
+func (fp *Failpoint) BadType(v interface{}, t string) {
+	fmt.Printf("failpoint: %q got value %v of type \"%T\" but expected type %q\n", fp.t.fpath, v, v, t)
+}
+
+func (fp *Failpoint) SetTerm(t *terms) {
+	fp.mux.Lock()
+	defer fp.mux.Unlock()
+
+	fp.t = t
+}
+
+func (fp *Failpoint) ClearTerm() error {
+	fp.mux.Lock()
+	defer fp.mux.Unlock()
+
+	if fp.t == nil {
+		return ErrDisabled
+	}
+	fp.t = nil
+
+	return nil
+}
+
+func (fp *Failpoint) Status() (string, int, error) {
+	fp.mux.RLock()
+	defer fp.mux.RUnlock()
+
+	t := fp.t
+	if t == nil {
+		return "", 0, ErrDisabled
+	}
+
+	return t.desc, t.counter, nil
+}
diff --git a/vendor/go.etcd.io/gofail/runtime/http.go b/vendor/go.etcd.io/gofail/runtime/http.go
new file mode 100644
index 0000000..84ecaf7
--- /dev/null
+++ b/vendor/go.etcd.io/gofail/runtime/http.go
@@ -0,0 +1,134 @@
+// Copyright 2016 CoreOS, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package runtime
+
+import (
+	"errors"
+	"fmt"
+	"io"
+	"net"
+	"net/http"
+	"sort"
+	"strconv"
+	"strings"
+)
+
+type httpHandler struct{}
+
+func serve(host string) error {
+	ln, err := net.Listen("tcp", host)
+	if err != nil {
+		return err
+	}
+	go http.Serve(ln, &httpHandler{})
+	return nil
+}
+
+func (*httpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+	// Ensures the server(runtime) doesn't panic due to the execution of
+	// panic failpoints during processing of the HTTP request, as the
+	// sender of the HTTP request should not be affected by the execution
+	// of the panic failpoints and crash as a side effect
+	panicMu.Lock()
+	defer panicMu.Unlock()
+
+	// flush before unlocking so a panic failpoint won't
+	// take down the http server before it sends the response
+	defer flush(w)
+
+	key := r.RequestURI
+	if len(key) == 0 || key[0] != '/' {
+		http.Error(w, "malformed request URI", http.StatusBadRequest)
+		return
+	}
+	key = key[1:]
+
+	switch {
+	// sets the failpoint
+	case r.Method == "PUT":
+		v, err := io.ReadAll(r.Body)
+		if err != nil {
+			http.Error(w, "failed ReadAll in PUT", http.StatusBadRequest)
+			return
+		}
+
+		fpMap := map[string]string{key: string(v)}
+		if strings.EqualFold(key, "failpoints") {
+			fpMap, err = parseFailpoints(string(v))
+			if err != nil {
+				http.Error(w, fmt.Sprintf("fail to parse failpoint: %v", err), http.StatusBadRequest)
+				return
+			}
+		}
+
+		for k, v := range fpMap {
+			if err := Enable(k, v); err != nil {
+				http.Error(w, fmt.Sprintf("fail to set failpoint: %v", err), http.StatusBadRequest)
+				return
+			}
+		}
+		w.WriteHeader(http.StatusNoContent)
+
+	// gets status of the failpoint
+	case r.Method == "GET":
+		if len(key) == 0 {
+			fps := list()
+			sort.Strings(fps)
+			lines := make([]string, len(fps))
+			for i := range lines {
+				s, _, _ := Status(fps[i])
+				lines[i] = fps[i] + "=" + s
+			}
+			w.Write([]byte(strings.Join(lines, "\n") + "\n"))
+		} else if strings.HasSuffix(key, "/count") {
+			fp := key[:len(key)-len("/count")]
+			_, count, err := Status(fp)
+			if err != nil {
+				if errors.Is(err, ErrNoExist) {
+					http.Error(w, "failed to GET: "+err.Error(), http.StatusNotFound)
+				} else {
+					http.Error(w, "failed to GET: "+err.Error(), http.StatusInternalServerError)
+				}
+				return
+			}
+			w.Write([]byte(strconv.Itoa(count)))
+		} else {
+			status, _, err := Status(key)
+			if err != nil {
+				http.Error(w, "failed to GET: "+err.Error(), http.StatusNotFound)
+			}
+			w.Write([]byte(status + "\n"))
+		}
+
+	// deactivates a failpoint
+	case r.Method == "DELETE":
+		if err := Disable(key); err != nil {
+			http.Error(w, "failed to delete failpoint "+err.Error(), http.StatusBadRequest)
+			return
+		}
+		w.WriteHeader(http.StatusNoContent)
+	default:
+		w.Header().Add("Allow", "DELETE")
+		w.Header().Add("Allow", "GET")
+		w.Header().Set("Allow", "PUT")
+		http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
+	}
+}
+
+func flush(w http.ResponseWriter) {
+	if f, ok := w.(http.Flusher); ok {
+		f.Flush()
+	}
+}
diff --git a/vendor/go.etcd.io/gofail/runtime/runtime.go b/vendor/go.etcd.io/gofail/runtime/runtime.go
new file mode 100644
index 0000000..f6e1589
--- /dev/null
+++ b/vendor/go.etcd.io/gofail/runtime/runtime.go
@@ -0,0 +1,151 @@
+// Copyright 2016 CoreOS, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package runtime
+
+import (
+	"fmt"
+	"os"
+	"strings"
+	"sync"
+)
+
+var (
+	ErrNoExist  = fmt.Errorf("failpoint: failpoint does not exist")
+	ErrDisabled = fmt.Errorf("failpoint: failpoint is disabled")
+
+	failpoints map[string]*Failpoint
+	// failpointsMu protects the failpoints map, preventing concurrent
+	// accesses during commands such as Enabling and Disabling
+	failpointsMu sync.RWMutex
+
+	envTerms map[string]string
+
+	// panicMu (panic mutex) ensures that the action of panic failpoints
+	// and serving of the HTTP requests won't be executed at the same time,
+	// avoiding the possibility that the server runtime panics during processing
+	// requests
+	panicMu sync.Mutex
+)
+
+func init() {
+	failpoints = make(map[string]*Failpoint)
+	envTerms = make(map[string]string)
+	if s := os.Getenv("GOFAIL_FAILPOINTS"); len(s) > 0 {
+		fpMap, err := parseFailpoints(s)
+		if err != nil {
+			fmt.Printf("fail to parse failpoint: %v\n", err)
+			os.Exit(1)
+		}
+		envTerms = fpMap
+	}
+	if s := os.Getenv("GOFAIL_HTTP"); len(s) > 0 {
+		if err := serve(s); err != nil {
+			fmt.Println(err)
+			os.Exit(1)
+		}
+	}
+}
+
+func parseFailpoints(fps string) (map[string]string, error) {
+	// The format is <FAILPOINT>=<TERMS>[;<FAILPOINT>=<TERMS>]*
+	fpMap := map[string]string{}
+
+	for _, fp := range strings.Split(fps, ";") {
+		if len(fp) == 0 {
+			continue
+		}
+		fpTerm := strings.Split(fp, "=")
+		if len(fpTerm) != 2 {
+			err := fmt.Errorf("bad failpoint %q", fp)
+			return nil, err
+		}
+		fpMap[fpTerm[0]] = fpTerm[1]
+	}
+	return fpMap, nil
+}
+
+// Enable sets a failpoint to a given failpoint description.
+func Enable(name, inTerms string) error {
+	failpointsMu.RLock()
+	fp := failpoints[name]
+	failpointsMu.RUnlock()
+	if fp == nil {
+		return ErrNoExist
+	}
+
+	t, err := newTerms(name, inTerms)
+	if err != nil {
+		fmt.Printf("failed to enable \"%s=%s\" (%v)\n", name, inTerms, err)
+		return err
+	}
+
+	fp.SetTerm(t)
+
+	return nil
+}
+
+// Disable stops a failpoint from firing.
+func Disable(name string) error {
+	failpointsMu.RLock()
+	fp := failpoints[name]
+	failpointsMu.RUnlock()
+	if fp == nil {
+		return ErrNoExist
+	}
+
+	return fp.ClearTerm()
+}
+
+// Status gives the current setting and execution count for the failpoint
+func Status(failpath string) (string, int, error) {
+	failpointsMu.RLock()
+	fp := failpoints[failpath]
+	failpointsMu.RUnlock()
+	if fp == nil {
+		return "", 0, ErrNoExist
+	}
+
+	return fp.Status()
+}
+
+func List() []string {
+	failpointsMu.Lock()
+	defer failpointsMu.Unlock()
+	return list()
+}
+
+func list() []string {
+	ret := make([]string, 0, len(failpoints))
+	for fp := range failpoints {
+		ret = append(ret, fp)
+	}
+	return ret
+}
+
+func register(name string) *Failpoint {
+	failpointsMu.Lock()
+	if _, ok := failpoints[name]; ok {
+		failpointsMu.Unlock()
+		panic(fmt.Sprintf("failpoint name %s is already registered.", name))
+	}
+
+	fp := &Failpoint{}
+	failpoints[name] = fp
+	failpointsMu.Unlock()
+	if t, ok := envTerms[name]; ok {
+		Enable(name, t)
+	}
+	return fp
+}
diff --git a/vendor/go.etcd.io/gofail/runtime/terms.go b/vendor/go.etcd.io/gofail/runtime/terms.go
new file mode 100644
index 0000000..b28b468
--- /dev/null
+++ b/vendor/go.etcd.io/gofail/runtime/terms.go
@@ -0,0 +1,356 @@
+// Copyright 2016 CoreOS, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package runtime
+
+import (
+	"fmt"
+	"math/rand"
+	"os"
+	"os/exec"
+	"strings"
+	"sync"
+	"time"
+)
+
+var (
+	ErrExhausted = fmt.Errorf("failpoint: terms exhausted")
+	ErrBadParse  = fmt.Errorf("failpoint: could not parse terms")
+)
+
+// terms encodes the state for a failpoint term string (see fail(9) for examples)
+// <fp> :: <term> ( "->" <term> )*
+type terms struct {
+	// chain is a slice of all the terms from desc
+	chain []*term
+	// desc is the full term given for the failpoint
+	desc string
+	// fpath is the failpoint path for these terms
+	fpath string
+
+	// mu protects the state of the terms chain
+	mu sync.Mutex
+	// tracks executions count of terms that are actually evaluated
+	counter int
+}
+
+// term is an executable unit of the failpoint terms chain
+type term struct {
+	desc string
+
+	mods mod
+	act  actFunc
+	val  interface{}
+
+	parent *terms
+}
+
+type mod interface {
+	allow() bool
+}
+
+type modCount struct{ c int }
+
+func (mc *modCount) allow() bool {
+	if mc.c > 0 {
+		mc.c--
+		return true
+	}
+	return false
+}
+
+type modProb struct{ p float64 }
+
+func (mp *modProb) allow() bool { return rand.Float64() <= mp.p }
+
+type modList struct{ l []mod }
+
+func (ml *modList) allow() bool {
+	for _, m := range ml.l {
+		if !m.allow() {
+			return false
+		}
+	}
+	return true
+}
+
+func newTerms(fpath, desc string) (*terms, error) {
+	chain := parse(desc)
+	if len(chain) == 0 {
+		return nil, ErrBadParse
+	}
+	t := &terms{chain: chain, desc: desc, fpath: fpath}
+	for _, c := range chain {
+		c.parent = t
+	}
+	return t, nil
+}
+
+func (t *terms) String() string { return t.desc }
+
+func (t *terms) eval() interface{} {
+	t.mu.Lock()
+	defer t.mu.Unlock()
+	for _, term := range t.chain {
+		if term.mods.allow() {
+			t.counter++
+			return term.do()
+		}
+	}
+	return nil
+}
+
+// split terms from a -> b -> ... into [a, b, ...]
+func parse(desc string) (chain []*term) {
+	origDesc := desc
+	for len(desc) != 0 {
+		t := parseTerm(desc)
+		if t == nil {
+			fmt.Printf("failed to parse %q past %q\n", origDesc, desc)
+			return nil
+		}
+		desc = desc[len(t.desc):]
+		chain = append(chain, t)
+		if len(desc) >= 2 {
+			if !strings.HasPrefix(desc, "->") {
+				fmt.Printf("failed to parse %q past %q, expected \"->\"\n", origDesc, desc)
+				return nil
+			}
+			desc = desc[2:]
+		}
+	}
+	return chain
+}
+
+// <term> :: <mod> <act> [ "(" <val> ")" ]
+func parseTerm(desc string) *term {
+	t := &term{}
+	modStr, mods := parseMod(desc)
+	t.mods = &modList{mods}
+	actStr, act := parseAct(desc[len(modStr):])
+	t.act = act
+	valStr, val := parseVal(desc[len(modStr)+len(actStr):])
+	t.val = val
+	t.desc = desc[:len(modStr)+len(actStr)+len(valStr)]
+	if len(t.desc) == 0 {
+		return nil
+	}
+	return t
+}
+
+// <mod> :: ((<float> "%")|(<int> "*" ))*
+func parseMod(desc string) (ret string, mods []mod) {
+	for {
+		s, v := parseIntFloat(desc)
+		if len(s) == 0 {
+			break
+		}
+		if len(s) == len(desc) {
+			return "", nil
+		}
+		switch v := v.(type) {
+		case float64:
+			if desc[len(s)] != '%' {
+				return "", nil
+			}
+			ret = ret + desc[:len(s)+1]
+			mods = append(mods, &modProb{v / 100.0})
+			desc = desc[len(s)+1:]
+		case int:
+			if desc[len(s)] != '*' {
+				return "", nil
+			}
+			ret = ret + desc[:len(s)+1]
+			mods = append(mods, &modCount{v})
+			desc = desc[len(s)+1:]
+		default:
+			panic("???")
+		}
+	}
+	return ret, mods
+}
+
+// parseIntFloat parses an int or float from a string and returns the string
+// it parsed it from (unlike scanf).
+func parseIntFloat(desc string) (string, interface{}) {
+	// parse for ints
+	i := 0
+	for i < len(desc) {
+		if desc[i] < '0' || desc[i] > '9' {
+			break
+		}
+		i++
+	}
+	if i == 0 {
+		return "", nil
+	}
+
+	intVal := int(0)
+	_, err := fmt.Sscanf(desc[:i], "%d", &intVal)
+	if err != nil {
+		return "", nil
+	}
+	if len(desc) == i {
+		return desc[:i], intVal
+	}
+	if desc[i] != '.' {
+		return desc[:i], intVal
+	}
+
+	// parse for floats
+	i++
+	if i == len(desc) {
+		return desc[:i], float64(intVal)
+	}
+
+	j := i
+	for i < len(desc) {
+		if desc[i] < '0' || desc[i] > '9' {
+			break
+		}
+		i++
+	}
+	if j == i {
+		return desc[:i], float64(intVal)
+	}
+
+	f := float64(0)
+	if _, err = fmt.Sscanf(desc[:i], "%f", &f); err != nil {
+		return "", nil
+	}
+	return desc[:i], f
+}
+
+// parseAct parses an action
+// <act> :: "off" | "return" | "sleep" | "panic" | "break" | "print"
+func parseAct(desc string) (string, actFunc) {
+	for k, v := range actMap {
+		if strings.HasPrefix(desc, k) {
+			return k, v
+		}
+	}
+	return "", nil
+}
+
+// <val> :: <int> | <string> | <bool> | <nothing>
+func parseVal(desc string) (string, interface{}) {
+	// return => struct{}
+	if len(desc) == 0 {
+		return "", struct{}{}
+	}
+	// malformed
+	if len(desc) == 1 || desc[0] != '(' {
+		return "", nil
+	}
+	// return() => struct{}
+	if desc[1] == ')' {
+		return "()", struct{}{}
+	}
+	// return("s") => string
+	s := ""
+	n, err := fmt.Sscanf(desc[1:], "%q", &s)
+	if n == 1 && err == nil {
+		return desc[:len(s)+4], s
+	}
+	// return(1) => int
+	v := 0
+	n, err = fmt.Sscanf(desc[1:], "%d", &v)
+	if n == 1 && err == nil {
+		return desc[:len(fmt.Sprintf("%d", v))+2], v
+	}
+	// return(true) => bool
+	b := false
+	n, err = fmt.Sscanf(desc[1:], "%t", &b)
+	if n == 1 && err == nil {
+		return desc[:len(fmt.Sprintf("%t", b))+2], b
+	}
+	// unknown type; malformed input?
+	return "", nil
+}
+
+type actFunc func(*term) interface{}
+
+var actMap = map[string]actFunc{
+	"off":    actOff,
+	"return": actReturn,
+	"sleep":  actSleep,
+	"panic":  actPanic,
+	"break":  actBreak,
+	"print":  actPrint,
+}
+
+func (t *term) do() interface{} { return t.act(t) }
+
+func actOff(_ *term) interface{} { return nil }
+
+func actReturn(t *term) interface{} { return t.val }
+
+func actSleep(t *term) interface{} {
+	var dur time.Duration
+	switch v := t.val.(type) {
+	case int:
+		dur = time.Duration(v) * time.Millisecond
+	case string:
+		vDur, err := time.ParseDuration(v)
+		if err != nil {
+			fmt.Printf("failpoint: could not parse sleep(%v) on %s\n", v, t.parent.fpath)
+			return nil
+		}
+		dur = vDur
+	default:
+		fmt.Printf("failpoint: ignoring sleep(%v) on %s\n", v, t.parent.fpath)
+		return nil
+	}
+	time.Sleep(dur)
+	return nil
+}
+
+func actPanic(t *term) interface{} {
+	panicMu.Lock()
+	defer panicMu.Unlock()
+
+	if t.val != nil {
+		panic(fmt.Sprintf("failpoint panic: %v", t.val))
+	}
+	panic("failpoint panic: " + t.parent.fpath)
+}
+
+func actBreak(_ *term) interface{} {
+	p, perr := exec.LookPath(os.Args[0])
+	if perr != nil {
+		panic(perr)
+	}
+	cmd := exec.Command("gdb", p, fmt.Sprintf("%d", os.Getpid()))
+	cmd.Stdin = os.Stdin
+	cmd.Stdout = os.Stdout
+	cmd.Stderr = os.Stderr
+	if err := cmd.Start(); err != nil {
+		panic(err)
+	}
+
+	// wait for gdb prompt
+	// XXX: tried doing this by piping stdout here and waiting on "(gdb) "
+	// but the the output won't appear since the process is STOPed and
+	// can't copy it back to the actual stdout
+	time.Sleep(3 * time.Second)
+
+	// don't zombie gdb
+	go cmd.Wait()
+	return nil
+}
+
+func actPrint(t *term) interface{} {
+	fmt.Println("failpoint print:", t.parent.fpath)
+	return nil
+}