Skip to content

Commit 50b03dd

Browse files
Merge pull request #15 from m-lab/sandbox-soltesz-rename-throughput1
Rename "ndt8" to "throughput1" throughout
2 parents 64bdc6e + dbfd2fc commit 50b03dd

File tree

12 files changed

+73
-73
lines changed

12 files changed

+73
-73
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ COPY --from=build /msak/msak-server /msak/
1616
COPY --from=build /msak/generate-schema /msak/
1717

1818
# Generate msak's JSON schema.
19-
RUN /msak/generate-schema -ndt8=/msak/ndt8.json
19+
RUN /msak/generate-schema -throughput1=/msak/throughput1.json
2020

2121
# Verify that the msak-server binary can be run.
2222
RUN ./msak-server -h

cmd/generate-schema/main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ import (
66

77
"github.com/m-lab/go/cloud/bqx"
88
"github.com/m-lab/go/rtx"
9-
"github.com/m-lab/msak/pkg/ndt8/model"
9+
"github.com/m-lab/msak/pkg/throughput1/model"
1010

1111
"cloud.google.com/go/bigquery"
1212
)
1313

1414
var (
15-
ndt8Schema string
15+
throughput1Schema string
1616
)
1717

1818
func init() {
19-
flag.StringVar(&ndt8Schema, "ndt8", "/var/spool/datatypes/ndt8.json", "filename to write ndt8 schema")
19+
flag.StringVar(&throughput1Schema, "throughput1", "/var/spool/datatypes/throughput1.json", "filename to write throughput1 schema")
2020
}
2121

2222
func main() {
2323
flag.Parse()
2424
// Generate and save ndt7 schema for autoloading.
25-
ndt8Result := model.NDT8Result{}
26-
sch, err := bigquery.InferSchema(ndt8Result)
27-
rtx.Must(err, "failed to generate ndt8 schema")
25+
throughput1Result := model.Throughput1Result{}
26+
sch, err := bigquery.InferSchema(throughput1Result)
27+
rtx.Must(err, "failed to generate throughput1 schema")
2828
sch = bqx.RemoveRequired(sch)
2929
b, err := sch.ToJSONFields()
3030
rtx.Must(err, "failed to marshal schema")
31-
ioutil.WriteFile(ndt8Schema, b, 0o644)
31+
ioutil.WriteFile(throughput1Schema, b, 0o644)
3232
}

cmd/msak-server/server.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"github.com/m-lab/go/rtx"
1717
"github.com/m-lab/msak/internal/handler"
1818
"github.com/m-lab/msak/internal/netx"
19-
"github.com/m-lab/msak/pkg/ndt8/spec"
19+
"github.com/m-lab/msak/pkg/throughput1/spec"
2020
)
2121

