diff --git a/plugins/inputs/tail/tail_test.go b/plugins/inputs/tail/tail_test.go index a66863da0..e9e2bcdbf 100644 --- a/plugins/inputs/tail/tail_test.go +++ b/plugins/inputs/tail/tail_test.go @@ -204,7 +204,8 @@ func TestGrokParseLogFilesWithMultiline(t *testing.T) { }) acc.AssertContainsTaggedFields(t, "tail_grok", map[string]interface{}{ - "message": "HelloExample: Sorry, something wrong! java.lang.ArithmeticException: / by zero\tat com.foo.HelloExample2.divide(HelloExample2.java:24)\tat com.foo.HelloExample2.main(HelloExample2.java:14)", + "message": "HelloExample: Sorry, something wrong! java.lang.ArithmeticException: / by zero\t" + + "at com.foo.HelloExample2.divide(HelloExample2.java:24)\tat com.foo.HelloExample2.main(HelloExample2.java:14)", }, map[string]string{ "path": expectedPath, diff --git a/plugins/inputs/teamspeak/teamspeak_test.go b/plugins/inputs/teamspeak/teamspeak_test.go index 98fc51948..4d56f5834 100644 --- a/plugins/inputs/teamspeak/teamspeak_test.go +++ b/plugins/inputs/teamspeak/teamspeak_test.go @@ -6,19 +6,54 @@ import ( "strings" "testing" - "github.com/influxdata/telegraf/testutil" "github.com/stretchr/testify/require" + + "github.com/influxdata/telegraf/testutil" ) -const welcome = `Welcome to the TeamSpeak 3 ServerQuery interface, type "help" for a list of commands and "help " for information on a specific command.` +const welcome = `Welcome to the TeamSpeak 3 ServerQuery interface, type "help" for a list of commands and ` + + `"help " for information on a specific command.` const ok = `error id=0 msg=ok` const errorMsg = `error id=256 msg=command\snot\sfound` var cmd = map[string]string{ - "login": "", - "use": "", - "serverinfo": `virtualserver_unique_identifier=a1vn9PLF8CMIU virtualserver_name=Testserver virtualserver_welcomemessage=Test virtualserver_platform=Linux virtualserver_version=3.0.13.8\s[Build:\s1500452811] virtualserver_maxclients=32 virtualserver_password virtualserver_clientsonline=2 virtualserver_channelsonline=1 virtualserver_created=1507400243 virtualserver_uptime=148 virtualserver_codec_encryption_mode=0 virtualserver_hostmessage virtualserver_hostmessage_mode=0 virtualserver_filebase=files\/virtualserver_1 virtualserver_default_server_group=8 virtualserver_default_channel_group=8 virtualserver_flag_password=0 virtualserver_default_channel_admin_group=5 virtualserver_max_download_total_bandwidth=18446744073709551615 virtualserver_max_upload_total_bandwidth=18446744073709551615 virtualserver_hostbanner_url virtualserver_hostbanner_gfx_url virtualserver_hostbanner_gfx_interval=0 virtualserver_complain_autoban_count=5 virtualserver_complain_autoban_time=1200 virtualserver_complain_remove_time=3600 virtualserver_min_clients_in_channel_before_forced_silence=100 virtualserver_priority_speaker_dimm_modificator=-18.0000 virtualserver_id=1 virtualserver_antiflood_points_tick_reduce=5 virtualserver_antiflood_points_needed_command_block=150 virtualserver_antiflood_points_needed_ip_block=250 virtualserver_client_connections=1 virtualserver_query_client_connections=1 virtualserver_hostbutton_tooltip virtualserver_hostbutton_url virtualserver_hostbutton_gfx_url virtualserver_queryclientsonline=1 virtualserver_download_quota=18446744073709551615 virtualserver_upload_quota=18446744073709551615 virtualserver_month_bytes_downloaded=0 virtualserver_month_bytes_uploaded=0 virtualserver_total_bytes_downloaded=0 virtualserver_total_bytes_uploaded=0 virtualserver_port=9987 virtualserver_autostart=1 virtualserver_machine_id virtualserver_needed_identity_security_level=8 virtualserver_log_client=0 virtualserver_log_query=0 virtualserver_log_channel=0 virtualserver_log_permissions=1 virtualserver_log_server=0 virtualserver_log_filetransfer=0 virtualserver_min_client_version=1445512488 virtualserver_name_phonetic virtualserver_icon_id=0 virtualserver_reserved_slots=0 virtualserver_total_packetloss_speech=0.0000 virtualserver_total_packetloss_keepalive=0.0000 virtualserver_total_packetloss_control=0.0000 virtualserver_total_packetloss_total=0.0000 virtualserver_total_ping=1.0000 virtualserver_ip=0.0.0.0,\s:: virtualserver_weblist_enabled=1 virtualserver_ask_for_privilegekey=0 virtualserver_hostbanner_mode=0 virtualserver_channel_temp_delete_delay_default=0 virtualserver_min_android_version=1407159763 virtualserver_min_ios_version=1407159763 virtualserver_status=online connection_filetransfer_bandwidth_sent=0 connection_filetransfer_bandwidth_received=0 connection_filetransfer_bytes_sent_total=0 connection_filetransfer_bytes_received_total=0 connection_packets_sent_speech=0 connection_bytes_sent_speech=0 connection_packets_received_speech=0 connection_bytes_received_speech=0 connection_packets_sent_keepalive=261 connection_bytes_sent_keepalive=10701 connection_packets_received_keepalive=261 connection_bytes_received_keepalive=10961 connection_packets_sent_control=54 connection_bytes_sent_control=15143 connection_packets_received_control=55 connection_bytes_received_control=4239 connection_packets_sent_total=315 connection_bytes_sent_total=25844 connection_packets_received_total=316 connection_bytes_received_total=15200 connection_bandwidth_sent_last_second_total=81 connection_bandwidth_sent_last_minute_total=141 connection_bandwidth_received_last_second_total=83 connection_bandwidth_received_last_minute_total=98`, - "serverrequestconnectioninfo": `connection_filetransfer_bandwidth_sent=0 connection_filetransfer_bandwidth_received=0 connection_filetransfer_bytes_sent_total=0 connection_filetransfer_bytes_received_total=0 connection_packets_sent_total=369 connection_bytes_sent_total=28058 connection_packets_received_total=370 connection_bytes_received_total=17468 connection_bandwidth_sent_last_second_total=81 connection_bandwidth_sent_last_minute_total=109 connection_bandwidth_received_last_second_total=83 connection_bandwidth_received_last_minute_total=94 connection_connected_time=174 connection_packetloss_total=0.0000 connection_ping=1.0000`, + "login": "", + "use": "", + "serverinfo": `virtualserver_unique_identifier=a1vn9PLF8CMIU virtualserver_name=Testserver ` + + `virtualserver_welcomemessage=Test virtualserver_platform=Linux virtualserver_version=3.0.13.8\s[Build:\s1500452811] ` + + `virtualserver_maxclients=32 virtualserver_password virtualserver_clientsonline=2 virtualserver_channelsonline=1 ` + + `virtualserver_created=1507400243 virtualserver_uptime=148 virtualserver_codec_encryption_mode=0 virtualserver_hostmessage ` + + `virtualserver_hostmessage_mode=0 virtualserver_filebase=files\/virtualserver_1 virtualserver_default_server_group=8 ` + + `virtualserver_default_channel_group=8 virtualserver_flag_password=0 virtualserver_default_channel_admin_group=5 ` + + `virtualserver_max_download_total_bandwidth=18446744073709551615 virtualserver_max_upload_total_bandwidth=18446744073709551615 ` + + `virtualserver_hostbanner_url virtualserver_hostbanner_gfx_url virtualserver_hostbanner_gfx_interval=0 ` + + `virtualserver_complain_autoban_count=5 virtualserver_complain_autoban_time=1200 virtualserver_complain_remove_time=3600 ` + + `virtualserver_min_clients_in_channel_before_forced_silence=100 virtualserver_priority_speaker_dimm_modificator=-18.0000 ` + + `virtualserver_id=1 virtualserver_antiflood_points_tick_reduce=5 virtualserver_antiflood_points_needed_command_block=150 ` + + `virtualserver_antiflood_points_needed_ip_block=250 virtualserver_client_connections=1 virtualserver_query_client_connections=1 ` + + `virtualserver_hostbutton_tooltip virtualserver_hostbutton_url virtualserver_hostbutton_gfx_url virtualserver_queryclientsonline=1 ` + + `virtualserver_download_quota=18446744073709551615 virtualserver_upload_quota=18446744073709551615 virtualserver_month_bytes_downloaded=0 ` + + `virtualserver_month_bytes_uploaded=0 virtualserver_total_bytes_downloaded=0 virtualserver_total_bytes_uploaded=0 virtualserver_port=9987 ` + + `virtualserver_autostart=1 virtualserver_machine_id virtualserver_needed_identity_security_level=8 virtualserver_log_client=0 ` + + `virtualserver_log_query=0 virtualserver_log_channel=0 virtualserver_log_permissions=1 virtualserver_log_server=0 ` + + `virtualserver_log_filetransfer=0 virtualserver_min_client_version=1445512488 virtualserver_name_phonetic virtualserver_icon_id=0 ` + + `virtualserver_reserved_slots=0 virtualserver_total_packetloss_speech=0.0000 virtualserver_total_packetloss_keepalive=0.0000 ` + + `virtualserver_total_packetloss_control=0.0000 virtualserver_total_packetloss_total=0.0000 virtualserver_total_ping=1.0000 ` + + `virtualserver_ip=0.0.0.0,\s:: virtualserver_weblist_enabled=1 virtualserver_ask_for_privilegekey=0 virtualserver_hostbanner_mode=0 ` + + `virtualserver_channel_temp_delete_delay_default=0 virtualserver_min_android_version=1407159763 virtualserver_min_ios_version=1407159763 ` + + `virtualserver_status=online connection_filetransfer_bandwidth_sent=0 connection_filetransfer_bandwidth_received=0 ` + + `connection_filetransfer_bytes_sent_total=0 connection_filetransfer_bytes_received_total=0 connection_packets_sent_speech=0 ` + + `connection_bytes_sent_speech=0 connection_packets_received_speech=0 connection_bytes_received_speech=0 connection_packets_sent_keepalive=261 ` + + `connection_bytes_sent_keepalive=10701 connection_packets_received_keepalive=261 connection_bytes_received_keepalive=10961 ` + + `connection_packets_sent_control=54 connection_bytes_sent_control=15143 connection_packets_received_control=55 ` + + `connection_bytes_received_control=4239 connection_packets_sent_total=315 connection_bytes_sent_total=25844 connection_packets_received_total=316 ` + + `connection_bytes_received_total=15200 connection_bandwidth_sent_last_second_total=81 connection_bandwidth_sent_last_minute_total=141 ` + + `connection_bandwidth_received_last_second_total=83 connection_bandwidth_received_last_minute_total=98`, + "serverrequestconnectioninfo": `connection_filetransfer_bandwidth_sent=0 connection_filetransfer_bandwidth_received=0 ` + + `connection_filetransfer_bytes_sent_total=0 connection_filetransfer_bytes_received_total=0 connection_packets_sent_total=369 ` + + `connection_bytes_sent_total=28058 connection_packets_received_total=370 connection_bytes_received_total=17468 ` + + `connection_bandwidth_sent_last_second_total=81 connection_bandwidth_sent_last_minute_total=109 connection_bandwidth_received_last_second_total=83 ` + + `connection_bandwidth_received_last_minute_total=94 connection_connected_time=174 connection_packetloss_total=0.0000 connection_ping=1.0000`, } func TestGather(t *testing.T) { diff --git a/plugins/inputs/tomcat/tomcat_test.go b/plugins/inputs/tomcat/tomcat_test.go index 9ba7affe5..840e4f9b0 100644 --- a/plugins/inputs/tomcat/tomcat_test.go +++ b/plugins/inputs/tomcat/tomcat_test.go @@ -6,35 +6,36 @@ import ( "net/http/httptest" "testing" - "github.com/influxdata/telegraf/testutil" - "github.com/stretchr/testify/require" + + "github.com/influxdata/telegraf/testutil" ) var tomcatStatus8 = ` - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + ` func TestHTTPTomcat8(t *testing.T) { @@ -107,17 +108,19 @@ func TestHTTPTomcat8(t *testing.T) { var tomcatStatus6 = ` - - - - - - - - - - - + + + + + + + + + + + ` func TestHTTPTomcat6(t *testing.T) { diff --git a/plugins/inputs/varnish/varnish.go b/plugins/inputs/varnish/varnish.go index c84a55816..0c3b633ea 100644 --- a/plugins/inputs/varnish/varnish.go +++ b/plugins/inputs/varnish/varnish.go @@ -36,8 +36,11 @@ var ( //vcl name and backend restriction regexp [A-Za-z][A-Za-z0-9_-]* defaultRegexps = []*regexp.Regexp{ //dynamic backends + //nolint:lll,revive // conditionally long line allowed to have a better understanding of following regexp //VBE.VCL_xxxx_xxx_VOD_SHIELD_Vxxxxxxxxxxxxx_xxxxxxxxxxxxx.goto.000007c8.(xx.xx.xxx.xx).(http://xxxxxxx-xxxxx-xxxxx-xxxxxx-xx-xxxx-x-xxxx.xx-xx-xxxx-x.amazonaws.com:80).(ttl:5.000000).fail_eaddrnotavail - regexp.MustCompile(`^VBE\.(?P<_vcl>[\w\-]*)\.goto\.[[:alnum:]]+\.\((?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\)\.\((?P.*)\)\.\(ttl:\d*\.\d*.*\)`), + regexp.MustCompile( + `^VBE\.(?P<_vcl>[\w\-]*)\.goto\.[[:alnum:]]+\.\((?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\)\.\((?P.*)\)\.\(ttl:\d*\.\d*.*\)`, + ), //VBE.reload_20210622_153544_23757.default.unhealthy regexp.MustCompile(`^VBE\.(?P<_vcl>[\w\-]*)\.(?P[\w\-]*)\.([\w\-]*)`), diff --git a/plugins/inputs/varnish/varnish_test.go b/plugins/inputs/varnish/varnish_test.go index d22008b32..f671f76a2 100644 --- a/plugins/inputs/varnish/varnish_test.go +++ b/plugins/inputs/varnish/varnish_test.go @@ -507,13 +507,17 @@ func TestV2ParseVarnishNames(t *testing.T) { activeVcl: "1111", }, { - vName: "VBE.VCL_1023_DIS_VOD_SHIELD_V1629295401194_1629295437531.goto.00000000.(111.112.113.114).(http://abc-ede.xyz.yyy.com:80).(ttl:3600.000000).is_healthy", - tags: map[string]string{"section": "VBE", "serial_1": "0", "backend_1": "111.112.113.114", "server_1": "http://abc-ede.xyz.yyy.com:80", "ttl": "3600.000000"}, + vName: "VBE.VCL_1023_DIS_VOD_SHIELD_V1629295401194_1629295437531.goto.00000000.(111.112.113.114)." + + "(http://abc-ede.xyz.yyy.com:80).(ttl:3600.000000).is_healthy", + tags: map[string]string{"section": "VBE", "serial_1": "0", "backend_1": "111.112.113.114", + "server_1": "http://abc-ede.xyz.yyy.com:80", "ttl": "3600.000000"}, field: "is_healthy", activeVcl: "VCL_1023_DIS_VOD_SHIELD_V1629295401194_1629295437531", customRegexps: []string{ - `^VBE\.(?P<_vcl>[\w\-]*)\.goto\.(?P[[:alnum:]])+\.\((?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\)\.\((?P.*)\)\.\(ttl:(?P\d*\.\d*.)*\)`, - `^VBE\.(?P<_vcl>[\w\-]*)\.goto\.(?P[[:alnum:]])+\.\((?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\)\.\((?P.*)\)\.\(ttl:(?P\d*\.\d*.)*\)`, + `^VBE\.(?P<_vcl>[\w\-]*)\.goto\.(?P[[:alnum:]])+\.` + + `\((?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\)\.\((?P.*)\)\.\(ttl:(?P\d*\.\d*.)*\)`, + `^VBE\.(?P<_vcl>[\w\-]*)\.goto\.(?P[[:alnum:]])+\.` + + `\((?P\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\)\.\((?P.*)\)\.\(ttl:(?P\d*\.\d*.)*\)`, }, }, } { diff --git a/plugins/inputs/vsphere/endpoint.go b/plugins/inputs/vsphere/endpoint.go index f71a454f9..279306da8 100644 --- a/plugins/inputs/vsphere/endpoint.go +++ b/plugins/inputs/vsphere/endpoint.go @@ -14,12 +14,12 @@ import ( "sync/atomic" "time" - "github.com/influxdata/telegraf" "github.com/vmware/govmomi/object" "github.com/vmware/govmomi/performance" "github.com/vmware/govmomi/vim25/mo" "github.com/vmware/govmomi/vim25/types" + "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/filter" ) @@ -369,7 +369,13 @@ func (e *Endpoint) getDatacenterName(ctx context.Context, client *Client, cache return e.getAncestorName(ctx, client, "Datacenter", cache, r) } -func (e *Endpoint) getAncestorName(ctx context.Context, client *Client, resourceType string, cache map[string]string, r types.ManagedObjectReference) (string, bool) { +func (e *Endpoint) getAncestorName( + ctx context.Context, + client *Client, + resourceType string, + cache map[string]string, + r types.ManagedObjectReference, +) (string, bool) { path := make([]string, 0) returnVal := "" here := r @@ -1139,7 +1145,13 @@ func (e *Endpoint) alignSamples(info []types.PerfSampleInfo, values []int64, int return rInfo, rValues } -func (e *Endpoint) collectChunk(ctx context.Context, pqs queryChunk, res *resourceKind, acc telegraf.Accumulator, interval time.Duration) (int, time.Time, error) { +func (e *Endpoint) collectChunk( + ctx context.Context, + pqs queryChunk, + res *resourceKind, + acc telegraf.Accumulator, + interval time.Duration, +) (int, time.Time, error) { e.log.Debugf("Query for %s has %d QuerySpecs", res.name, len(pqs)) latestSample := time.Time{} count := 0 diff --git a/plugins/inputs/webhooks/artifactory/artifactory_webhook_test.go b/plugins/inputs/webhooks/artifactory/artifactory_webhook_test.go index 7c731487e..54d2273e9 100644 --- a/plugins/inputs/webhooks/artifactory/artifactory_webhook_test.go +++ b/plugins/inputs/webhooks/artifactory/artifactory_webhook_test.go @@ -136,7 +136,13 @@ func TestDestinationDeleteFailedEvent(t *testing.T) { } func TestEventWithSignatureSuccess(t *testing.T) { - ArtifactoryWebhookRequestWithSignature("watch", ArtifactDeployedEventJSON(), t, generateSignature("signature", []byte(ArtifactDeployedEventJSON())), http.StatusOK) + ArtifactoryWebhookRequestWithSignature( + "watch", + ArtifactDeployedEventJSON(), + t, + generateSignature("signature", []byte(ArtifactDeployedEventJSON())), + http.StatusOK, + ) } func TestCheckSignatureSuccess(t *testing.T) { diff --git a/plugins/inputs/webhooks/filestack/filestack_webhooks_events_json_test.go b/plugins/inputs/webhooks/filestack/filestack_webhooks_events_json_test.go deleted file mode 100644 index 351de01b4..000000000 --- a/plugins/inputs/webhooks/filestack/filestack_webhooks_events_json_test.go +++ /dev/null @@ -1,110 +0,0 @@ -package filestack - -func DialogOpenJSON() string { - return `{ - "action": "fp.dialog", - "timestamp": 1435584646, - "id": 102, - "text": { - "mimetypes": ["*/*"], - "iframe": false, - "language": "en", - "id": "1435584650723", - "mobile": false, - "app":{ - "upsell": "false", - "apikey": "YOUR_API_KEY", - "customization":{ - "saveas_subheader": "Save it down to your local device or onto the Cloud", - "folder_subheader": "Choose a folder to share with this application", - "open_subheader": "Choose from the files on your local device or the ones you have online", - "folder_header": "Select a folder", - "help_text": "", - "saveas_header": "Save your file", - "open_header": "Upload a file" - } - }, - "dialogType": "open", - "auth": false, - "welcome_header": "Upload a file", - "welcome_subheader": "Choose from the files on your local device or the ones you have online", - "help_text": "", - "recent_path": "/", - "extensions": null, - "maxSize": 0, - "signature": null, - "policy": null, - "custom_providers": "imgur,cloudapp", - "intra": false - } - }` -} - -func UploadJSON() string { - return `{ - "action":"fp.upload", - "timestamp":1443444905, - "id":100946, - "text":{ - "url":"https://www.filestackapi.com/api/file/WAunDTTqQfCNWwUUyf6n", - "client":"Facebook", - "type":"image/jpeg", - "filename":"1579337399020824.jpg", - "size":139154 - } - }` -} - -func VideoConversionJSON() string { - return `{ - "status":"completed", - "message":"Done", - "data":{ - "thumb":"https://cdn.filestackcontent.com/f1e8V88QDuxzOvtOAq1W", - "thumb100x100":"https://process.filestackapi.com/AhTgLagciQByzXpFGRI0Az/resize=w:100,h:100,f:crop/output=f:jpg,q:66/https://cdn.filestackcontent.com/f1e8V88QDuxzOvtOAq1W", - "thumb200x200":"https://process.filestackapi.com/AhTgLagciQByzXpFGRI0Az/resize=w:200,h:200,f:crop/output=f:jpg,q:66/https://cdn.filestackcontent.com/f1e8V88QDuxzOvtOAq1W", - "thumb300x300":"https://process.filestackapi.com/AhTgLagciQByzXpFGRI0Az/resize=w:300,h:300,f:crop/output=f:jpg,q:66/https://cdn.filestackcontent.com/f1e8V88QDuxzOvtOAq1W", - "url":"https://cdn.filestackcontent.com/VgvFVdvvTkml0WXPIoGn" - }, - "metadata":{ - "result":{ - "audio_channels":2, - "audio_codec":"vorbis", - "audio_sample_rate":44100, - "created_at":"2015/12/21 20:45:19 +0000", - "duration":10587, - "encoding_progress":100, - "encoding_time":8, - "extname":".webm", - "file_size":293459, - "fps":24, - "height":260, - "mime_type":"video/webm", - "started_encoding_at":"2015/12/21 20:45:22 +0000", - "updated_at":"2015/12/21 20:45:32 +0000", - "video_bitrate":221, - "video_codec":"vp8", - "width":300 - }, - "source":{ - "audio_bitrate":125, - "audio_channels":2, - "audio_codec":"aac", - "audio_sample_rate":44100, - "created_at":"2015/12/21 20:45:19 +0000", - "duration":10564, - "extname":".mp4", - "file_size":875797, - "fps":24, - "height":360, - "mime_type":"video/mp4", - "updated_at":"2015/12/21 20:45:32 +0000", - "video_bitrate":196, - "video_codec":"h264", - "width":480 - } - }, - "timestamp":"1453850583", - "uuid":"638311d89d2bc849563a674a45809b7c" - }` -} diff --git a/plugins/inputs/webhooks/filestack/filestack_webhooks_test.go b/plugins/inputs/webhooks/filestack/filestack_webhooks_test.go index 13f69e5cb..6f61f9f12 100644 --- a/plugins/inputs/webhooks/filestack/filestack_webhooks_test.go +++ b/plugins/inputs/webhooks/filestack/filestack_webhooks_test.go @@ -1,16 +1,20 @@ package filestack import ( - "github.com/influxdata/telegraf/testutil" + "io" "net/http" "net/http/httptest" - + "os" "strings" "testing" + + "github.com/stretchr/testify/require" + + "github.com/influxdata/telegraf/testutil" ) -func postWebhooks(md *FilestackWebhook, eventBody string) *httptest.ResponseRecorder { - req, _ := http.NewRequest("POST", "/filestack", strings.NewReader(eventBody)) +func postWebhooks(md *FilestackWebhook, eventBodyFile io.Reader) *httptest.ResponseRecorder { + req, _ := http.NewRequest("POST", "/filestack", eventBodyFile) w := httptest.NewRecorder() md.eventHandler(w, req) @@ -21,7 +25,7 @@ func postWebhooks(md *FilestackWebhook, eventBody string) *httptest.ResponseReco func TestDialogEvent(t *testing.T) { var acc testutil.Accumulator fs := &FilestackWebhook{Path: "/filestack", acc: &acc} - resp := postWebhooks(fs, DialogOpenJSON()) + resp := postWebhooks(fs, getFile(t, "testdata/dialog_open.json")) if resp.Code != http.StatusOK { t.Errorf("POST returned HTTP status code %v.\nExpected %v", resp.Code, http.StatusOK) } @@ -39,7 +43,7 @@ func TestDialogEvent(t *testing.T) { func TestParseError(t *testing.T) { fs := &FilestackWebhook{Path: "/filestack"} - resp := postWebhooks(fs, "") + resp := postWebhooks(fs, strings.NewReader("")) if resp.Code != http.StatusBadRequest { t.Errorf("POST returned HTTP status code %v.\nExpected %v", resp.Code, http.StatusBadRequest) } @@ -48,7 +52,7 @@ func TestParseError(t *testing.T) { func TestUploadEvent(t *testing.T) { var acc testutil.Accumulator fs := &FilestackWebhook{Path: "/filestack", acc: &acc} - resp := postWebhooks(fs, UploadJSON()) + resp := postWebhooks(fs, getFile(t, "testdata/upload.json")) if resp.Code != http.StatusOK { t.Errorf("POST returned HTTP status code %v.\nExpected %v", resp.Code, http.StatusOK) } @@ -67,8 +71,15 @@ func TestUploadEvent(t *testing.T) { func TestVideoConversionEvent(t *testing.T) { var acc testutil.Accumulator fs := &FilestackWebhook{Path: "/filestack", acc: &acc} - resp := postWebhooks(fs, VideoConversionJSON()) + resp := postWebhooks(fs, getFile(t, "testdata/video_conversion.json")) if resp.Code != http.StatusBadRequest { t.Errorf("POST returned HTTP status code %v.\nExpected %v", resp.Code, http.StatusBadRequest) } } + +func getFile(t *testing.T, filePath string) io.Reader { + file, err := os.Open(filePath) + require.NoErrorf(t, err, "could not read from file %s", filePath) + + return file +} diff --git a/plugins/inputs/webhooks/filestack/testdata/dialog_open.json b/plugins/inputs/webhooks/filestack/testdata/dialog_open.json new file mode 100644 index 000000000..eb5b38183 --- /dev/null +++ b/plugins/inputs/webhooks/filestack/testdata/dialog_open.json @@ -0,0 +1,39 @@ +{ + "action": "fp.dialog", + "timestamp": 1435584646, + "id": 102, + "text": { + "mimetypes": [ + "*/*" + ], + "iframe": false, + "language": "en", + "id": "1435584650723", + "mobile": false, + "app": { + "upsell": "false", + "apikey": "YOUR_API_KEY", + "customization": { + "saveas_subheader": "Save it down to your local device or onto the Cloud", + "folder_subheader": "Choose a folder to share with this application", + "open_subheader": "Choose from the files on your local device or the ones you have online", + "folder_header": "Select a folder", + "help_text": "", + "saveas_header": "Save your file", + "open_header": "Upload a file" + } + }, + "dialogType": "open", + "auth": false, + "welcome_header": "Upload a file", + "welcome_subheader": "Choose from the files on your local device or the ones you have online", + "help_text": "", + "recent_path": "/", + "extensions": null, + "maxSize": 0, + "signature": null, + "policy": null, + "custom_providers": "imgur,cloudapp", + "intra": false + } +} diff --git a/plugins/inputs/webhooks/filestack/testdata/upload.json b/plugins/inputs/webhooks/filestack/testdata/upload.json new file mode 100644 index 000000000..d36a6ecbd --- /dev/null +++ b/plugins/inputs/webhooks/filestack/testdata/upload.json @@ -0,0 +1,12 @@ +{ + "action": "fp.upload", + "timestamp": 1443444905, + "id": 100946, + "text": { + "url": "https://www.filestackapi.com/api/file/WAunDTTqQfCNWwUUyf6n", + "client": "Facebook", + "type": "image/jpeg", + "filename": "1579337399020824.jpg", + "size": 139154 + } +} diff --git a/plugins/inputs/webhooks/filestack/testdata/video_conversion.json b/plugins/inputs/webhooks/filestack/testdata/video_conversion.json new file mode 100644 index 000000000..7a23dabe5 --- /dev/null +++ b/plugins/inputs/webhooks/filestack/testdata/video_conversion.json @@ -0,0 +1,51 @@ +{ + "status":"completed", + "message":"Done", + "data":{ + "thumb":"https://cdn.filestackcontent.com/f1e8V88QDuxzOvtOAq1W", + "thumb100x100":"https://process.filestackapi.com/AhTgLagciQByzXpFGRI0Az/resize=w:100,h:100,f:crop/output=f:jpg,q:66/https://cdn.filestackcontent.com/f1e8V88QDuxzOvtOAq1W", + "thumb200x200":"https://process.filestackapi.com/AhTgLagciQByzXpFGRI0Az/resize=w:200,h:200,f:crop/output=f:jpg,q:66/https://cdn.filestackcontent.com/f1e8V88QDuxzOvtOAq1W", + "thumb300x300":"https://process.filestackapi.com/AhTgLagciQByzXpFGRI0Az/resize=w:300,h:300,f:crop/output=f:jpg,q:66/https://cdn.filestackcontent.com/f1e8V88QDuxzOvtOAq1W", + "url":"https://cdn.filestackcontent.com/VgvFVdvvTkml0WXPIoGn" + }, + "metadata":{ + "result":{ + "audio_channels":2, + "audio_codec":"vorbis", + "audio_sample_rate":44100, + "created_at":"2015/12/21 20:45:19 +0000", + "duration":10587, + "encoding_progress":100, + "encoding_time":8, + "extname":".webm", + "file_size":293459, + "fps":24, + "height":260, + "mime_type":"video/webm", + "started_encoding_at":"2015/12/21 20:45:22 +0000", + "updated_at":"2015/12/21 20:45:32 +0000", + "video_bitrate":221, + "video_codec":"vp8", + "width":300 + }, + "source":{ + "audio_bitrate":125, + "audio_channels":2, + "audio_codec":"aac", + "audio_sample_rate":44100, + "created_at":"2015/12/21 20:45:19 +0000", + "duration":10564, + "extname":".mp4", + "file_size":875797, + "fps":24, + "height":360, + "mime_type":"video/mp4", + "updated_at":"2015/12/21 20:45:32 +0000", + "video_bitrate":196, + "video_codec":"h264", + "width":480 + } + }, + "timestamp":"1453850583", + "uuid":"638311d89d2bc849563a674a45809b7c" +} diff --git a/plugins/inputs/webhooks/mandrill/mandrill_webhooks_events_json_test.go b/plugins/inputs/webhooks/mandrill/mandrill_webhooks_events_json_test.go deleted file mode 100644 index 4ab385e18..000000000 --- a/plugins/inputs/webhooks/mandrill/mandrill_webhooks_events_json_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package mandrill - -func SendEventJSON() string { - return ` - { - "event": "send", - "msg": { - "ts": 1365109999, - "subject": "This an example webhook message", - "email": "example.webhook@mandrillapp.com", - "sender": "example.sender@mandrillapp.com", - "tags": [ - "webhook-example" - ], - "opens": [ - - ], - "clicks": [ - - ], - "state": "sent", - "metadata": { - "user_id": 111 - }, - "_id": "exampleaaaaaaaaaaaaaaaaaaaaaaaaa", - "_version": "exampleaaaaaaaaaaaaaaa" - }, - "_id": "id1", - "ts": 1384954004 - }` -} - -func HardBounceEventJSON() string { - return ` - { - "event": "hard_bounce", - "msg": { - "ts": 1365109999, - "subject": "This an example webhook message", - "email": "example.webhook@mandrillapp.com", - "sender": "example.sender@mandrillapp.com", - "tags": [ - "webhook-example" - ], - "state": "bounced", - "metadata": { - "user_id": 111 - }, - "_id": "exampleaaaaaaaaaaaaaaaaaaaaaaaaa2", - "_version": "exampleaaaaaaaaaaaaaaa", - "bounce_description": "bad_mailbox", - "bgtools_code": 10, - "diag": "smtp;550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces." - }, - "_id": "id2", - "ts": 1384954004 - }` -} diff --git a/plugins/inputs/webhooks/mandrill/mandrill_webhooks_test.go b/plugins/inputs/webhooks/mandrill/mandrill_webhooks_test.go index 94ac68684..62949f71c 100644 --- a/plugins/inputs/webhooks/mandrill/mandrill_webhooks_test.go +++ b/plugins/inputs/webhooks/mandrill/mandrill_webhooks_test.go @@ -1,12 +1,16 @@ package mandrill import ( - "github.com/influxdata/telegraf/testutil" "net/http" "net/http/httptest" "net/url" + "os" "strings" "testing" + + "github.com/stretchr/testify/require" + + "github.com/influxdata/telegraf/testutil" ) func postWebhooks(md *MandrillWebhook, eventBody string) *httptest.ResponseRecorder { @@ -40,7 +44,7 @@ func TestHead(t *testing.T) { func TestSendEvent(t *testing.T) { var acc testutil.Accumulator md := &MandrillWebhook{Path: "/mandrill", acc: &acc} - resp := postWebhooks(md, "["+SendEventJSON()+"]") + resp := postWebhooks(md, "["+readFile(t, "testdata/send_event.json")+"]") if resp.Code != http.StatusOK { t.Errorf("POST send returned HTTP status code %v.\nExpected %v", resp.Code, http.StatusOK) } @@ -59,7 +63,7 @@ func TestSendEvent(t *testing.T) { func TestMultipleEvents(t *testing.T) { var acc testutil.Accumulator md := &MandrillWebhook{Path: "/mandrill", acc: &acc} - resp := postWebhooks(md, "["+SendEventJSON()+","+HardBounceEventJSON()+"]") + resp := postWebhooks(md, "["+readFile(t, "testdata/send_event.json")+","+readFile(t, "testdata/hard_bounce_event.json")+"]") if resp.Code != http.StatusOK { t.Errorf("POST send returned HTTP status code %v.\nExpected %v", resp.Code, http.StatusOK) } @@ -83,3 +87,10 @@ func TestMultipleEvents(t *testing.T) { } acc.AssertContainsTaggedFields(t, "mandrill_webhooks", fields, tags) } + +func readFile(t *testing.T, filePath string) string { + data, err := os.ReadFile(filePath) + require.NoErrorf(t, err, "could not read from file %s", filePath) + + return string(data) +} diff --git a/plugins/inputs/webhooks/mandrill/testdata/hard_bounce_event.json b/plugins/inputs/webhooks/mandrill/testdata/hard_bounce_event.json new file mode 100644 index 000000000..a29408131 --- /dev/null +++ b/plugins/inputs/webhooks/mandrill/testdata/hard_bounce_event.json @@ -0,0 +1,23 @@ +{ + "event": "hard_bounce", + "msg": { + "ts": 1365109999, + "subject": "This an example webhook message", + "email": "example.webhook@mandrillapp.com", + "sender": "example.sender@mandrillapp.com", + "tags": [ + "webhook-example" + ], + "state": "bounced", + "metadata": { + "user_id": 111 + }, + "_id": "exampleaaaaaaaaaaaaaaaaaaaaaaaaa2", + "_version": "exampleaaaaaaaaaaaaaaa", + "bounce_description": "bad_mailbox", + "bgtools_code": 10, + "diag": "smtp;550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces." + }, + "_id": "id2", + "ts": 1384954004 +} diff --git a/plugins/inputs/webhooks/mandrill/testdata/send_event.json b/plugins/inputs/webhooks/mandrill/testdata/send_event.json new file mode 100644 index 000000000..77201f50c --- /dev/null +++ b/plugins/inputs/webhooks/mandrill/testdata/send_event.json @@ -0,0 +1,26 @@ +{ + "event": "send", + "msg": { + "ts": 1365109999, + "subject": "This an example webhook message", + "email": "example.webhook@mandrillapp.com", + "sender": "example.sender@mandrillapp.com", + "tags": [ + "webhook-example" + ], + "opens": [ + + ], + "clicks": [ + + ], + "state": "sent", + "metadata": { + "user_id": 111 + }, + "_id": "exampleaaaaaaaaaaaaaaaaaaaaaaaaa", + "_version": "exampleaaaaaaaaaaaaaaa" + }, + "_id": "id1", + "ts": 1384954004 +} diff --git a/plugins/inputs/win_eventlog/zsyscall_windows.go b/plugins/inputs/win_eventlog/zsyscall_windows.go index e07837130..e4c3570c2 100644 --- a/plugins/inputs/win_eventlog/zsyscall_windows.go +++ b/plugins/inputs/win_eventlog/zsyscall_windows.go @@ -77,8 +77,29 @@ var ( procEvtOpenPublisherMetadata = modwevtapi.NewProc("EvtOpenPublisherMetadata") ) -func _EvtSubscribe(session EvtHandle, signalEvent uintptr, channelPath *uint16, query *uint16, bookmark EvtHandle, context uintptr, callback syscall.Handle, flags EvtSubscribeFlag) (handle EvtHandle, err error) { - r0, _, e1 := syscall.Syscall9(procEvtSubscribe.Addr(), 8, uintptr(session), uintptr(signalEvent), uintptr(unsafe.Pointer(channelPath)), uintptr(unsafe.Pointer(query)), uintptr(bookmark), uintptr(context), uintptr(callback), uintptr(flags), 0) +func _EvtSubscribe( + session EvtHandle, + signalEvent uintptr, + channelPath *uint16, + query *uint16, + bookmark EvtHandle, + context uintptr, + callback syscall.Handle, + flags EvtSubscribeFlag, +) (handle EvtHandle, err error) { + r0, _, e1 := syscall.Syscall9( + procEvtSubscribe.Addr(), + 8, + uintptr(session), + uintptr(signalEvent), + uintptr(unsafe.Pointer(channelPath)), + uintptr(unsafe.Pointer(query)), + uintptr(bookmark), + uintptr(context), + uintptr(callback), + uintptr(flags), + 0, + ) handle = EvtHandle(r0) if handle == 0 { if e1 != 0 { @@ -90,8 +111,28 @@ func _EvtSubscribe(session EvtHandle, signalEvent uintptr, channelPath *uint16, return } -func _EvtRender(context EvtHandle, fragment EvtHandle, flags EvtRenderFlag, bufferSize uint32, buffer *byte, bufferUsed *uint32, propertyCount *uint32) (err error) { - r1, _, e1 := syscall.Syscall9(procEvtRender.Addr(), 7, uintptr(context), uintptr(fragment), uintptr(flags), uintptr(bufferSize), uintptr(unsafe.Pointer(buffer)), uintptr(unsafe.Pointer(bufferUsed)), uintptr(unsafe.Pointer(propertyCount)), 0, 0) +func _EvtRender( + context EvtHandle, + fragment EvtHandle, + flags EvtRenderFlag, + bufferSize uint32, + buffer *byte, + bufferUsed *uint32, + propertyCount *uint32, +) (err error) { + r1, _, e1 := syscall.Syscall9( + procEvtRender.Addr(), + 7, + uintptr(context), + uintptr(fragment), + uintptr(flags), + uintptr(bufferSize), + uintptr(unsafe.Pointer(buffer)), + uintptr(unsafe.Pointer(bufferUsed)), + uintptr(unsafe.Pointer(propertyCount)), + 0, + 0, + ) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -115,7 +156,16 @@ func _EvtClose(object EvtHandle) (err error) { } func _EvtNext(resultSet EvtHandle, eventArraySize uint32, eventArray *EvtHandle, timeout uint32, flags uint32, numReturned *uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procEvtNext.Addr(), 6, uintptr(resultSet), uintptr(eventArraySize), uintptr(unsafe.Pointer(eventArray)), uintptr(timeout), uintptr(flags), uintptr(unsafe.Pointer(numReturned))) + r1, _, e1 := syscall.Syscall6( + procEvtNext.Addr(), + 6, + uintptr(resultSet), + uintptr(eventArraySize), + uintptr(unsafe.Pointer(eventArray)), + uintptr(timeout), + uintptr(flags), + uintptr(unsafe.Pointer(numReturned)), + ) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -126,8 +176,30 @@ func _EvtNext(resultSet EvtHandle, eventArraySize uint32, eventArray *EvtHandle, return } -func _EvtFormatMessage(publisherMetadata EvtHandle, event EvtHandle, messageID uint32, valueCount uint32, values uintptr, flags EvtFormatMessageFlag, bufferSize uint32, buffer *byte, bufferUsed *uint32) (err error) { - r1, _, e1 := syscall.Syscall9(procEvtFormatMessage.Addr(), 9, uintptr(publisherMetadata), uintptr(event), uintptr(messageID), uintptr(valueCount), uintptr(values), uintptr(flags), uintptr(bufferSize), uintptr(unsafe.Pointer(buffer)), uintptr(unsafe.Pointer(bufferUsed))) +func _EvtFormatMessage( + publisherMetadata EvtHandle, + event EvtHandle, + messageID uint32, + valueCount uint32, + values uintptr, + flags EvtFormatMessageFlag, + bufferSize uint32, + buffer *byte, + bufferUsed *uint32, +) (err error) { + r1, _, e1 := syscall.Syscall9( + procEvtFormatMessage.Addr(), + 9, + uintptr(publisherMetadata), + uintptr(event), + uintptr(messageID), + uintptr(valueCount), + uintptr(values), + uintptr(flags), + uintptr(bufferSize), + uintptr(unsafe.Pointer(buffer)), + uintptr(unsafe.Pointer(bufferUsed)), + ) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -139,7 +211,16 @@ func _EvtFormatMessage(publisherMetadata EvtHandle, event EvtHandle, messageID u } func _EvtOpenPublisherMetadata(session EvtHandle, publisherIdentity *uint16, logFilePath *uint16, locale uint32, flags uint32) (handle EvtHandle, err error) { - r0, _, e1 := syscall.Syscall6(procEvtOpenPublisherMetadata.Addr(), 5, uintptr(session), uintptr(unsafe.Pointer(publisherIdentity)), uintptr(unsafe.Pointer(logFilePath)), uintptr(locale), uintptr(flags), 0) + r0, _, e1 := syscall.Syscall6( + procEvtOpenPublisherMetadata.Addr(), + 5, + uintptr(session), + uintptr(unsafe.Pointer(publisherIdentity)), + uintptr(unsafe.Pointer(logFilePath)), + uintptr(locale), + uintptr(flags), + 0, + ) handle = EvtHandle(r0) if handle == 0 { if e1 != 0 { diff --git a/plugins/inputs/win_perf_counters/win_perf_counters.go b/plugins/inputs/win_perf_counters/win_perf_counters.go index 51b0b384f..7d981cd6b 100644 --- a/plugins/inputs/win_perf_counters/win_perf_counters.go +++ b/plugins/inputs/win_perf_counters/win_perf_counters.go @@ -120,7 +120,16 @@ func extractCounterInfoFromCounterPath(counterPath string) (object string, insta return } -func newCounter(counterHandle PDH_HCOUNTER, counterPath string, objectName string, instance string, counterName string, measurement string, includeTotal bool, useRawValue bool) *counter { +func newCounter( + counterHandle PDH_HCOUNTER, + counterPath string, + objectName string, + instance string, + counterName string, + measurement string, + includeTotal bool, + useRawValue bool, +) *counter { measurementName := sanitizedChars.Replace(measurement) if measurementName == "" { measurementName = "win_perf_counters" @@ -137,7 +146,15 @@ func (*Win_PerfCounters) SampleConfig() string { return sampleConfig } -func (m *Win_PerfCounters) AddItem(counterPath string, objectName string, instance string, counterName string, measurement string, includeTotal bool, useRawValue bool) error { +func (m *Win_PerfCounters) AddItem( + counterPath string, + objectName string, + instance string, + counterName string, + measurement string, + includeTotal bool, + useRawValue bool, +) error { origCounterPath := counterPath var err error var counterHandle PDH_HCOUNTER diff --git a/plugins/inputs/win_perf_counters/win_perf_counters_test.go b/plugins/inputs/win_perf_counters/win_perf_counters_test.go index 6295d603c..91cc5fdaf 100644 --- a/plugins/inputs/win_perf_counters/win_perf_counters_test.go +++ b/plugins/inputs/win_perf_counters/win_perf_counters_test.go @@ -5,7 +5,6 @@ package win_perf_counters import ( "errors" "fmt" - "github.com/stretchr/testify/assert" "testing" "time" @@ -910,7 +909,11 @@ func TestGatherRefreshingWithoutExpansion(t *testing.T) { //test finding new instance cps2 := []string{"\\O(I1)\\C1", "\\O(I1)\\C2", "\\O(I2)\\C1", "\\O(I2)\\C2", "\\O(I3)\\C1", "\\O(I3)\\C2"} fpm = &FakePerformanceQuery{ - counters: createCounterMap(append([]string{"\\O(*)\\C1", "\\O(*)\\C2"}, cps2...), []float64{0, 0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6}, []uint32{0, 0, 0, 0, 0, 0, 0, 0}), + counters: createCounterMap( + append([]string{"\\O(*)\\C1", "\\O(*)\\C2"}, cps2...), + []float64{0, 0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6}, + []uint32{0, 0, 0, 0, 0, 0, 0, 0}, + ), expandPaths: map[string][]string{ "\\O(*)\\C1": {cps2[0], cps2[2], cps2[4]}, "\\O(*)\\C2": {cps2[1], cps2[3], cps2[5]}, @@ -943,7 +946,11 @@ func TestGatherRefreshingWithoutExpansion(t *testing.T) { perfObjects = createPerfObject(measurement, "O", []string{"*"}, []string{"C1", "C2", "C3"}, true, false, false) cps3 := []string{"\\O(I1)\\C1", "\\O(I1)\\C2", "\\O(I1)\\C3", "\\O(I2)\\C1", "\\O(I2)\\C2", "\\O(I2)\\C3"} fpm = &FakePerformanceQuery{ - counters: createCounterMap(append([]string{"\\O(*)\\C1", "\\O(*)\\C2", "\\O(*)\\C3"}, cps3...), []float64{0, 0, 0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6}, []uint32{0, 0, 0, 0, 0, 0, 0, 0, 0}), + counters: createCounterMap( + append([]string{"\\O(*)\\C1", "\\O(*)\\C2", "\\O(*)\\C3"}, cps3...), + []float64{0, 0, 0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6}, + []uint32{0, 0, 0, 0, 0, 0, 0, 0, 0}, + ), expandPaths: map[string][]string{ "\\O(*)\\C1": {cps3[0], cps3[3]}, "\\O(*)\\C2": {cps3[1], cps3[4]}, @@ -1072,8 +1079,8 @@ func TestGatherRaw(t *testing.T) { var acc1 testutil.Accumulator err = m.Gather(&acc1) require.NoError(t, err) - assert.Len(t, m.counters, 2) - assert.Len(t, acc1.Metrics, 2) + require.Len(t, m.counters, 2) + require.Len(t, acc1.Metrics, 2) fields1 := map[string]interface{}{ "C1_Raw": int64(1), "C2_Raw": int64(2), @@ -1101,8 +1108,8 @@ func TestGatherRaw(t *testing.T) { var acc2 testutil.Accumulator err = m.Gather(&acc2) require.NoError(t, err) - assert.Len(t, m.counters, 4) //expanded counters - assert.Len(t, acc2.Metrics, 2) + require.Len(t, m.counters, 4) //expanded counters + require.Len(t, acc2.Metrics, 2) acc2.AssertContainsTaggedFields(t, measurement, fields1, tags1) @@ -1110,9 +1117,19 @@ func TestGatherRaw(t *testing.T) { } // list of nul terminated strings from WinAPI -var unicodeStringListWithEnglishChars = []uint16{0x5c, 0x5c, 0x54, 0x34, 0x38, 0x30, 0x5c, 0x50, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x44, 0x69, 0x73, 0x6b, 0x28, 0x30, 0x20, 0x43, 0x3a, 0x29, 0x5c, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x44, 0x69, 0x73, 0x6b, 0x20, 0x51, 0x75, 0x65, 0x75, 0x65, 0x20, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x0, 0x5c, 0x5c, 0x54, 0x34, 0x38, 0x30, 0x5c, 0x50, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x44, 0x69, 0x73, 0x6b, 0x28, 0x5f, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x29, 0x5c, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x44, 0x69, 0x73, 0x6b, 0x20, 0x51, 0x75, 0x65, 0x75, 0x65, 0x20, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x0, 0x0} -var unicodeStringListWithCzechChars = []uint16{0x5c, 0x5c, 0x54, 0x34, 0x38, 0x30, 0x5c, 0x46, 0x79, 0x7a, 0x69, 0x63, 0x6b, 0xfd, 0x20, 0x64, 0x69, 0x73, 0x6b, 0x28, 0x30, 0x20, 0x43, 0x3a, 0x29, 0x5c, 0x41, 0x6b, 0x74, 0x75, 0xe1, 0x6c, 0x6e, 0xed, 0x20, 0x64, 0xe9, 0x6c, 0x6b, 0x61, 0x20, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x79, 0x20, 0x64, 0x69, 0x73, 0x6b, 0x75, 0x0, 0x5c, 0x5c, 0x54, 0x34, 0x38, 0x30, 0x5c, 0x46, 0x79, 0x7a, 0x69, 0x63, 0x6b, 0xfd, 0x20, 0x64, 0x69, 0x73, 0x6b, 0x28, 0x5f, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x29, 0x5c, 0x41, 0x6b, 0x74, 0x75, 0xe1, 0x6c, 0x6e, 0xed, 0x20, 0x64, 0xe9, 0x6c, 0x6b, 0x61, 0x20, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x79, 0x20, 0x64, 0x69, 0x73, 0x6b, 0x75, 0x0, 0x0} -var unicodeStringListSingleItem = []uint16{0x5c, 0x5c, 0x54, 0x34, 0x38, 0x30, 0x5c, 0x50, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x44, 0x69, 0x73, 0x6b, 0x28, 0x30, 0x20, 0x43, 0x3a, 0x29, 0x5c, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x44, 0x69, 0x73, 0x6b, 0x20, 0x51, 0x75, 0x65, 0x75, 0x65, 0x20, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x0, 0x0} +var unicodeStringListWithEnglishChars = []uint16{0x5c, 0x5c, 0x54, 0x34, 0x38, 0x30, 0x5c, 0x50, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x44, 0x69, 0x73, + 0x6b, 0x28, 0x30, 0x20, 0x43, 0x3a, 0x29, 0x5c, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x44, 0x69, 0x73, 0x6b, 0x20, 0x51, 0x75, 0x65, 0x75, + 0x65, 0x20, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x0, 0x5c, 0x5c, 0x54, 0x34, 0x38, 0x30, 0x5c, 0x50, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x44, + 0x69, 0x73, 0x6b, 0x28, 0x5f, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x29, 0x5c, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x44, 0x69, 0x73, 0x6b, 0x20, + 0x51, 0x75, 0x65, 0x75, 0x65, 0x20, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x0, 0x0} +var unicodeStringListWithCzechChars = []uint16{0x5c, 0x5c, 0x54, 0x34, 0x38, 0x30, 0x5c, 0x46, 0x79, 0x7a, 0x69, 0x63, 0x6b, 0xfd, 0x20, 0x64, 0x69, 0x73, + 0x6b, 0x28, 0x30, 0x20, 0x43, 0x3a, 0x29, 0x5c, 0x41, 0x6b, 0x74, 0x75, 0xe1, 0x6c, 0x6e, 0xed, 0x20, 0x64, 0xe9, 0x6c, 0x6b, 0x61, 0x20, 0x66, 0x72, + 0x6f, 0x6e, 0x74, 0x79, 0x20, 0x64, 0x69, 0x73, 0x6b, 0x75, 0x0, 0x5c, 0x5c, 0x54, 0x34, 0x38, 0x30, 0x5c, 0x46, 0x79, 0x7a, 0x69, 0x63, 0x6b, 0xfd, + 0x20, 0x64, 0x69, 0x73, 0x6b, 0x28, 0x5f, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x29, 0x5c, 0x41, 0x6b, 0x74, 0x75, 0xe1, 0x6c, 0x6e, 0xed, 0x20, 0x64, 0xe9, + 0x6c, 0x6b, 0x61, 0x20, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x79, 0x20, 0x64, 0x69, 0x73, 0x6b, 0x75, 0x0, 0x0} +var unicodeStringListSingleItem = []uint16{0x5c, 0x5c, 0x54, 0x34, 0x38, 0x30, 0x5c, 0x50, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x44, 0x69, 0x73, 0x6b, + 0x28, 0x30, 0x20, 0x43, 0x3a, 0x29, 0x5c, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x44, 0x69, 0x73, 0x6b, 0x20, 0x51, 0x75, 0x65, 0x75, 0x65, 0x20, + 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x0, 0x0} var unicodeStringListNoItem = []uint16{0x0} var stringArrayWithEnglishChars = []string{ diff --git a/plugins/inputs/x509_cert/x509_cert_test.go b/plugins/inputs/x509_cert/x509_cert_test.go index e91f43e49..2ead1def4 100644 --- a/plugins/inputs/x509_cert/x509_cert_test.go +++ b/plugins/inputs/x509_cert/x509_cert_test.go @@ -383,8 +383,14 @@ func TestGatherCertMustNotTimeoutIntegration(t *testing.T) { func TestSourcesToURLs(t *testing.T) { m := &X509Cert{ - Sources: []string{"https://www.influxdata.com:443", "tcp://influxdata.com:443", "smtp://influxdata.com:25", "file:///dummy_test_path_file.pem", "/tmp/dummy_test_path_glob*.pem"}, - Log: testutil.Logger{}, + Sources: []string{ + "https://www.influxdata.com:443", + "tcp://influxdata.com:443", + "smtp://influxdata.com:25", + "file:///dummy_test_path_file.pem", + "/tmp/dummy_test_path_glob*.pem", + }, + Log: testutil.Logger{}, } require.NoError(t, m.Init()) diff --git a/plugins/inputs/zipkin/cmd/stress_test_write/stress_test_write.go b/plugins/inputs/zipkin/cmd/stress_test_write/stress_test_write.go index a1abccc42..e5d071a8c 100644 --- a/plugins/inputs/zipkin/cmd/stress_test_write/stress_test_write.go +++ b/plugins/inputs/zipkin/cmd/stress_test_write/stress_test_write.go @@ -5,11 +5,13 @@ parameters which dictate batch size and flush timeout. Usage as follows: -`./stress_test_write -batch_size= -max_backlog= -batch_interval= -span_count -zipkin_host=` +`./stress_test_write -batch_size= -max_backlog= -batch_interval= \ +-span_count -zipkin_host=` Or with a timer: -`time ./stress_test_write -batch_size= -max_backlog= -batch_interval= -span_count -zipkin_host=` +`time ./stress_test_write -batch_size= -max_backlog= -batch_interval= \ +-span_count -zipkin_host=` However, the flag defaults work just fine for a good write stress test (and are what this tool has mainly been tested with), so there shouldn't be much need to diff --git a/plugins/inputs/zipkin/zipkin_test.go b/plugins/inputs/zipkin/zipkin_test.go index f2f07c572..516a514e2 100644 --- a/plugins/inputs/zipkin/zipkin_test.go +++ b/plugins/inputs/zipkin/zipkin_test.go @@ -615,7 +615,9 @@ func TestZipkinPlugin(t *testing.T) { if err := postThriftData(tt.datafile, z.address, tt.contentType); err != nil { t.Fatalf("Posting data to http endpoint /api/v1/spans failed. Error: %s\n", err) } - mockAcc.Wait(len(tt.want)) //Since the server is running concurrently, we need to wait for the number of data points we want to test to be added to the Accumulator. + mockAcc.Wait( + len(tt.want), + ) //Since the server is running concurrently, we need to wait for the number of data points we want to test to be added to the Accumulator. if len(mockAcc.Errors) > 0 != tt.wantErr { t.Fatalf("Got unexpected errors. want error = %v, errors = %v\n", tt.wantErr, mockAcc.Errors) }