Commit d8390c48 authored by Eric Walker's avatar Eric Walker

Remove test/images/* from hack/.golint_failures

parent 224448b8
...@@ -746,14 +746,6 @@ test/e2e_node/environment ...@@ -746,14 +746,6 @@ test/e2e_node/environment
test/e2e_node/remote test/e2e_node/remote
test/e2e_node/runner/remote test/e2e_node/runner/remote
test/e2e_node/services test/e2e_node/services
test/images/net/nat
test/images/netexec
test/images/nettest
test/images/no-snat-test
test/images/no-snat-test-proxy
test/images/resource-consumer
test/images/resource-consumer/common
test/images/resource-consumer/controller
test/integration test/integration
test/integration/auth test/integration/auth
test/integration/evictions test/integration/evictions
......
...@@ -40,7 +40,7 @@ import ( ...@@ -40,7 +40,7 @@ import (
// connection assigned here. // connection assigned here.
var leakedConnection *net.TCPConn var leakedConnection *net.TCPConn
// Server JSON options. // CloseWaitServerOptions holds server JSON options.
type CloseWaitServerOptions struct { type CloseWaitServerOptions struct {
// Address to bind for the test // Address to bind for the test
LocalAddr string LocalAddr string
...@@ -110,7 +110,7 @@ func (server *closeWaitServer) Run(logger *log.Logger, rawOptions interface{}) e ...@@ -110,7 +110,7 @@ func (server *closeWaitServer) Run(logger *log.Logger, rawOptions interface{}) e
return nil return nil
} }
// Client JSON options // CloseWaitClientOptions holds client JSON options.
type CloseWaitClientOptions struct { type CloseWaitClientOptions struct {
// RemoteAddr of the server to connect to. // RemoteAddr of the server to connect to.
RemoteAddr string RemoteAddr string
......
...@@ -80,7 +80,7 @@ func main() { ...@@ -80,7 +80,7 @@ func main() {
func startHTTPServer(httpPort int) { func startHTTPServer(httpPort int) {
http.HandleFunc("/", rootHandler) http.HandleFunc("/", rootHandler)
http.HandleFunc("/clientip", clientIpHandler) http.HandleFunc("/clientip", clientIPHandler)
http.HandleFunc("/echo", echoHandler) http.HandleFunc("/echo", echoHandler)
http.HandleFunc("/exit", exitHandler) http.HandleFunc("/exit", exitHandler)
http.HandleFunc("/hostname", hostnameHandler) http.HandleFunc("/hostname", hostnameHandler)
...@@ -104,7 +104,7 @@ func echoHandler(w http.ResponseWriter, r *http.Request) { ...@@ -104,7 +104,7 @@ func echoHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%s", r.FormValue("msg")) fmt.Fprintf(w, "%s", r.FormValue("msg"))
} }
func clientIpHandler(w http.ResponseWriter, r *http.Request) { func clientIPHandler(w http.ResponseWriter, r *http.Request) {
log.Printf("GET /clientip") log.Printf("GET /clientip")
fmt.Fprintf(w, r.RemoteAddr) fmt.Fprintf(w, r.RemoteAddr)
} }
......
...@@ -133,7 +133,7 @@ func (s *State) serveWrite(w http.ResponseWriter, r *http.Request) { ...@@ -133,7 +133,7 @@ func (s *State) serveWrite(w http.ResponseWriter, r *http.Request) {
if s.Received == nil { if s.Received == nil {
s.Received = map[string]int{} s.Received = map[string]int{}
} }
s.Received[wp.Source] += 1 s.Received[wp.Source]++
} }
s.appendErr(json.NewEncoder(w).Encode(&WriteResp{Hostname: s.Hostname})) s.appendErr(json.NewEncoder(w).Encode(&WriteResp{Hostname: s.Hostname}))
} }
...@@ -164,7 +164,7 @@ func (s *State) appendSuccessfulSend(toHostname string) { ...@@ -164,7 +164,7 @@ func (s *State) appendSuccessfulSend(toHostname string) {
if s.Sent == nil { if s.Sent == nil {
s.Sent = map[string]int{} s.Sent = map[string]int{}
} }
s.Sent[toHostname] += 1 s.Sent[toHostname]++
} }
var ( var (
......
...@@ -30,22 +30,22 @@ import ( ...@@ -30,22 +30,22 @@ import (
// This Pod's /checknosnat takes `target` and `ips` arguments, and queries {target}/checknosnat?ips={ips} // This Pod's /checknosnat takes `target` and `ips` arguments, and queries {target}/checknosnat?ips={ips}
type MasqTestProxy struct { type masqTestProxy struct {
Port string Port string
} }
func NewMasqTestProxy() *MasqTestProxy { func newMasqTestProxy() *masqTestProxy {
return &MasqTestProxy{ return &masqTestProxy{
Port: "31235", Port: "31235",
} }
} }
func (m *MasqTestProxy) AddFlags(fs *pflag.FlagSet) { func (m *masqTestProxy) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&m.Port, "port", m.Port, "The port to serve /checknosnat endpoint on.") fs.StringVar(&m.Port, "port", m.Port, "The port to serve /checknosnat endpoint on.")
} }
func main() { func main() {
m := NewMasqTestProxy() m := newMasqTestProxy()
m.AddFlags(pflag.CommandLine) m.AddFlags(pflag.CommandLine)
flag.InitFlags() flag.InitFlags()
...@@ -58,7 +58,7 @@ func main() { ...@@ -58,7 +58,7 @@ func main() {
} }
} }
func (m *MasqTestProxy) Run() error { func (m *masqTestProxy) Run() error {
// register handler // register handler
http.HandleFunc("/checknosnat", checknosnat) http.HandleFunc("/checknosnat", checknosnat)
......
...@@ -34,22 +34,22 @@ import ( ...@@ -34,22 +34,22 @@ import (
// pip = this pod's ip // pip = this pod's ip
// nip = this node's ip // nip = this node's ip
type MasqTester struct { type masqTester struct {
Port string Port string
} }
func NewMasqTester() *MasqTester { func newMasqTester() *masqTester {
return &MasqTester{ return &masqTester{
Port: "8080", Port: "8080",
} }
} }
func (m *MasqTester) AddFlags(fs *pflag.FlagSet) { func (m *masqTester) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&m.Port, "port", m.Port, "The port to serve /checknosnat and /whoami endpoints on.") fs.StringVar(&m.Port, "port", m.Port, "The port to serve /checknosnat and /whoami endpoints on.")
} }
func main() { func main() {
m := NewMasqTester() m := newMasqTester()
m.AddFlags(pflag.CommandLine) m.AddFlags(pflag.CommandLine)
flag.InitFlags() flag.InitFlags()
...@@ -62,7 +62,7 @@ func main() { ...@@ -62,7 +62,7 @@ func main() {
} }
} }
func (m *MasqTester) Run() error { func (m *masqTester) Run() error {
// pip is the current pod's IP and nip is the current node's IP // pip is the current pod's IP and nip is the current node's IP
// pull the pip and nip out of the env // pull the pip and nip out of the env
pip, ok := os.LookupEnv("POD_IP") pip, ok := os.LookupEnv("POD_IP")
...@@ -145,9 +145,8 @@ func check(ip string, pip string, nip string) error { ...@@ -145,9 +145,8 @@ func check(ip string, pip string, nip string) error {
if rip != pip { if rip != pip {
if rip == nip { if rip == nip {
return fmt.Errorf("Returned ip %q != my Pod ip %q, == my Node ip %q - SNAT", rip, pip, nip) return fmt.Errorf("Returned ip %q != my Pod ip %q, == my Node ip %q - SNAT", rip, pip, nip)
} else {
return fmt.Errorf("Returned ip %q != my Pod ip %q or my Node ip %q - SNAT to unexpected ip (possible SNAT through unexpected interface on the way into another node)", rip, pip, nip)
} }
return fmt.Errorf("Returned ip %q != my Pod ip %q or my Node ip %q - SNAT to unexpected ip (possible SNAT through unexpected interface on the way into another node)", rip, pip, nip)
} }
return nil return nil
} }
...@@ -16,6 +16,7 @@ limitations under the License. ...@@ -16,6 +16,7 @@ limitations under the License.
package common package common
// Constants related to Prometheus metrics.
const ( const (
ConsumeCPUAddress = "/ConsumeCPU" ConsumeCPUAddress = "/ConsumeCPU"
ConsumeMemAddress = "/ConsumeMem" ConsumeMemAddress = "/ConsumeMem"
......
...@@ -24,26 +24,28 @@ import ( ...@@ -24,26 +24,28 @@ import (
"sync" "sync"
"time" "time"
. "k8s.io/kubernetes/test/images/resource-consumer/common" "k8s.io/kubernetes/test/images/resource-consumer/common"
) )
// ResourceConsumerHandler holds metrics for a resource consumer.
type ResourceConsumerHandler struct { type ResourceConsumerHandler struct {
metrics map[string]float64 metrics map[string]float64
metricsLock sync.Mutex metricsLock sync.Mutex
} }
// NewResourceConsumerHandler creates and initializes a ResourceConsumerHandler to defaults.
func NewResourceConsumerHandler() *ResourceConsumerHandler { func NewResourceConsumerHandler() *ResourceConsumerHandler {
return &ResourceConsumerHandler{metrics: map[string]float64{}} return &ResourceConsumerHandler{metrics: map[string]float64{}}
} }
func (handler *ResourceConsumerHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { func (handler *ResourceConsumerHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// handle exposing metrics in Prometheus format (both GET & POST) // handle exposing metrics in Prometheus format (both GET & POST)
if req.URL.Path == MetricsAddress { if req.URL.Path == common.MetricsAddress {
handler.handleMetrics(w) handler.handleMetrics(w)
return return
} }
if req.Method != "POST" { if req.Method != "POST" {
http.Error(w, BadRequest, http.StatusBadRequest) http.Error(w, common.BadRequest, http.StatusBadRequest)
return return
} }
// parsing POST request data and URL data // parsing POST request data and URL data
...@@ -52,34 +54,34 @@ func (handler *ResourceConsumerHandler) ServeHTTP(w http.ResponseWriter, req *ht ...@@ -52,34 +54,34 @@ func (handler *ResourceConsumerHandler) ServeHTTP(w http.ResponseWriter, req *ht
return return
} }
// handle consumeCPU // handle consumeCPU
if req.URL.Path == ConsumeCPUAddress { if req.URL.Path == common.ConsumeCPUAddress {
handler.handleConsumeCPU(w, req.Form) handler.handleConsumeCPU(w, req.Form)
return return
} }
// handle consumeMem // handle consumeMem
if req.URL.Path == ConsumeMemAddress { if req.URL.Path == common.ConsumeMemAddress {
handler.handleConsumeMem(w, req.Form) handler.handleConsumeMem(w, req.Form)
return return
} }
// handle getCurrentStatus // handle getCurrentStatus
if req.URL.Path == GetCurrentStatusAddress { if req.URL.Path == common.GetCurrentStatusAddress {
handler.handleGetCurrentStatus(w) handler.handleGetCurrentStatus(w)
return return
} }
// handle bumpMetric // handle bumpMetric
if req.URL.Path == BumpMetricAddress { if req.URL.Path == common.BumpMetricAddress {
handler.handleBumpMetric(w, req.Form) handler.handleBumpMetric(w, req.Form)
return return
} }
http.Error(w, fmt.Sprintf("%s: %s", UnknownFunction, req.URL.Path), http.StatusNotFound) http.Error(w, fmt.Sprintf("%s: %s", common.UnknownFunction, req.URL.Path), http.StatusNotFound)
} }
func (handler *ResourceConsumerHandler) handleConsumeCPU(w http.ResponseWriter, query url.Values) { func (handler *ResourceConsumerHandler) handleConsumeCPU(w http.ResponseWriter, query url.Values) {
// getting string data for consumeCPU // getting string data for consumeCPU
durationSecString := query.Get(DurationSecQuery) durationSecString := query.Get(common.DurationSecQuery)
millicoresString := query.Get(MillicoresQuery) millicoresString := query.Get(common.MillicoresQuery)
if durationSecString == "" || millicoresString == "" { if durationSecString == "" || millicoresString == "" {
http.Error(w, NotGivenFunctionArgument, http.StatusBadRequest) http.Error(w, common.NotGivenFunctionArgument, http.StatusBadRequest)
return return
} }
...@@ -87,22 +89,22 @@ func (handler *ResourceConsumerHandler) handleConsumeCPU(w http.ResponseWriter, ...@@ -87,22 +89,22 @@ func (handler *ResourceConsumerHandler) handleConsumeCPU(w http.ResponseWriter,
durationSec, durationSecError := strconv.Atoi(durationSecString) durationSec, durationSecError := strconv.Atoi(durationSecString)
millicores, millicoresError := strconv.Atoi(millicoresString) millicores, millicoresError := strconv.Atoi(millicoresString)
if durationSecError != nil || millicoresError != nil { if durationSecError != nil || millicoresError != nil {
http.Error(w, IncorrectFunctionArgument, http.StatusBadRequest) http.Error(w, common.IncorrectFunctionArgument, http.StatusBadRequest)
return return
} }
go ConsumeCPU(millicores, durationSec) go ConsumeCPU(millicores, durationSec)
fmt.Fprintln(w, ConsumeCPUAddress[1:]) fmt.Fprintln(w, common.ConsumeCPUAddress[1:])
fmt.Fprintln(w, millicores, MillicoresQuery) fmt.Fprintln(w, millicores, common.MillicoresQuery)
fmt.Fprintln(w, durationSec, DurationSecQuery) fmt.Fprintln(w, durationSec, common.DurationSecQuery)
} }
func (handler *ResourceConsumerHandler) handleConsumeMem(w http.ResponseWriter, query url.Values) { func (handler *ResourceConsumerHandler) handleConsumeMem(w http.ResponseWriter, query url.Values) {
// getting string data for consumeMem // getting string data for consumeMem
durationSecString := query.Get(DurationSecQuery) durationSecString := query.Get(common.DurationSecQuery)
megabytesString := query.Get(MegabytesQuery) megabytesString := query.Get(common.MegabytesQuery)
if durationSecString == "" || megabytesString == "" { if durationSecString == "" || megabytesString == "" {
http.Error(w, NotGivenFunctionArgument, http.StatusBadRequest) http.Error(w, common.NotGivenFunctionArgument, http.StatusBadRequest)
return return
} }
...@@ -110,20 +112,20 @@ func (handler *ResourceConsumerHandler) handleConsumeMem(w http.ResponseWriter, ...@@ -110,20 +112,20 @@ func (handler *ResourceConsumerHandler) handleConsumeMem(w http.ResponseWriter,
durationSec, durationSecError := strconv.Atoi(durationSecString) durationSec, durationSecError := strconv.Atoi(durationSecString)
megabytes, megabytesError := strconv.Atoi(megabytesString) megabytes, megabytesError := strconv.Atoi(megabytesString)
if durationSecError != nil || megabytesError != nil { if durationSecError != nil || megabytesError != nil {
http.Error(w, IncorrectFunctionArgument, http.StatusBadRequest) http.Error(w, common.IncorrectFunctionArgument, http.StatusBadRequest)
return return
} }
go ConsumeMem(megabytes, durationSec) go ConsumeMem(megabytes, durationSec)
fmt.Fprintln(w, ConsumeMemAddress[1:]) fmt.Fprintln(w, common.ConsumeMemAddress[1:])
fmt.Fprintln(w, megabytes, MegabytesQuery) fmt.Fprintln(w, megabytes, common.MegabytesQuery)
fmt.Fprintln(w, durationSec, DurationSecQuery) fmt.Fprintln(w, durationSec, common.DurationSecQuery)
} }
func (handler *ResourceConsumerHandler) handleGetCurrentStatus(w http.ResponseWriter) { func (handler *ResourceConsumerHandler) handleGetCurrentStatus(w http.ResponseWriter) {
GetCurrentStatus() GetCurrentStatus()
fmt.Fprintln(w, "Warning: not implemented!") fmt.Fprintln(w, "Warning: not implemented!")
fmt.Fprint(w, GetCurrentStatusAddress[1:]) fmt.Fprint(w, common.GetCurrentStatusAddress[1:])
} }
func (handler *ResourceConsumerHandler) handleMetrics(w http.ResponseWriter) { func (handler *ResourceConsumerHandler) handleMetrics(w http.ResponseWriter) {
...@@ -154,11 +156,11 @@ func (handler *ResourceConsumerHandler) bumpMetric(metric string, delta float64, ...@@ -154,11 +156,11 @@ func (handler *ResourceConsumerHandler) bumpMetric(metric string, delta float64,
func (handler *ResourceConsumerHandler) handleBumpMetric(w http.ResponseWriter, query url.Values) { func (handler *ResourceConsumerHandler) handleBumpMetric(w http.ResponseWriter, query url.Values) {
// getting string data for handleBumpMetric // getting string data for handleBumpMetric
metric := query.Get(MetricNameQuery) metric := query.Get(common.MetricNameQuery)
deltaString := query.Get(DeltaQuery) deltaString := query.Get(common.DeltaQuery)
durationSecString := query.Get(DurationSecQuery) durationSecString := query.Get(common.DurationSecQuery)
if durationSecString == "" || metric == "" || deltaString == "" { if durationSecString == "" || metric == "" || deltaString == "" {
http.Error(w, NotGivenFunctionArgument, http.StatusBadRequest) http.Error(w, common.NotGivenFunctionArgument, http.StatusBadRequest)
return return
} }
...@@ -166,13 +168,13 @@ func (handler *ResourceConsumerHandler) handleBumpMetric(w http.ResponseWriter, ...@@ -166,13 +168,13 @@ func (handler *ResourceConsumerHandler) handleBumpMetric(w http.ResponseWriter,
durationSec, durationSecError := strconv.Atoi(durationSecString) durationSec, durationSecError := strconv.Atoi(durationSecString)
delta, deltaError := strconv.ParseFloat(deltaString, 64) delta, deltaError := strconv.ParseFloat(deltaString, 64)
if durationSecError != nil || deltaError != nil { if durationSecError != nil || deltaError != nil {
http.Error(w, IncorrectFunctionArgument, http.StatusBadRequest) http.Error(w, common.IncorrectFunctionArgument, http.StatusBadRequest)
return return
} }
go handler.bumpMetric(metric, delta, time.Duration(durationSec)*time.Second) go handler.bumpMetric(metric, delta, time.Duration(durationSec)*time.Second)
fmt.Fprintln(w, BumpMetricAddress[1:]) fmt.Fprintln(w, common.BumpMetricAddress[1:])
fmt.Fprintln(w, metric, MetricNameQuery) fmt.Fprintln(w, metric, common.MetricNameQuery)
fmt.Fprintln(w, delta, DeltaQuery) fmt.Fprintln(w, delta, common.DeltaQuery)
fmt.Fprintln(w, durationSec, DurationSecQuery) fmt.Fprintln(w, durationSec, common.DurationSecQuery)
} }
...@@ -28,6 +28,7 @@ const ( ...@@ -28,6 +28,7 @@ const (
consumeMemBinary = "stress" consumeMemBinary = "stress"
) )
// ConsumeCPU consumes a given number of millicores for the specified duration.
func ConsumeCPU(millicores int, durationSec int) { func ConsumeCPU(millicores int, durationSec int) {
log.Printf("ConsumeCPU millicores: %v, durationSec: %v", millicores, durationSec) log.Printf("ConsumeCPU millicores: %v, durationSec: %v", millicores, durationSec)
// creating new consume cpu process // creating new consume cpu process
...@@ -37,6 +38,7 @@ func ConsumeCPU(millicores int, durationSec int) { ...@@ -37,6 +38,7 @@ func ConsumeCPU(millicores int, durationSec int) {
consumeCPU.Run() consumeCPU.Run()
} }
// ConsumeMem consumes a given number of megabytes for the specified duration.
func ConsumeMem(megabytes int, durationSec int) { func ConsumeMem(megabytes int, durationSec int) {
log.Printf("ConsumeMem megabytes: %v, durationSec: %v", megabytes, durationSec) log.Printf("ConsumeMem megabytes: %v, durationSec: %v", megabytes, durationSec)
megabytesString := strconv.Itoa(megabytes) + "M" megabytesString := strconv.Itoa(megabytes) + "M"
...@@ -46,6 +48,7 @@ func ConsumeMem(megabytes int, durationSec int) { ...@@ -46,6 +48,7 @@ func ConsumeMem(megabytes int, durationSec int) {
consumeMem.Run() consumeMem.Run()
} }
// GetCurrentStatus prints out a no-op.
func GetCurrentStatus() { func GetCurrentStatus() {
log.Printf("GetCurrentStatus") log.Printf("GetCurrentStatus")
// not implemented // not implemented
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment