Skip to content

Commit

Permalink
Rename NetworkProfile fields
Browse files Browse the repository at this point in the history
Renaming them by removing throughput. It should be clear from the
context that they reference the throughput and not any other aspect of
the network.
  • Loading branch information
ankur22 committed Nov 13, 2023
1 parent 93a6c1b commit 49070fd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
18 changes: 9 additions & 9 deletions common/network_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ type NetworkProfile struct {
Latency float64

// Maximal aggregated download throughput (bytes/sec). -1 disables download throttling.
DownloadThroughput float64
Download float64

// Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling.
UploadThroughput float64
Upload float64
}

// NewNetworkProfile creates a non-throttled network profile.
func NewNetworkProfile() NetworkProfile {
return NetworkProfile{
Latency: 0,
DownloadThroughput: -1,
UploadThroughput: -1,
Latency: 0,
Download: -1,
Upload: -1,
}
}

Expand Down Expand Up @@ -750,8 +750,8 @@ func (m *NetworkManager) SetOfflineMode(offline bool) {
action := network.EmulateNetworkConditions(
m.offline,
m.networkProfile.Latency,
m.networkProfile.DownloadThroughput,
m.networkProfile.UploadThroughput,
m.networkProfile.Download,
m.networkProfile.Upload,
)
if err := action.Do(cdp.WithExecutor(m.ctx, m.session)); err != nil {
k6ext.Panic(m.ctx, "setting offline mode: %w", err)
Expand All @@ -769,8 +769,8 @@ func (m *NetworkManager) ThrottleNetwork(networkProfile NetworkProfile) error {
action := network.EmulateNetworkConditions(
m.offline,
m.networkProfile.Latency,
m.networkProfile.DownloadThroughput,
m.networkProfile.UploadThroughput,
m.networkProfile.Download,
m.networkProfile.Upload,
)
if err := action.Do(cdp.WithExecutor(m.ctx, m.session)); err != nil {
return fmt.Errorf("throttling network: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions examples/throttle.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export async function throttled() {
try {
page.throttleNetwork({
latency: 750,
downloadThroughput: 250,
uploadThroughput: 250,
download: 250,
upload: 250,
});

await page.goto('https://test.k6.io/', { waitUntil: 'networkidle' });
Expand Down
32 changes: 16 additions & 16 deletions tests/page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1093,9 +1093,9 @@ func TestPageThrottleNetwork(t *testing.T) {
{
name: "none",
networkProfile: common.NetworkProfile{
Latency: 0,
DownloadThroughput: -1,
UploadThroughput: -1,
Latency: 0,
Download: -1,
Upload: -1,
},
},
{
Expand All @@ -1104,34 +1104,34 @@ func TestPageThrottleNetwork(t *testing.T) {
// measured and used to assert that Latency has been correctly used.
name: "latency",
networkProfile: common.NetworkProfile{
Latency: 100,
DownloadThroughput: -1,
UploadThroughput: -1,
Latency: 100,
Download: -1,
Upload: -1,
},
wantMinRoundTripDuration: 100,
},
{
// In the ping.html file, an async ping request is made, the ping response
// returns the request body (around a 1MB). The time it takes to perform the
// roundtrip of calling ping and getting the response body is measured and
// used to assert that DownloadThroughput has been correctly used.
name: "download_throughput",
// used to assert that Download has been correctly used.
name: "download",
networkProfile: common.NetworkProfile{
Latency: 0,
DownloadThroughput: 1000,
UploadThroughput: -1,
Latency: 0,
Download: 1000,
Upload: -1,
},
wantMinRoundTripDuration: 1000,
},
{
// In the ping.html file, an async ping request is made with around a 1MB body.
// The time it takes to perform the roundtrip of calling ping is measured
// and used to assert that UploadThroughput has been correctly used.
name: "upload_throughput",
// and used to assert that Upload has been correctly used.
name: "upload",
networkProfile: common.NetworkProfile{
Latency: 0,
DownloadThroughput: -1,
UploadThroughput: 1000,
Latency: 0,
Download: -1,
Upload: 1000,
},
wantMinRoundTripDuration: 1000,
},
Expand Down

0 comments on commit 49070fd

Please sign in to comment.