Skip to content

Commit

Permalink
PP-3222 - Create client for HTTP sequence tests
Browse files Browse the repository at this point in the history
Summary:
This is the first pass at the client for HTTP requests only.
I'll do some reorganization of the directories after this lands for more consistency.

Test Plan:
Run manually

```./client seq http --addr http://xyz:8080/seq_test -n 100000 -c 50 -s 2000000 -r 1024`

Reviewers: vihang, michelle, nserrino

Reviewed By: nserrino

JIRA Issues: PP-3222

Signed-off-by: Zain Asgar <zasgar@pixielabs.ai>

Differential Revision: https://phab.corp.pixielabs.ai/D10796

GitOrigin-RevId: 14f490a
  • Loading branch information
zasgar authored and copybaranaut committed Feb 17, 2022
1 parent dc168b6 commit 1e43e0d
Showing 11 changed files with 426 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/e2e_test/protocol_loadtest/http/http.go
Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ func basicHandler(w http.ResponseWriter, r *http.Request) {
bodySize := getQueryParamAsInt(r.URL.Query(), bodySizeParam)
numHeaders := getQueryParamAsInt(r.URL.Query(), numHeadersParam)

w.Header().Set("X-Pixie-Ack-Seq-Id", r.Header.Get("X-Pixie-Req-Seq-Id"))
w.Header().Set("x-px-ack-seq-id", r.Header.Get("x-px-seq-id"))
for i := 0; i < numHeaders; i++ {
w.Header().Add(fmt.Sprintf("X-Custom-Header-%d", i), string(util.RandPrintable(headerSize)))
}
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ spec:
spec:
containers:
- name: app
image: gcr.io/pixie-oss/pixie-dev/experimental/protocol_loadtest_server:latest
image: gcr.io/pixie-oss/pixie-dev/src/e2e_test/protocol_loadtest/protocol_loadtest_server_image:latest
env:
- name: HTTP_PORT
value: "8080"
4 changes: 2 additions & 2 deletions src/e2e_test/protocol_loadtest/skaffold_loadtest.yaml
Original file line number Diff line number Diff line change
@@ -3,10 +3,10 @@ apiVersion: skaffold/v2alpha3
kind: Config
build:
artifacts:
- image: gcr.io/pixie-oss/pixie-dev/src/e2e_test/protocol_loadtest/protocol_loadtest_server
- image: gcr.io/pixie-oss/pixie-dev/src/e2e_test/protocol_loadtest/protocol_loadtest_server_image
context: .
bazel:
target: //src/e2e_test/protocol_loadtest/protocol_loadtest_server_image.tar
target: //src/e2e_test/protocol_loadtest:protocol_loadtest_server_image.tar
tagPolicy:
dateTime: {}
local:
28 changes: 28 additions & 0 deletions src/e2e_test/vizier/seq_tests/client/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2018- The Pixie Authors.
#
# 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.
#
# SPDX-License-Identifier: Apache-2.0

load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "client",
srcs = ["client.go"],
importpath = "px.dev/pixie/src/e2e_test/vizier/seq_tests/client",
visibility = ["//visibility:public"],
deps = [
"//src/e2e_test/vizier/seq_tests/client/cmd",
"@com_github_sirupsen_logrus//:logrus",
],
)
32 changes: 32 additions & 0 deletions src/e2e_test/vizier/seq_tests/client/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2018- The Pixie Authors.
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/

package main

import (
log "github.com/sirupsen/logrus"

"px.dev/pixie/src/e2e_test/vizier/seq_tests/client/cmd"
)

func main() {
if err := cmd.RootCmd.Execute(); err != nil {
log.WithError(err).
Error("Failed to execute load test client")
}
}
33 changes: 33 additions & 0 deletions src/e2e_test/vizier/seq_tests/client/cmd/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2018- The Pixie Authors.
#
# 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.
#
# SPDX-License-Identifier: Apache-2.0

