refactor: remove model.ExperimentOrchestraClient (#284)
* ongoing * while there, make sure we test everything * reorganize previous commit * ensure we have reasonable coverage in session The code in here would be better with unit tests. We have too many integration tests and the tests overall are too slow. But it's also true that I should not write a giant diff as part of this PR.
This commit is contained in:
parent
4700ba791d
commit
79e8424677
12 changed files with 200 additions and 210 deletions
|
|
@ -55,6 +55,11 @@ type TargetResults struct {
|
|||
TargetSource string `json:"target_source,omitempty"`
|
||||
TCPConnect oonidatamodel.TCPConnectList `json:"tcp_connect"`
|
||||
TLSHandshakes oonidatamodel.TLSHandshakesList `json:"tls_handshakes"`
|
||||
|
||||
// Only for testing. We don't care about this field otherwise. We
|
||||
// cannot make this private because otherwise the IP address sanitizer
|
||||
// is going to panic over a private field.
|
||||
DirPortCount int `json:"-"`
|
||||
}
|
||||
|
||||
func registerExtensions(m *model.Measurement) {
|
||||
|
|
@ -78,6 +83,7 @@ func (tr *TargetResults) fillSummary() {
|
|||
case "dir_port":
|
||||
// The UI currently doesn't care about this protocol
|
||||
// as long as drawing a table is concerned.
|
||||
tr.DirPortCount++
|
||||
case "obfs4":
|
||||
// We currently only perform an OBFS4 handshake, hence
|
||||
// the final Failure is the handshake result
|
||||
|
|
@ -136,20 +142,16 @@ func (tk *TestKeys) fillToplevelKeys() {
|
|||
|
||||
// Measurer performs the measurement.
|
||||
type Measurer struct {
|
||||
config Config
|
||||
fetchTorTargets func(ctx context.Context, clnt model.ExperimentOrchestraClient, cc string) (map[string]model.TorTarget, error)
|
||||
newOrchestraClient func(ctx context.Context, sess model.ExperimentSession) (model.ExperimentOrchestraClient, error)
|
||||
config Config
|
||||
fetchTorTargets func(ctx context.Context, sess model.ExperimentSession, cc string) (map[string]model.TorTarget, error)
|
||||
}
|
||||
|
||||
// NewMeasurer creates a new Measurer
|
||||
func NewMeasurer(config Config) *Measurer {
|
||||
return &Measurer{
|
||||
config: config,
|
||||
fetchTorTargets: func(ctx context.Context, clnt model.ExperimentOrchestraClient, cc string) (map[string]model.TorTarget, error) {
|
||||
return clnt.FetchTorTargets(ctx, cc)
|
||||
},
|
||||
newOrchestraClient: func(ctx context.Context, sess model.ExperimentSession) (model.ExperimentOrchestraClient, error) {
|
||||
return sess.NewOrchestraClient(ctx)
|
||||
fetchTorTargets: func(ctx context.Context, sess model.ExperimentSession, cc string) (map[string]model.TorTarget, error) {
|
||||
return sess.FetchTorTargets(ctx, cc)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -189,11 +191,7 @@ func (m *Measurer) gimmeTargets(
|
|||
) (map[string]model.TorTarget, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
|
||||
defer cancel()
|
||||
clnt, err := m.newOrchestraClient(ctx, sess)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m.fetchTorTargets(ctx, clnt, sess.ProbeCC())
|
||||
return m.fetchTorTargets(ctx, sess, sess.ProbeCC())
|
||||
}
|
||||
|
||||
// keytarget contains a key and the related target
|
||||
|
|
|
|||
Loading…
Reference in a new issue