fix(ooniprobe): use ooniprobe-cli-unattended for unattended runs (#714)
This diff changes the software name used by unattended runs for which we did not override the default software name (`ooniprobe-cli`). It will become `ooniprobe-cli-unattended`. This software name is in line with the one we use for Android, iOS, and desktop unattended runs. While working in this diff, I introduced string constants for the run types and a string constant for the default software name. See https://github.com/ooni/probe/issues/2081.
This commit is contained in:
@@ -412,7 +412,7 @@ func MainWithConfiguration(experimentName string, currentOptions Options) {
|
||||
|
||||
inputLoader := &engine.InputLoader{
|
||||
CheckInConfig: &model.OOAPICheckInConfig{
|
||||
RunType: "manual",
|
||||
RunType: model.RunTypeManual,
|
||||
OnWiFi: true, // meaning: not on 4G
|
||||
Charging: true,
|
||||
},
|
||||
|
||||
@@ -17,7 +17,7 @@ func TestCheckInSuccess(t *testing.T) {
|
||||
Platform: "android",
|
||||
ProbeASN: "AS12353",
|
||||
ProbeCC: "PT",
|
||||
RunType: "timed",
|
||||
RunType: model.RunTypeTimed,
|
||||
SoftwareName: "ooniprobe-android",
|
||||
SoftwareVersion: "2.7.1",
|
||||
WebConnectivity: model.OOAPICheckInConfigWebConnectivity{
|
||||
@@ -54,7 +54,7 @@ func TestCheckInFailure(t *testing.T) {
|
||||
Platform: "android",
|
||||
ProbeASN: "AS12353",
|
||||
ProbeCC: "PT",
|
||||
RunType: "timed",
|
||||
RunType: model.RunTypeTimed,
|
||||
SoftwareName: "ooniprobe-android",
|
||||
SoftwareVersion: "2.7.1",
|
||||
WebConnectivity: model.OOAPICheckInConfigWebConnectivity{
|
||||
|
||||
@@ -238,7 +238,7 @@ func (s *Session) KibiBytesSent() float64 {
|
||||
//
|
||||
// - ProbeCC: if empty, set to Session.ProbeCC();
|
||||
//
|
||||
// - RunType: if empty, set to "timed";
|
||||
// - RunType: if empty, set to model.RunTypeTimed;
|
||||
//
|
||||
// - SoftwareName: if empty, set to Session.SoftwareName();
|
||||
//
|
||||
@@ -270,7 +270,7 @@ func (s *Session) CheckIn(
|
||||
config.ProbeCC = s.ProbeCC()
|
||||
}
|
||||
if config.RunType == "" {
|
||||
config.RunType = "timed" // most conservative choice
|
||||
config.RunType = model.RunTypeTimed // most conservative choice
|
||||
}
|
||||
if config.SoftwareName == "" {
|
||||
config.SoftwareName = s.SoftwareName()
|
||||
|
||||
@@ -107,7 +107,7 @@ func TestSessionCheckInSuccessful(t *testing.T) {
|
||||
if mockedClnt.Config.ProbeCC != "IT" {
|
||||
t.Fatal("invalid Config.ProbeCC")
|
||||
}
|
||||
if mockedClnt.Config.RunType != "timed" {
|
||||
if mockedClnt.Config.RunType != model.RunTypeTimed {
|
||||
t.Fatal("invalid Config.RunType")
|
||||
}
|
||||
if mockedClnt.Config.SoftwareName != "miniooni" {
|
||||
|
||||
@@ -16,7 +16,7 @@ type OOAPICheckInConfig struct {
|
||||
Platform string `json:"platform"` // Platform of the probe
|
||||
ProbeASN string `json:"probe_asn"` // ProbeASN is the probe country code
|
||||
ProbeCC string `json:"probe_cc"` // ProbeCC is the probe country code
|
||||
RunType string `json:"run_type"` // RunType
|
||||
RunType RunType `json:"run_type"` // RunType
|
||||
SoftwareName string `json:"software_name"` // SoftwareName of the probe
|
||||
SoftwareVersion string `json:"software_version"` // SoftwareVersion of the probe
|
||||
WebConnectivity OOAPICheckInConfigWebConnectivity `json:"web_connectivity"` // WebConnectivity class contain an array of categories
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package model
|
||||
|
||||
// RunType describes the type of a ooniprobe run.
|
||||
type RunType string
|
||||
|
||||
const (
|
||||
// RunTypeManual indicates that the user manually run `ooniprobe run`. Command
|
||||
// line tools such as miniooni should always use this run type.
|
||||
RunTypeManual = RunType("manual")
|
||||
|
||||
// RunTypeTimed indicates that the user run `ooniprobe run unattended`, which
|
||||
// is the correct way to run ooniprobe from scripts and cronjobs.
|
||||
RunTypeTimed = RunType("timed")
|
||||
)
|
||||
@@ -1,5 +1,7 @@
|
||||
package apimodel
|
||||
|
||||
import "github.com/ooni/probe-cli/v3/internal/model"
|
||||
|
||||
// CheckInRequestWebConnectivity contains WebConnectivity
|
||||
// specific parameters to include into CheckInRequest
|
||||
type CheckInRequestWebConnectivity struct {
|
||||
@@ -13,7 +15,7 @@ type CheckInRequest struct {
|
||||
Platform string `json:"platform"`
|
||||
ProbeASN string `json:"probe_asn"`
|
||||
ProbeCC string `json:"probe_cc"`
|
||||
RunType string `json:"run_type"`
|
||||
RunType model.RunType `json:"run_type"`
|
||||
SoftwareName string `json:"software_name"`
|
||||
SoftwareVersion string `json:"software_version"`
|
||||
WebConnectivity CheckInRequestWebConnectivity `json:"web_connectivity"`
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"log"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/kvstore"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/ooapi"
|
||||
"github.com/ooni/probe-cli/v3/internal/ooapi/apimodel"
|
||||
)
|
||||
@@ -21,7 +22,7 @@ func ExampleClient() {
|
||||
Platform: "linux",
|
||||
ProbeASN: "AS30722",
|
||||
ProbeCC: "IT",
|
||||
RunType: "timed",
|
||||
RunType: model.RunTypeTimed,
|
||||
SoftwareName: "miniooni",
|
||||
SoftwareVersion: "0.1.0-dev",
|
||||
WebConnectivity: apimodel.CheckInRequestWebConnectivity{
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/kvstore"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/ooapi"
|
||||
"github.com/ooni/probe-cli/v3/internal/ooapi/apimodel"
|
||||
)
|
||||
@@ -19,7 +20,7 @@ func TestWithRealServerDoCheckIn(t *testing.T) {
|
||||
Platform: "android",
|
||||
ProbeASN: "AS12353",
|
||||
ProbeCC: "IT",
|
||||
RunType: "timed",
|
||||
RunType: model.RunTypeTimed,
|
||||
SoftwareName: "ooniprobe-android",
|
||||
SoftwareVersion: "2.7.1",
|
||||
WebConnectivity: apimodel.CheckInRequestWebConnectivity{
|
||||
|
||||
Reference in New Issue
Block a user