load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "cmd",
srcs = [
"root.go",
"seq.go",
"seq_http.go",
],
importpath = "px.dev/pixie/src/e2e_test/vizier/seq_tests/client/cmd",
visibility = ["//visibility:public"],
deps = [
"//src/e2e_test/vizier/seq_tests/client/pkg/httpclient",
"@com_github_sirupsen_logrus//:logrus",
"@com_github_spf13_cobra//:cobra",
],
)
49 changes: 49 additions & 0 deletions src/e2e_test/vizier/seq_tests/client/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright 2018- The Pixie Authors.
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/

package cmd

import (
"crypto/tls"
"net/http"
"time"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

func init() {
RootCmd.PersistentFlags().StringP("addr", "a", "https://localhost:5001", "The address of the server with protocol")
RootCmd.PersistentFlags().BoolP("skip_verify", "k", false, "Skip SSL verification (if SSL is used)")

RootCmd.AddCommand(SeqCmd)
}

// RootCmd is the base command for this CLI.
var RootCmd = &cobra.Command{
Use: "ltc",
Short: "Load Test Client",
Long: "This is the load test client to test Pixie under various conditions",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
log.WithField("time", time.Now()).
Info("Starting Load Test Client")
if skip, _ := cmd.Flags().GetBool("skip_verify"); skip {
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
}
},
}
33 changes: 33 additions & 0 deletions src/e2e_test/vizier/seq_tests/client/cmd/seq.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2018- The Pixie Authors.
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/

package cmd

import (
"github.com/spf13/cobra"
)

func init() {
SeqCmd.AddCommand(HTTPSeqCmd)
}

// SeqCmd is the base of all sequence tests.
var SeqCmd = &cobra.Command{
Use: "seq",
Short: "Run sequence related tests",
}
61 changes: 61 additions & 0 deletions src/e2e_test/vizier/seq_tests/client/cmd/seq_http.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright 2018- The Pixie Authors.
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/

package cmd

import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"px.dev/pixie/src/e2e_test/vizier/seq_tests/client/pkg/httpclient"
)

func init() {
HTTPSeqCmd.PersistentFlags().IntP("start_sequence", "s", 0, "The start sequence number of the messages")
HTTPSeqCmd.PersistentFlags().IntP("num_messages", "n", 10, "Number of messages to send")
HTTPSeqCmd.PersistentFlags().IntP("num_conns", "c", 10, "Number of concurrent connections")
HTTPSeqCmd.PersistentFlags().IntP("req_size", "r", 16, "The size of the request body")
HTTPSeqCmd.PersistentFlags().IntP("resp_size", "z", 16, "The size of the response body")
}

// HTTPSeqCmd is the generates HTTP sequence messages.
var HTTPSeqCmd = &cobra.Command{
Use: "http",
Short: "HTTP Sequence Load Test",
Long: "Run the HTTP/1.1 sequence load test",
Run: func(cmd *cobra.Command, args []string) {
addr, _ := cmd.Flags().GetString("addr")
startSequence, _ := cmd.Flags().GetInt("start_sequence")
numMessages, _ := cmd.Flags().GetInt("num_messages")
numConns, _ := cmd.Flags().GetInt("num_conns")
reqSize, _ := cmd.Flags().GetInt("req_size")
respSize, _ := cmd.Flags().GetInt("resp_size")
log.
WithField("addr", addr).
WithField("start_sequence", startSequence).
WithField("num_messages", numMessages).
WithField("num_conns", numConns).
WithField("req_size", reqSize).
WithField("resp_size", respSize).
Info("Running HTTP sequence tests")

c := httpclient.New(addr, startSequence, numMessages, numConns, reqSize, respSize)
_ = c.Run()
_ = c.PrintStats()
},
}
28 changes: 28 additions & 0 deletions src/e2e_test/vizier/seq_tests/client/pkg/httpclient/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2018- The Pixie Authors.
#
# 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.
#
# SPDX-License-Identifier: Apache-2.0

load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "httpclient",
srcs = ["client.go"],
importpath = "px.dev/pixie/src/e2e_test/vizier/seq_tests/client/pkg/httpclient",
visibility = ["//visibility:public"],
deps = [
"//src/e2e_test/util",
"@com_github_sirupsen_logrus//:logrus",
],
)
Loading

0 comments on commit 1e43e0d

Please sign in to comment.