feat(ExperimentOrchestraClient): add CheckIn (#263)
We use ExperimentOrchestraClient in several places to help us calling probe-services APIs. We need to call CheckIn because we want to use CheckIn in InputLoader. (We also want to remove the URLs API, but that is not something doable now, since the mobile app is still using this API via the wrappers at pkg/oonimkall.) Work part of https://github.com/ooni/probe/issues/1299.
This commit is contained in:
parent
576059b3fa
commit
3b029ee0d6
|
@ -80,6 +80,10 @@ func TestInputLoaderNewOrchestraClientFailure(t *testing.T) {
|
||||||
|
|
||||||
type InputLoaderBrokenOrchestraClient struct{}
|
type InputLoaderBrokenOrchestraClient struct{}
|
||||||
|
|
||||||
|
func (InputLoaderBrokenOrchestraClient) CheckIn(ctx context.Context, config model.CheckInConfig) (*model.CheckInInfo, error) {
|
||||||
|
return nil, io.EOF
|
||||||
|
}
|
||||||
|
|
||||||
func (InputLoaderBrokenOrchestraClient) FetchPsiphonConfig(ctx context.Context) ([]byte, error) {
|
func (InputLoaderBrokenOrchestraClient) FetchPsiphonConfig(ctx context.Context) ([]byte, error) {
|
||||||
return nil, io.EOF
|
return nil, io.EOF
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,6 +162,8 @@ var _ torx.Session = &Session{}
|
||||||
// ExperimentOrchestraClient is the experiment's view of
|
// ExperimentOrchestraClient is the experiment's view of
|
||||||
// a client for querying the OONI orchestra.
|
// a client for querying the OONI orchestra.
|
||||||
type ExperimentOrchestraClient struct {
|
type ExperimentOrchestraClient struct {
|
||||||
|
MockableCheckInInfo *model.CheckInInfo
|
||||||
|
MockableCheckInErr error
|
||||||
MockableFetchPsiphonConfigResult []byte
|
MockableFetchPsiphonConfigResult []byte
|
||||||
MockableFetchPsiphonConfigErr error
|
MockableFetchPsiphonConfigErr error
|
||||||
MockableFetchTorTargetsResult map[string]model.TorTarget
|
MockableFetchTorTargetsResult map[string]model.TorTarget
|
||||||
|
@ -170,6 +172,12 @@ type ExperimentOrchestraClient struct {
|
||||||
MockableFetchURLListErr error
|
MockableFetchURLListErr error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckIn implements ExperimentOrchestraClient.CheckIn.
|
||||||
|
func (c ExperimentOrchestraClient) CheckIn(
|
||||||
|
ctx context.Context, config model.CheckInConfig) (*model.CheckInInfo, error) {
|
||||||
|
return c.MockableCheckInInfo, c.MockableCheckInErr
|
||||||
|
}
|
||||||
|
|
||||||
// FetchPsiphonConfig implements ExperimentOrchestraClient.FetchPsiphonConfig
|
// FetchPsiphonConfig implements ExperimentOrchestraClient.FetchPsiphonConfig
|
||||||
func (c ExperimentOrchestraClient) FetchPsiphonConfig(
|
func (c ExperimentOrchestraClient) FetchPsiphonConfig(
|
||||||
ctx context.Context) ([]byte, error) {
|
ctx context.Context) ([]byte, error) {
|
||||||
|
|
|
@ -8,8 +8,17 @@ import (
|
||||||
// ExperimentOrchestraClient is the experiment's view of
|
// ExperimentOrchestraClient is the experiment's view of
|
||||||
// a client for querying the OONI orchestra API.
|
// a client for querying the OONI orchestra API.
|
||||||
type ExperimentOrchestraClient interface {
|
type ExperimentOrchestraClient interface {
|
||||||
|
// CheckIn calls the check-in API.
|
||||||
|
CheckIn(ctx context.Context, config CheckInConfig) (*CheckInInfo, error)
|
||||||
|
|
||||||
|
// FetchPsiphonConfig returns psiphon config from the API.
|
||||||
FetchPsiphonConfig(ctx context.Context) ([]byte, error)
|
FetchPsiphonConfig(ctx context.Context) ([]byte, error)
|
||||||
|
|
||||||
|
// FetchTorTargets returns tor targets from the API.
|
||||||
FetchTorTargets(ctx context.Context, cc string) (map[string]TorTarget, error)
|
FetchTorTargets(ctx context.Context, cc string) (map[string]TorTarget, error)
|
||||||
|
|
||||||
|
// FetchURLList returns URLs from the API.
|
||||||
|
// This method is deprecated and will be removed soon.
|
||||||
FetchURLList(ctx context.Context, config URLListConfig) ([]URLInfo, error)
|
FetchURLList(ctx context.Context, config URLListConfig) ([]URLInfo, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -315,7 +315,7 @@ func TestMaxRuntime(t *testing.T) {
|
||||||
// In case there are further timeouts, e.g. in the sessionresolver, the
|
// In case there are further timeouts, e.g. in the sessionresolver, the
|
||||||
// time used by the experiment will be much more. This is for example the
|
// time used by the experiment will be much more. This is for example the
|
||||||
// case in https://github.com/ooni/probe-engine/issues/1005.
|
// case in https://github.com/ooni/probe-engine/issues/1005.
|
||||||
if time.Now().Sub(begin) > 10*time.Second {
|
if time.Since(begin) > 10*time.Second {
|
||||||
t.Fatal("expected shorter runtime")
|
t.Fatal("expected shorter runtime")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user