Skip to content

Commit

Permalink
Add throughput1 client library (#26)
Browse files Browse the repository at this point in the history
* Add handler

* Save archival data from deferred func

* Add main, fix handler

* Add script to generate local test certs

* Add build script and Dockerfile.

* Update go.mod/go.sum

* Add basic client for testing

* Swap logger

* Swap logger in measurer, too

* Remove files that don't belong to this PR

* Remove more files that don't belong here

* go mod tidy

* Change metadata length limits

* Add access_token to the knownOptions map.

* Add partial tests and prom metrics

* Duration should be milliseconds

* Increase test coverage

* Update go.mod

* Update go.mod go.sum

* Add client code

* Merge branch 'main' into sandbox-roberto-client

* Rename ndt8 -> throughput1

* Separate network-level and application-level measurements.

This commit adds application-level measurements and namespaces to better separate
the two kind of measurements in the Measurement object.

It is a breaking change and will need a schema update.

* Fix client

* Merge branch 'main' into sandbox-roberto-client

* Merge branch 'add-application-byte-counters' into sandbox-roberto-client

* Merge branch 'temp-test' into sandbox-roberto-client

* Make output more detailed, add server-side messages

* Make application-level byte counters atomic.

* Merge branch 'add-application-byte-counters' into sandbox-roberto-client

* Merge branch 'main' into sandbox-roberto-client

* Add debug flag and simplify code

* Add -debug flag, docstrings, and call Upload() in main

* Remove unused fields

* Complete rename from NDT8 to Throughput1

* Use the same version for libraryVersion and clientVersion

(and set it to version.Version, overridden by build flags)

* Rename client to msak-client-go

* Add docstrings and use the right timeout in connect() call.

* Refactor code to extract runStream().

* Add docstrings.

* Fix race condition.

* Refactor code, only output every 100ms

* Remove extra \n from OnDebug messages

* Address code review comments

- Make client name const
- Use client package consts for flags' default values
- Use log.Fatal

* Update defaults, add comments

* Include

* Add DefaultScheme const and more docstrings

* Replace fmt.Print with Emitter.OnDebug

* Panic on invalid subtests

* Remove ServiceURL

* Move client config to a dedicated struct

* Rename client.ClientConfig to client.Config

* More refactoring and more comments/docstrings.

* Add TLSClientConfig to defaultDialer.

* Add docstrings in Emitter interface.

* Merge branch 'main' into sandbox-roberto-client

* FromTCPConn -> FromTCPLikeConn

* Panic on empty clientName/Version in client.New()

* Add comments in nextURLFromLocate and remove extra printf
  • Loading branch information
robertodauria authored Sep 29, 2023
1 parent d233487 commit 21baee2
Show file tree
Hide file tree
Showing 5 changed files with 646 additions and 0 deletions.
56 changes: 56 additions & 0 deletions cmd/msak-client/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package main

import (
"context"
"flag"
"log"

"github.com/google/uuid"
"github.com/m-lab/msak/pkg/client"
"github.com/m-lab/msak/pkg/version"
)

const clientName = "msak-client-go"

var clientVersion = version.Version

var (
flagServer = flag.String("server", "", "Server address")
flagStreams = flag.Int("streams", client.DefaultStreams, "Number of streams")
flagCC = flag.String("cc", "bbr", "Congestion control algorithm to use")
flagDelay = flag.Duration("delay", 0, "Delay between each stream")
flagDuration = flag.Duration("duration", client.DefaultLength, "Length of the last stream")
flagScheme = flag.String("scheme", client.DefaultScheme, "Websocket scheme (wss or ws)")
flagMID = flag.String("mid", uuid.NewString(), "Measurement ID to use")
flagNoVerify = flag.Bool("no-verify", false, "Skip TLS certificate verification")
flagDebug = flag.Bool("debug", false, "Enable debug logging")
)

func main() {
flag.Parse()

// For a given number of streams, there will be streams-1 delays. This makes
// sure that all the streams can at least start with the current configuration.
if float64(*flagStreams-1)*flagDelay.Seconds() >= flagDuration.Seconds() {
log.Fatal("Invalid configuration: please check streams, delay and duration and make sure they make sense.")
}

config := client.Config{
Server: *flagServer,
Scheme: *flagScheme,
NumStreams: *flagStreams,
CongestionControl: *flagCC,
Delay: *flagDelay,
Length: *flagDuration,
MeasurementID: *flagMID,
Emitter: client.HumanReadable{
Debug: *flagDebug,
},
NoVerify: *flagNoVerify,
}

cl := client.New(clientName, clientVersion, config)

cl.Download(context.Background())
cl.Upload(context.Background())
}
Loading

0 comments on commit 21baee2

Please sign in to comment.