2222
var (
@@ -71,54 +71,54 @@ func main() {
7171
rtx.Must(err, "Failed to load verifier")
7272
}
7373
// Enforce tokens on uploads and downloads.
74-
ndt8TxPaths := controller.Paths{
74+
throughput1TxPaths := controller.Paths{
7575
spec.DownloadPath: true,
7676
spec.UploadPath: true,
7777
}
78-
ndt8TokenPaths := controller.Paths{
78+
throughput1TokenPaths := controller.Paths{
7979
spec.DownloadPath: true,
8080
spec.UploadPath: true,
8181
}
8282
acm, _ := controller.Setup(ctx, v, tokenVerify, tokenMachine,
83-
ndt8TxPaths, ndt8TokenPaths)
83+
throughput1TxPaths, throughput1TokenPaths)
8484

85-
ndt8Mux := http.NewServeMux()
86-
ndt8Handler := handler.New(*flagDataDir)
87-
ndt8Mux.Handle(spec.DownloadPath, http.HandlerFunc(ndt8Handler.Download))
88-
ndt8Mux.Handle(spec.UploadPath, http.HandlerFunc(ndt8Handler.Upload))
89-
ndt8ServerCleartext := httpServer(
85+
throughput1Mux := http.NewServeMux()
86+
throughput1Handler := handler.New(*flagDataDir)
87+
throughput1Mux.Handle(spec.DownloadPath, http.HandlerFunc(throughput1Handler.Download))
88+
throughput1Mux.Handle(spec.UploadPath, http.HandlerFunc(throughput1Handler.Upload))
89+
throughput1ServerCleartext := httpServer(
9090
*flagEndpointCleartext,
91-
acm.Then(ndt8Mux))
91+
acm.Then(throughput1Mux))
9292

9393
log.Info("About to listen for ws tests", "endpoint", *flagEndpointCleartext)
9494

95-
tcpl, err := net.Listen("tcp", ndt8ServerCleartext.Addr)
95+
tcpl, err := net.Listen("tcp", throughput1ServerCleartext.Addr)
9696
rtx.Must(err, "failed to create listener")
9797
l := netx.NewListener(tcpl.(*net.TCPListener))
9898
defer l.Close()
9999

100100
go func() {
101-
err := ndt8ServerCleartext.Serve(l)
101+
err := throughput1ServerCleartext.Serve(l)
102102
rtx.Must(err, "Could not start cleartext server")
103-
defer ndt8ServerCleartext.Close()
103+
defer throughput1ServerCleartext.Close()
104104
}()
105105

106106
// Only start TLS-based services if certs and keys are provided
107107
if *flagCertFile != "" && *flagKeyFile != "" {
108-
ndt8Server := httpServer(
108+
throughput1Server := httpServer(
109109
*flagEndpoint,
110-
acm.Then(ndt8Mux))
110+
acm.Then(throughput1Mux))
111111
log.Info("About to listen for wss tests", "endpoint", *flagEndpoint)
112112

113-
tcpl, err := net.Listen("tcp", ndt8Server.Addr)
113+
tcpl, err := net.Listen("tcp", throughput1Server.Addr)
114114
rtx.Must(err, "failed to create listener")
115115
l := netx.NewListener(tcpl.(*net.TCPListener))
116116
defer l.Close()
117117

118118
go func() {
119-
err := ndt8Server.ServeTLS(l, *flagCertFile, *flagKeyFile)
119+
err := throughput1Server.ServeTLS(l, *flagCertFile, *flagKeyFile)
120120
rtx.Must(err, "Could not start cleartext server")
121-
defer ndt8Server.Close()
121+
defer throughput1Server.Close()
122122
}()
123123
}
124124

internal/handler/handler.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ import (
1414
"github.com/m-lab/go/prometheusx"
1515
"github.com/m-lab/msak/internal/netx"
1616
"github.com/m-lab/msak/internal/persistence"
17-
"github.com/m-lab/msak/pkg/ndt8"
18-
"github.com/m-lab/msak/pkg/ndt8/model"
17+
"github.com/m-lab/msak/pkg/throughput1"
18+
"github.com/m-lab/msak/pkg/throughput1/model"
1919
"github.com/prometheus/client_golang/prometheus"
2020
"github.com/prometheus/client_golang/prometheus/promauto"
2121
)
2222

23-
// knownOptions are the known ndt8 options.
23+
// knownOptions are the known throughput1 options.
2424
var knownOptions = map[string]struct{}{
2525
"streams": {},
2626
"duration": {},
@@ -41,7 +41,7 @@ var (
4141
ClientConnections = promauto.NewCounterVec(
4242
prometheus.CounterOpts{
4343
Namespace: "msak",
44-
Subsystem: "ndt8",
44+
Subsystem: "throughput1",
4545
Name: "client_connections_total",
4646
},
4747
[]string{"direction", "status"},
@@ -142,10 +142,10 @@ func (h *Handler) upgradeAndRunMeasurement(kind model.TestDirection, rw http.Res
142142
}
143143

144144
// Everything looks good, try upgrading the connection to WebSocket.
145-
// Once upgraded, the underlying TCP connection is hijacked and the ndt8
145+
// Once upgraded, the underlying TCP connection is hijacked and the throughput1
146146
// protocol code will take care of closing it. Note that for this reason
147147
// we cannot call writeBadRequest after attempting an Upgrade.
148-
wsConn, err := ndt8.Upgrade(rw, req)
148+
wsConn, err := throughput1.Upgrade(rw, req)
149149
if err != nil {
150150
ClientConnections.WithLabelValues(string(kind),
151151
"websocket-upgrade-failed").Inc()
@@ -182,7 +182,7 @@ func (h *Handler) upgradeAndRunMeasurement(kind model.TestDirection, rw http.Res
182182
wsConn.Close()
183183
return
184184
}
185-
archivalData := model.NDT8Result{
185+
archivalData := model.Throughput1Result{
186186
MeasurementID: mid,
187187
UUID: uuid,
188188
StartTime: time.Now(),
@@ -203,7 +203,7 @@ func (h *Handler) upgradeAndRunMeasurement(kind model.TestDirection, rw http.Res
203203
timeout, cancel := context.WithTimeout(req.Context(), duration)
204204
defer cancel()
205205

206-
proto := ndt8.New(wsConn)
206+
proto := throughput1.New(wsConn)
207207
var senderCh, receiverCh <-chan model.WireMeasurement
208208
var errCh <-chan error
209209
if kind == model.DirectionDownload {
@@ -243,12 +243,12 @@ func (h *Handler) upgradeAndRunMeasurement(kind model.TestDirection, rw http.Res
243243
}
244244
}
245245

246-
func (h *Handler) writeResult(uuid string, kind model.TestDirection, result *model.NDT8Result) {
246+
func (h *Handler) writeResult(uuid string, kind model.TestDirection, result *model.Throughput1Result) {
247247
_, err := persistence.WriteDataFile(
248-
h.archivalDataDir, "ndt8", string(kind), uuid,
248+
h.archivalDataDir, "throughput1", string(kind), uuid,
249249
result)
250250
if err != nil {
251-
log.Error("failed to write ndt8 result", "uuid", uuid, "error", err)
251+
log.Error("failed to write throughput1 result", "uuid", uuid, "error", err)
252252
return
253253
}
254254
}

internal/handler/handler_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import (
1515
"github.com/m-lab/go/rtx"
1616
"github.com/m-lab/msak/internal/handler"
1717
"github.com/m-lab/msak/internal/netx"
18-
"github.com/m-lab/msak/pkg/ndt8"
19-
"github.com/m-lab/msak/pkg/ndt8/model"
20-
"github.com/m-lab/msak/pkg/ndt8/spec"
18+
"github.com/m-lab/msak/pkg/throughput1"
19+
"github.com/m-lab/msak/pkg/throughput1/model"
20+
"github.com/m-lab/msak/pkg/throughput1/spec"
2121
)
2222

2323
func TestNew(t *testing.T) {
@@ -76,7 +76,7 @@ func TestHandler_Upload(t *testing.T) {
7676
if conn == nil {
7777
t.Fatalf("websocket dial returned nil")
7878
}
79-
proto := ndt8.New(conn)
79+
proto := throughput1.New(conn)
8080
timeout, cancel := context.WithTimeout(context.Background(), 1*time.Second)
8181
defer cancel()
8282
senderCh, receiverCh, errCh := proto.SenderLoop(timeout)
@@ -123,7 +123,7 @@ func TestHandler_Download(t *testing.T) {
123123
t.Fatalf("websocket dial returned nil")
124124
}
125125

126-
proto := ndt8.New(conn)
126+
proto := throughput1.New(conn)
127127
timeout, cancel := context.WithTimeout(context.Background(), 1*time.Second)
128128
defer cancel()
129129
senderCh, receiverCh, errCh := proto.ReceiverLoop(timeout)

internal/measurer/measurer.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// The measurer package provides functions to periodically read kernel metrics
22
// for a given network connection and return them over a channel wrapped in an
3-
// ndt8 Measurement object.
3+
// throughput1 Measurement object.
44
package measurer
55

66
import (
@@ -12,11 +12,11 @@ import (
1212
"github.com/m-lab/go/memoryless"
1313
"github.com/m-lab/go/rtx"
1414
"github.com/m-lab/msak/internal/netx"
15-
"github.com/m-lab/msak/pkg/ndt8/model"
16-
"github.com/m-lab/msak/pkg/ndt8/spec"
15+
"github.com/m-lab/msak/pkg/throughput1/model"
16+
"github.com/m-lab/msak/pkg/throughput1/spec"
1717
)
1818

19-
type ndt8Measurer struct {
19+
type throughput1Measurer struct {
2020
connInfo netx.ConnInfo
2121
startTime time.Time
2222
bytesReadAtStart int64
@@ -33,7 +33,7 @@ type ndt8Measurer struct {
3333
// If passed a connection that is not a netx.Conn, this function will panic.
3434
func Start(ctx context.Context, conn net.Conn) <-chan model.Measurement {
3535
// Implementation note: this channel must be buffered to account for slow
36-
// readers. The "typical" reader is an ndt8 send or receive loop, which
36+
// readers. The "typical" reader is an throughput1 send or receive loop, which
3737
// might be busy with data r/w. The buffer size corresponds to at least 10
3838
// seconds:
3939
//
@@ -42,7 +42,7 @@ func Start(ctx context.Context, conn net.Conn) <-chan model.Measurement {
4242

4343
connInfo := netx.ToConnInfo(conn)
4444
read, written := connInfo.ByteCounters()
45-
m := &ndt8Measurer{
45+
m := &throughput1Measurer{
4646
connInfo: connInfo,
4747
dstChan: dst,
4848
startTime: time.Now(),
@@ -58,7 +58,7 @@ func Start(ctx context.Context, conn net.Conn) <-chan model.Measurement {
5858
return dst
5959
}
6060

61-
func (m *ndt8Measurer) loop(ctx context.Context) {
61+
func (m *throughput1Measurer) loop(ctx context.Context) {
6262
log.Debug("Measurer started", "context", ctx)
6363
defer log.Debug("Measurer stopped", "context", ctx)
6464
t, err := memoryless.NewTicker(ctx, memoryless.Config{
@@ -81,7 +81,7 @@ func (m *ndt8Measurer) loop(ctx context.Context) {
8181
}
8282
}
8383

84-
func (m *ndt8Measurer) measure(ctx context.Context) {
84+
func (m *throughput1Measurer) measure(ctx context.Context) {
8585
// On non-Linux systems, collecting kernel metrics WILL fail. In that case,
8686
// we still want to return a (empty) Measurement.
8787
bbrInfo, tcpInfo, err := m.connInfo.Info()
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"time"
55
)
66

7-
// NDT8Result is the struct that is serialized as JSON to disk as the archival
8-
// record of an ndt8 test.
9-
type NDT8Result struct {
7+
// Throughput1Result is the struct that is serialized as JSON to disk as the archival
8+
// record of an throughput1 test.
9+
type Throughput1Result struct {
1010
// GitShortCommit is the Git commit (short form) of the running server code.
1111
GitShortCommit string
1212
// Version is the symbolic version (if any) of the running server code.
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ndt8
1+
package throughput1
22

33
import (
44
"context"
@@ -15,8 +15,8 @@ import (
1515
"github.com/gorilla/websocket"
1616
"github.com/m-lab/msak/internal/measurer"
1717
"github.com/m-lab/msak/internal/netx"
18-
"github.com/m-lab/msak/pkg/ndt8/model"
19-
"github.com/m-lab/msak/pkg/ndt8/spec"
18+
"github.com/m-lab/msak/pkg/throughput1/model"
19+
"github.com/m-lab/msak/pkg/throughput1/spec"
2020
)
2121

2222
type senderFunc func(ctx context.Context,
@@ -27,7 +27,7 @@ type Measurer interface {
2727
Start(context.Context, net.Conn) <-chan model.Measurement
2828
}
2929

30-
// DefaultMeasurer is the default ndt8 measurer that wraps the measurer
30+
// DefaultMeasurer is the default throughput1 measurer that wraps the measurer
3131
// package's Start function.
3232
type DefaultMeasurer struct{}
3333

@@ -36,7 +36,7 @@ func (*DefaultMeasurer) Start(ctx context.Context,
3636
return measurer.Start(ctx, c)
3737
}
3838

39-
// Protocol is the implementation of the ndt8 protocol.
39+
// Protocol is the implementation of the throughput1 protocol.
4040
type Protocol struct {
4141
conn *websocket.Conn
4242
connInfo netx.ConnInfo
@@ -61,7 +61,7 @@ func New(conn *websocket.Conn) *Protocol {
6161
// Upgrade takes a HTTP request and upgrades the connection to WebSocket.
6262
// Returns a websocket Conn if the upgrade succeeded, and an error otherwise.
6363
func Upgrade(w http.ResponseWriter, r *http.Request) (*websocket.Conn, error) {
64-
// We expect WebSocket's subprotocol to be ndt8's. The same subprotocol is
64+
// We expect WebSocket's subprotocol to be throughput1's. The same subprotocol is
6565
// added as a header on the response.
6666
if r.Header.Get("Sec-WebSocket-Protocol") != spec.SecWebSocketProtocol {
6767
w.WriteHeader(http.StatusBadRequest)
@@ -91,7 +91,7 @@ func (p *Protocol) makePreparedMessage(size int) (*websocket.PreparedMessage, er
9191
return websocket.NewPreparedMessage(websocket.BinaryMessage, data)
9292
}
9393

94-
// SenderLoop starts the send loop of the ndt8 protocol. The context's lifetime
94+
// SenderLoop starts the send loop of the throughput1 protocol. The context's lifetime
9595
// determines how long to run for. It returns one channel for sender-side
9696
// measurements, one channel for receiver-side measurements and one channel for
9797
// errors. While the measurements channels could be ignored, the errors channel
@@ -101,7 +101,7 @@ func (p *Protocol) SenderLoop(ctx context.Context) (<-chan model.WireMeasurement
101101
return p.senderReceiverLoop(ctx, p.sender)
102102
}
103103

104-
// ReceiverLoop starts the receiver loop of the ndt8 protocol. The context's
104+
// ReceiverLoop starts the receiver loop of the throughput1 protocol. The context's
105105
// lifetime determines how long to run for. It returns one channel for
106106
// sender-side measurements, one channel for receiver-side measurements and one
107107
// channel for errors. While the measurements channels could be ignored, the

0 commit comments

Comments
 (0)