From 1c8017f902a5f704af485ffcd9df23ef09cf4e1c Mon Sep 17 00:00:00 2001 From: Henry Whitaker Date: Sun, 11 Apr 2021 09:23:18 +0100 Subject: [PATCH] Added v1.12.0 files --- README.md | 2 +- conf/site/README.md | 9 +- .../app/Actions/GetFailedSpeedtestData.php | 2 +- .../app/Actions/GetLatestSpeedtestData.php | 2 +- .../site/app/Actions/GetSpeedtestTimeData.php | 2 +- .../Commands/ClearOldSessionsCommand.php | 2 +- .../InfluxDBConnectionErrorException.php | 10 ++ .../InfluxDBNotEnabledException.php | 10 ++ conf/site/app/Helpers/BackupHelper.php | 2 +- .../app/Helpers/EmailVerificationHelper.php | 4 +- conf/site/app/Helpers/SettingsHelper.php | 2 +- conf/site/app/Helpers/SpeedtestHelper.php | 5 +- .../app/Http/Controllers/AuthController.php | 6 +- .../Http/Controllers/SettingsController.php | 2 +- .../Http/Controllers/SpeedtestController.php | 2 +- .../Http/Middleware/CheckActiveSession.php | 2 +- .../Interfaces/InfluxDBWrapperInterface.php | 13 ++ .../site/app/Interfaces/SpeedtestProvider.php | 2 +- .../app/Models/Auth/EmailVerification.php | 14 +++ conf/site/app/Models/Auth/LoginSession.php | 21 ++++ conf/site/app/Models/Setting.php | 25 ++++ conf/site/app/Models/Speedtest.php | 45 +++++++ conf/site/app/Models/User.php | 114 ++++++++++++++++++ conf/site/app/Observers/SpeedtestObserver.php | 30 +++++ .../app/Providers/EventServiceProvider.php | 4 +- conf/site/app/Utils/InfluxDB/InfluxDB.php | 113 +++++++++++++++++ .../InfluxDB/InfluxDBVersion1Wrapper.php | 74 ++++++++++++ .../InfluxDB/InfluxDBVersion2Wrapper.php | 37 ++++++ conf/site/app/Utils/OoklaTester.php | 2 +- conf/site/changelog.json | 6 + conf/site/composer.json | 12 +- conf/site/composer.lock | 114 +++++++++++++++++- conf/site/config/services.php | 5 + conf/site/config/speedtest.php | 2 +- .../database/factories/SpeedtestFactory.php | 32 +++++ conf/site/database/factories/UserFactory.php | 2 +- .../2014_10_12_000000_create_users_table.php | 2 +- ...020_05_18_211812_create_settings_table.php | 2 +- ...6_21_171849_add_notifications_settings.php | 2 +- .../2020_07_06_105930_add_graph_settings.php | 2 +- ...215412_add_notification_agent_settings.php | 2 +- ...08_12_123941_add_healthchecks_settings.php | 2 +- ..._21_133343_add_authentication_settings.php | 2 +- ...add_conditional_notifications_settings.php | 2 +- ...8_192136_add_show_failed_tests_setting.php | 2 +- ..._09_10_231121_add_widget_card_settings.php | 2 +- ...19_211232_add_schedule_enabled_setting.php | 2 +- ...2020_12_19_234248_add_app_name_setting.php | 2 +- ...001345_add_custom_healthchecks_setting.php | 2 +- ..._101259_add_speedtest_provider_setting.php | 2 +- ..._update_speedtest_server_settings_text.php | 2 +- ..._10_082758_add_visible_columns_setting.php | 2 +- ...4_10_102320_add_hidden_columns_setting.php | 2 +- ...21_04_10_182503_add_influx_db_settings.php | 92 ++++++++++++++ .../{seeds => seeders}/DatabaseSeeder.php | 5 +- .../site/database/seeders/SpeedtestSeeder.php | 21 ++++ conf/site/routes/api.php | 2 +- conf/site/tests/Feature/APISpeedtestTest.php | 2 +- conf/site/tests/Feature/SpeedtestTest.php | 14 +++ .../InfluxDB/InfluxDBWrapperWrapperTest.php | 26 ++++ conf/site/tests/Mocks/OoklaTesterMocker.php | 59 +++++++++ .../SpeedtestController/DeleteTest.php | 2 +- .../SpeedtestController/LatestTest.php | 2 +- .../SpeedtestHelper/AbsoluteThresholdTest.php | 2 +- .../SpeedtestHelper/CheckOutputTest.php | 2 + .../SpeedtestHelper/FailureRateTest.php | 2 +- .../PercentageThresholdTest.php | 2 +- .../Helpers/SpeedtestHelper/SpeedtestTest.php | 13 +- .../SpeedtestCompleteListener/SlackTest.php | 2 +- .../TelegramTest.php | 2 +- .../SpeedtestFailedListener/SlackTest.php | 2 +- .../SpeedtestFailedListener/TelegramTest.php | 2 +- .../SpeedtestOverviewListener/SlackTest.php | 2 +- .../TelegramTest.php | 2 +- 74 files changed, 951 insertions(+), 72 deletions(-) create mode 100644 conf/site/app/Exceptions/InfluxDBConnectionErrorException.php create mode 100644 conf/site/app/Exceptions/InfluxDBNotEnabledException.php create mode 100644 conf/site/app/Interfaces/InfluxDBWrapperInterface.php create mode 100644 conf/site/app/Models/Auth/EmailVerification.php create mode 100644 conf/site/app/Models/Auth/LoginSession.php create mode 100644 conf/site/app/Models/Setting.php create mode 100644 conf/site/app/Models/Speedtest.php create mode 100644 conf/site/app/Models/User.php create mode 100644 conf/site/app/Observers/SpeedtestObserver.php create mode 100644 conf/site/app/Utils/InfluxDB/InfluxDB.php create mode 100644 conf/site/app/Utils/InfluxDB/InfluxDBVersion1Wrapper.php create mode 100644 conf/site/app/Utils/InfluxDB/InfluxDBVersion2Wrapper.php create mode 100644 conf/site/database/factories/SpeedtestFactory.php create mode 100644 conf/site/database/migrations/2021_04_10_182503_add_influx_db_settings.php rename conf/site/database/{seeds => seeders}/DatabaseSeeder.php (64%) create mode 100644 conf/site/database/seeders/SpeedtestSeeder.php create mode 100644 conf/site/tests/Feature/Utils/InfluxDB/InfluxDBWrapperWrapperTest.php create mode 100644 conf/site/tests/Mocks/OoklaTesterMocker.php diff --git a/README.md b/README.md index e75e568f..ae72d1c2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Speedtest Tracker -[![Docker pulls](https://img.shields.io/docker/pulls/henrywhitaker3/speedtest-tracker?style=flat-square)](https://hub.docker.com/r/henrywhitaker3/speedtest-tracker) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Stable?label=master&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Dev?label=dev&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![last_commit](https://img.shields.io/github/last-commit/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) [![issues](https://img.shields.io/github/issues/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/issues) [![commit_freq](https://img.shields.io/github/commit-activity/m/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) ![version](https://img.shields.io/badge/version-v1.11.1-success?style=flat-square) [![license](https://img.shields.io/github/license/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/blob/master/LICENSE) +[![Docker pulls](https://img.shields.io/docker/pulls/henrywhitaker3/speedtest-tracker?style=flat-square)](https://hub.docker.com/r/henrywhitaker3/speedtest-tracker) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Stable?label=master&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Dev?label=dev&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![last_commit](https://img.shields.io/github/last-commit/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) [![issues](https://img.shields.io/github/issues/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/issues) [![commit_freq](https://img.shields.io/github/commit-activity/m/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) ![version](https://img.shields.io/badge/version-v1.12.0-success?style=flat-square) [![license](https://img.shields.io/github/license/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/blob/master/LICENSE) This program runs a speedtest check every hour and graphs the results. The back-end is written in [Laravel](https://laravel.com/) and the front-end uses [React](https://reactjs.org/). It uses [Ookla's Speedtest cli](https://www.speedtest.net/apps/cli) to get the data and uses [Chart.js](https://www.chartjs.org/) to plot the results. diff --git a/conf/site/README.md b/conf/site/README.md index 1b738472..c1ce12fc 100644 --- a/conf/site/README.md +++ b/conf/site/README.md @@ -1,6 +1,6 @@ # Speedtest Tracker -[![Docker pulls](https://img.shields.io/docker/pulls/henrywhitaker3/speedtest-tracker?style=flat-square)](https://hub.docker.com/r/henrywhitaker3/speedtest-tracker) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Stable?label=master&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Dev?label=dev&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![last_commit](https://img.shields.io/github/last-commit/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) [![issues](https://img.shields.io/github/issues/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/issues) [![commit_freq](https://img.shields.io/github/commit-activity/m/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) ![version](https://img.shields.io/badge/version-v1.11.1-success?style=flat-square) [![license](https://img.shields.io/github/license/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/blob/master/LICENSE) +[![Docker pulls](https://img.shields.io/docker/pulls/henrywhitaker3/speedtest-tracker?style=flat-square)](https://hub.docker.com/r/henrywhitaker3/speedtest-tracker) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Stable?label=master&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/henrywhitaker3/Speedtest-Tracker/Dev?label=dev&logo=github&style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/actions) [![last_commit](https://img.shields.io/github/last-commit/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) [![issues](https://img.shields.io/github/issues/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/issues) [![commit_freq](https://img.shields.io/github/commit-activity/m/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) ![version](https://img.shields.io/badge/version-v1.12.0-success?style=flat-square) [![license](https://img.shields.io/github/license/henrywhitaker3/Speedtest-Tracker?style=flat-square)](https://github.com/henrywhitaker3/Speedtest-Tracker/blob/master/LICENSE) This program runs a speedtest check every hour and graphs the results. The back-end is written in [Laravel](https://laravel.com/) and the front-end uses [React](https://reactjs.org/). It uses the [Ookla's speedtest cli](https://www.speedtest.net/apps/cli) package to get the data and uses [Chart.js](https://www.chartjs.org/) to plot the results. @@ -18,6 +18,7 @@ Disclaimer: You will need to accept Ookla's EULA and privacy agreements in order - Slack/Discord/Telegram notifications - [healthchecks.io](https://healthchecks.io) integration - Organizr integration +- InfluxDB integration (currently v1 only, v2 is a WIP) ## Installation & Setup @@ -84,6 +85,8 @@ Container images are configured using parameters passed at runtime (such as thos | `-e PUID` | Optional. Supply a local user ID for volume permissions | | `-e PGID` | Optional. Supply a local group ID for volume permissions | | `-e AUTH` | Optional. Set to 'true' to enable authentication for the app | +| `-e INFLUXDB_RETENTION`| Optional. Sets the InfluxDB retention period, defaults to `30d` | +| `-e INFLUXDB_HOST_TAG | Optional. Sets the InfluxDB host tag value, defaults to `speedtest` | ### Authentication @@ -101,3 +104,7 @@ After enabling, you should change the password through the web UI. ### Manual Install For manual installations, please follow the instructions [here](https://github.com/henrywhitaker3/Speedtest-Tracker/wiki/Manual-Installation). + +### Kubernetes + +There is a 3rd party helm chart available [here](https://github.com/sOblivionsCall/charts). diff --git a/conf/site/app/Actions/GetFailedSpeedtestData.php b/conf/site/app/Actions/GetFailedSpeedtestData.php index 7ffd586a..652f85c7 100644 --- a/conf/site/app/Actions/GetFailedSpeedtestData.php +++ b/conf/site/app/Actions/GetFailedSpeedtestData.php @@ -2,7 +2,7 @@ namespace App\Actions; -use App\Speedtest; +use App\Models\Speedtest; use Cache; use Carbon\Carbon; use DB; diff --git a/conf/site/app/Actions/GetLatestSpeedtestData.php b/conf/site/app/Actions/GetLatestSpeedtestData.php index ec6b8044..bc456ded 100644 --- a/conf/site/app/Actions/GetLatestSpeedtestData.php +++ b/conf/site/app/Actions/GetLatestSpeedtestData.php @@ -4,7 +4,7 @@ namespace App\Actions; use App\Helpers\SettingsHelper; use App\Helpers\SpeedtestHelper; -use App\Speedtest; +use App\Models\Speedtest; use DB; use Henrywhitaker3\LaravelActions\Interfaces\ActionInterface; diff --git a/conf/site/app/Actions/GetSpeedtestTimeData.php b/conf/site/app/Actions/GetSpeedtestTimeData.php index 105baa00..d2b15988 100644 --- a/conf/site/app/Actions/GetSpeedtestTimeData.php +++ b/conf/site/app/Actions/GetSpeedtestTimeData.php @@ -3,7 +3,7 @@ namespace App\Actions; use App\Helpers\SettingsHelper; -use App\Speedtest; +use App\Models\Speedtest; use Cache; use Carbon\Carbon; use Henrywhitaker3\LaravelActions\Interfaces\ActionInterface; diff --git a/conf/site/app/Console/Commands/ClearOldSessionsCommand.php b/conf/site/app/Console/Commands/ClearOldSessionsCommand.php index b6d69933..223b2bf5 100644 --- a/conf/site/app/Console/Commands/ClearOldSessionsCommand.php +++ b/conf/site/app/Console/Commands/ClearOldSessionsCommand.php @@ -2,7 +2,7 @@ namespace App\Console\Commands; -use App\Auth\LoginSession; +use App\Models\Auth\LoginSession; use Carbon\Carbon; use Illuminate\Console\Command; use Log; diff --git a/conf/site/app/Exceptions/InfluxDBConnectionErrorException.php b/conf/site/app/Exceptions/InfluxDBConnectionErrorException.php new file mode 100644 index 00000000..24266020 --- /dev/null +++ b/conf/site/app/Exceptions/InfluxDBConnectionErrorException.php @@ -0,0 +1,10 @@ +make(SpeedtestProvider::class); return $tester->run(); } diff --git a/conf/site/app/Http/Controllers/AuthController.php b/conf/site/app/Http/Controllers/AuthController.php index 2a610fe9..abbf0564 100644 --- a/conf/site/app/Http/Controllers/AuthController.php +++ b/conf/site/app/Http/Controllers/AuthController.php @@ -2,14 +2,14 @@ namespace App\Http\Controllers; -use App\Auth\EmailVerification; -use App\Auth\LoginSession as AuthLoginSession; +use App\Models\Auth\EmailVerification; +use App\Models\Auth\LoginSession as AuthLoginSession; use App\Helpers\EmailVerificationHelper; use Illuminate\Support\Facades\Auth; use App\Http\Controllers\Controller; use App\LoginSession; use App\Rules\CurrentPasswordMatches; -use App\User; +use App\Models\User; use DateTime; use Hash; use Illuminate\Support\Facades\Request as RequestFacade; diff --git a/conf/site/app/Http/Controllers/SettingsController.php b/conf/site/app/Http/Controllers/SettingsController.php index 4d7202d6..b8359c37 100644 --- a/conf/site/app/Http/Controllers/SettingsController.php +++ b/conf/site/app/Http/Controllers/SettingsController.php @@ -4,7 +4,7 @@ namespace App\Http\Controllers; use App\Helpers\SettingsHelper; use App\Rules\Cron; -use App\Setting; +use App\Models\Setting; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Validator; diff --git a/conf/site/app/Http/Controllers/SpeedtestController.php b/conf/site/app/Http/Controllers/SpeedtestController.php index f4204ff0..20169675 100644 --- a/conf/site/app/Http/Controllers/SpeedtestController.php +++ b/conf/site/app/Http/Controllers/SpeedtestController.php @@ -9,7 +9,7 @@ use App\Actions\QueueSpeedtest; use App\Helpers\SettingsHelper; use App\Helpers\SpeedtestHelper; use App\Jobs\SpeedtestJob; -use App\Speedtest; +use App\Models\Speedtest; use Carbon\Carbon; use Exception; use Illuminate\Http\Request; diff --git a/conf/site/app/Http/Middleware/CheckActiveSession.php b/conf/site/app/Http/Middleware/CheckActiveSession.php index 6b46bfb1..11c43a27 100644 --- a/conf/site/app/Http/Middleware/CheckActiveSession.php +++ b/conf/site/app/Http/Middleware/CheckActiveSession.php @@ -2,7 +2,7 @@ namespace App\Http\Middleware; -use App\Auth\LoginSession; +use App\Models\Auth\LoginSession; use Closure; use Exception; diff --git a/conf/site/app/Interfaces/InfluxDBWrapperInterface.php b/conf/site/app/Interfaces/InfluxDBWrapperInterface.php new file mode 100644 index 00000000..329429b7 --- /dev/null +++ b/conf/site/app/Interfaces/InfluxDBWrapperInterface.php @@ -0,0 +1,13 @@ + CommaSeparatedArrayCast::class, + ]; +} diff --git a/conf/site/app/Models/Speedtest.php b/conf/site/app/Models/Speedtest.php new file mode 100644 index 00000000..063ebd98 --- /dev/null +++ b/conf/site/app/Models/Speedtest.php @@ -0,0 +1,45 @@ + (int) $this->id, + 'download' => (float) $this->download, + 'upload' => (float) $this->upload, + 'ping' => (float) $this->ping, + 'server_id' => (int) $this->server_id, + 'server_host' => $this->server_host, + 'server_name' => $this->server_name, + 'scheduled' => (bool) $this->scheduled, + ]; + } +} diff --git a/conf/site/app/Models/User.php b/conf/site/app/Models/User.php new file mode 100644 index 00000000..35333805 --- /dev/null +++ b/conf/site/app/Models/User.php @@ -0,0 +1,114 @@ + 'datetime', + ]; + + protected $primaryKey = 'id'; + + protected $keyType = 'uuid'; + + public $incrementing = false; + + public static function loginRules() + { + return [ + 'email' => 'required', + 'password' => 'required' + ]; + } + + public static function registerRules() + { + return [ + 'name' => ['required', 'string', 'max:255'], + 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], + 'password' => ['required', 'string', 'min:8', 'confirmed'] + ]; + } + + public static function updateRules() + { + return [ + 'name' => ['required', 'string', 'max:255'], + 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'] + ]; + } + + public function verification() + { + return $this->hasOne('\App\Auth\EmailVerification'); + } + + /** + * Returns a user's login sessions + * + * @return mixed + */ + public function sessions() + { + return $this->hasMany('\App\Auth\LoginSession'); + } + + /** + * Get the identifier that will be stored in the subject claim of the JWT. + * + * @return mixed + */ + public function getJWTIdentifier() + { + return $this->getKey(); + } + + /** + * Return a key value array, containing any custom claims to be added to the JWT. + * + * @return array + */ + public function getJWTCustomClaims() + { + return []; + } + + public function setPasswordAttribute($password) + { + if (!empty($password)) { + $this->attributes['password'] = Hash::make($password); + } + } +} diff --git a/conf/site/app/Observers/SpeedtestObserver.php b/conf/site/app/Observers/SpeedtestObserver.php new file mode 100644 index 00000000..1ad26d27 --- /dev/null +++ b/conf/site/app/Observers/SpeedtestObserver.php @@ -0,0 +1,30 @@ +store($speedtest); + } catch (InfluxDBNotEnabledException $e) { + // / + } catch (Exception $e) { + Log::error($e); + } + } +} diff --git a/conf/site/app/Providers/EventServiceProvider.php b/conf/site/app/Providers/EventServiceProvider.php index b33e65d5..e343a8b6 100644 --- a/conf/site/app/Providers/EventServiceProvider.php +++ b/conf/site/app/Providers/EventServiceProvider.php @@ -10,6 +10,8 @@ use App\Listeners\SpeedtestCompleteListener; use App\Listeners\SpeedtestFailedListener; use App\Listeners\SpeedtestOverviewListener; use App\Listeners\TestNotificationListener; +use App\Observers\SpeedtestObserver; +use App\Models\Speedtest; use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; @@ -49,6 +51,6 @@ class EventServiceProvider extends ServiceProvider { parent::boot(); - // + Speedtest::observe(SpeedtestObserver::class); } } diff --git a/conf/site/app/Utils/InfluxDB/InfluxDB.php b/conf/site/app/Utils/InfluxDB/InfluxDB.php new file mode 100644 index 00000000..defe5f63 --- /dev/null +++ b/conf/site/app/Utils/InfluxDB/InfluxDB.php @@ -0,0 +1,113 @@ +client = $client; + } + + /** + * Connect to influx db + * + * @param string $host + * @param integer $port + * @param string $database + * @return InfluxDB + */ + public static function connect() + { + if (!(bool) SettingsHelper::get('influx_db_enabled')->value) { + throw new InfluxDBNotEnabledException(); + } + + $host = SettingsHelper::get('influx_db_host')->value; + $port = SettingsHelper::get('influx_db_port')->value; + $username = SettingsHelper::get('influx_db_username')->value; + $password = SettingsHelper::get('influx_db_password')->value; + $database = SettingsHelper::get('influx_db_database')->value; + $version = (int) SettingsHelper::get('influx_db_version')->value; + + $wrapper = $version === 1 + ? new InfluxDBVersion1Wrapper( + new Version1( + str_replace(['http://', 'https://'], '', $host), + $port, + $username, + $password + ) + ) + : new InfluxDBVersion2Wrapper( + new Version2([ + 'url' => $host . ':' . $port, + 'token' => '', + ]) + ); + + return (new self($wrapper))->setDatabase($database) + ->testConnection(); + } + + /** + * Set the database field + * + * @param string $database + * @return InfluxDB + */ + public function setDatabase(string $database): InfluxDB + { + $this->database = $database; + + return $this; + } + + /** + * Test the connection + * + * @throws InfluxDBConnectionErrorException + * @return InfluxDB + */ + public function testConnection(): InfluxDB + { + if (!$this->client->testConnection()) { + throw new InfluxDBConnectionErrorException(); + } + + if (!$this->doesDatabaseExist()) { + $this->createDatabase(); + } + + return $this; + } + + public function doesDatabaseExist(): bool + { + return $this->client->doesDatabaseExist($this->database); + } + + public function createDatabase(): bool + { + return $this->client->createDatabase($this->database); + } + + public function store(Speedtest $speedtest): InfluxDB + { + $this->client->store($speedtest); + + return $this; + } +} diff --git a/conf/site/app/Utils/InfluxDB/InfluxDBVersion1Wrapper.php b/conf/site/app/Utils/InfluxDB/InfluxDBVersion1Wrapper.php new file mode 100644 index 00000000..c439f712 --- /dev/null +++ b/conf/site/app/Utils/InfluxDB/InfluxDBVersion1Wrapper.php @@ -0,0 +1,74 @@ +client = $client; + } + + public function testConnection(): bool + { + try { + $this->client->listDatabases(); + + return true; + } catch (Exception $e) { + Log::error($e); + + return false; + } + } + + public function doesDatabaseExist(string $database): bool + { + $this->database = $this->client->selectDB($database); + + return (bool) $this->database->exists(); + } + + public function createDatabase(string $database): bool + { + try { + $this->database->create( + new RetentionPolicy( + 'speedtest_retention_policy', + config('services.influxdb.retention'), + 1, + true + ) + ); + + return true; + } catch (Exception $e) { + Log::error($e); + return false; + } + } + + public function store(Speedtest $speedtest): bool + { + return $this->database->writePoints([ + new Point( + 'speedtest', + null, + ['host' => config('services.influxdb.host')], + $speedtest->formatForInfluxDB(), + ) + ]); + } +} diff --git a/conf/site/app/Utils/InfluxDB/InfluxDBVersion2Wrapper.php b/conf/site/app/Utils/InfluxDB/InfluxDBVersion2Wrapper.php new file mode 100644 index 00000000..f7d24946 --- /dev/null +++ b/conf/site/app/Utils/InfluxDB/InfluxDBVersion2Wrapper.php @@ -0,0 +1,37 @@ +client = $client; + } + + public function testConnection(): bool + { + return $this->client->health()->getStatus() !== 'pass'; + } + + public function doesDatabaseExist(string $database): bool + { + return true; + } + + public function createDatabase(string $database): bool + { + return true; + } + + public function store(Speedtest $speedtest): bool + { + return true; + } +} diff --git a/conf/site/app/Utils/OoklaTester.php b/conf/site/app/Utils/OoklaTester.php index 74e617da..f127b08f 100644 --- a/conf/site/app/Utils/OoklaTester.php +++ b/conf/site/app/Utils/OoklaTester.php @@ -6,7 +6,7 @@ use App\Exceptions\SpeedtestFailureException; use App\Helpers\SettingsHelper; use App\Helpers\SpeedtestHelper; use App\Interfaces\SpeedtestProvider; -use App\Speedtest; +use App\Models\Speedtest; use Cache; use Exception; use JsonException; diff --git a/conf/site/changelog.json b/conf/site/changelog.json index 7302b2c9..89c3ab38 100644 --- a/conf/site/changelog.json +++ b/conf/site/changelog.json @@ -1,4 +1,10 @@ { + "1.12.0": [ + { + "description": "Added InfluxDB intergation.", + "link": "" + } + ], "1.11.1": [ { "description": "Add option to show/hide columns in the all tests table.", diff --git a/conf/site/composer.json b/conf/site/composer.json index eacdb52c..aa56ac7e 100644 --- a/conf/site/composer.json +++ b/conf/site/composer.json @@ -16,6 +16,8 @@ "guzzlehttp/guzzle": "^7.0.1", "henrywhitaker3/healthchecks-io": "^1.0", "henrywhitaker3/laravel-actions": "^1.0", + "influxdata/influxdb-client-php": "^1.12", + "influxdb/influxdb-php": "^1.15", "laravel-notification-channels/telegram": "^0.5.0", "laravel/framework": "^8.0", "laravel/slack-notification-channel": "^2.0", @@ -45,12 +47,10 @@ }, "autoload": { "psr-4": { - "App\\": "app/" - }, - "classmap": [ - "database/seeds", - "database/factories" - ] + "App\\": "app/", + "Database\\Factories\\": "database/factories/", + "Database\\Seeders\\": "database/seeders/" + } }, "autoload-dev": { "psr-4": { diff --git a/conf/site/composer.lock b/conf/site/composer.lock index b16ed50e..120c2d80 100644 --- a/conf/site/composer.lock +++ b/conf/site/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2c905613bf401a9978baa23d1a80b710", + "content-hash": "46d75195c9e28db55cd2b086a6846e13", "packages": [ { "name": "asm89/stack-cors", @@ -1309,6 +1309,118 @@ }, "time": "2021-02-06T09:50:49+00:00" }, + { + "name": "influxdata/influxdb-client-php", + "version": "1.12.0", + "source": { + "type": "git", + "url": "https://github.com/influxdata/influxdb-client-php.git", + "reference": "e04f802a4d9c52b5b497077673269e8463fdb6ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/influxdata/influxdb-client-php/zipball/e04f802a4d9c52b5b497077673269e8463fdb6ea", + "reference": "e04f802a4d9c52b5b497077673269e8463fdb6ea", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "guzzlehttp/guzzle": "^6.2|^7.0.1", + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.4|^9.1", + "squizlabs/php_codesniffer": "~2.6" + }, + "type": "library", + "autoload": { + "psr-4": { + "InfluxDB2\\": "src/InfluxDB2" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "InfluxDB (v2+) Client Library for PHP", + "homepage": "https://www.github.com/influxdata/influxdb-client-php", + "keywords": [ + "influxdb" + ], + "support": { + "issues": "https://github.com/influxdata/influxdb-client-php/issues", + "source": "https://github.com/influxdata/influxdb-client-php/tree/1.12.0" + }, + "time": "2021-04-01T06:28:57+00:00" + }, + { + "name": "influxdb/influxdb-php", + "version": "1.15.2", + "source": { + "type": "git", + "url": "https://github.com/influxdata/influxdb-php.git", + "reference": "d6e59f4f04ab9107574fda69c2cbe36671253d03" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/influxdata/influxdb-php/zipball/d6e59f4f04ab9107574fda69c2cbe36671253d03", + "reference": "d6e59f4f04ab9107574fda69c2cbe36671253d03", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^6.0|^7.0", + "php": "^5.5 || ^7.0 || ^8.0" + }, + "require-dev": { + "dms/phpunit-arraysubset-asserts": "^0.2.1", + "phpunit/phpunit": "^9.5" + }, + "suggest": { + "ext-curl": "Curl extension, needed for Curl driver", + "stefanotorresi/influxdb-php-async": "An asyncronous client for InfluxDB, implemented via ReactPHP." + }, + "type": "library", + "autoload": { + "psr-4": { + "InfluxDB\\": "src/InfluxDB" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Stephen Hoogendijk", + "email": "stephen@tca0.nl" + }, + { + "name": "Daniel Martinez", + "email": "danimartcas@hotmail.com" + }, + { + "name": "Gianluca Arbezzano", + "email": "gianarb92@gmail.com" + } + ], + "description": "InfluxDB client library for PHP", + "keywords": [ + "client", + "influxdata", + "influxdb", + "influxdb class", + "influxdb client", + "influxdb library", + "time series" + ], + "support": { + "issues": "https://github.com/influxdata/influxdb-php/issues", + "source": "https://github.com/influxdata/influxdb-php/tree/1.15.2" + }, + "time": "2020-12-26T17:45:17+00:00" + }, { "name": "laravel-notification-channels/telegram", "version": "0.5.1", diff --git a/conf/site/config/services.php b/conf/site/config/services.php index 88eb96e4..c966d76e 100644 --- a/conf/site/config/services.php +++ b/conf/site/config/services.php @@ -34,4 +34,9 @@ return [ 'token' => env('TELEGRAM_BOT_TOKEN', 'YOUR BOT TOKEN HERE') ], + 'influxdb' => [ + 'retention' => env('INFLUXDB_RETENTION', '30d'), + 'host' => env('INFLUXDB_HOST_TAG', 'speedtest'), + ], + ]; diff --git a/conf/site/config/speedtest.php b/conf/site/config/speedtest.php index ceef7301..95a8f7a4 100644 --- a/conf/site/config/speedtest.php +++ b/conf/site/config/speedtest.php @@ -7,7 +7,7 @@ return [ |-------------------------------------------------------------------------- */ - 'version' => '1.11.1', + 'version' => '1.12.0', /* |-------------------------------------------------------------------------- diff --git a/conf/site/database/factories/SpeedtestFactory.php b/conf/site/database/factories/SpeedtestFactory.php new file mode 100644 index 00000000..c09c6798 --- /dev/null +++ b/conf/site/database/factories/SpeedtestFactory.php @@ -0,0 +1,32 @@ + rand(15, 900), + 'upload' => rand(15, 900), + 'ping' => rand(1, 25), + 'scheduled' => (bool) rand(0, 1), + 'failed' => false, + ]; + } +} diff --git a/conf/site/database/factories/UserFactory.php b/conf/site/database/factories/UserFactory.php index 741edead..fa9360e7 100644 --- a/conf/site/database/factories/UserFactory.php +++ b/conf/site/database/factories/UserFactory.php @@ -2,7 +2,7 @@ /** @var \Illuminate\Database\Eloquent\Factory $factory */ -use App\User; +use App\Models\User; use Faker\Generator as Faker; use Illuminate\Support\Str; diff --git a/conf/site/database/migrations/2014_10_12_000000_create_users_table.php b/conf/site/database/migrations/2014_10_12_000000_create_users_table.php index 4bfd7b91..5d0ad5dc 100644 --- a/conf/site/database/migrations/2014_10_12_000000_create_users_table.php +++ b/conf/site/database/migrations/2014_10_12_000000_create_users_table.php @@ -1,6 +1,6 @@ 'influx_db_enabled', + 'value' => false, + 'description' => 'Enable the InfluxDB integration for speedtests.' + ]); + } + + if (!SettingsHelper::get('influx_db_host')) { + Setting::create([ + 'name' => 'influx_db_host', + 'value' => '', + 'description' => 'InfluxDB hostname, include the protocol (http:// or https://).' + ]); + } + + if (!SettingsHelper::get('influx_db_port')) { + Setting::create([ + 'name' => 'influx_db_port', + 'value' => '', + 'description' => 'InfluxDB port' + ]); + } + + if (!SettingsHelper::get('influx_db_database')) { + Setting::create([ + 'name' => 'influx_db_database', + 'value' => '', + 'description' => 'InfluxDB database' + ]); + } + + if (!SettingsHelper::get('influx_db_username')) { + Setting::create([ + 'name' => 'influx_db_username', + 'value' => '', + 'description' => 'InfluxDB username' + ]); + } + + if (!SettingsHelper::get('influx_db_password')) { + Setting::create([ + 'name' => 'influx_db_password', + 'value' => '', + 'description' => 'InfluxDB password' + ]); + } + + if (!SettingsHelper::get('influx_db_version')) { + Setting::create([ + 'name' => 'influx_db_version', + 'value' => 1, + 'description' => 'InfluxDB version' + ]); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Setting::whereIn('name', [ + 'influx_db_enabled', + 'influx_db_host', + 'influx_db_port', + 'influx_db_database', + 'influx_db_username', + 'influx_db_password', + 'influx_db_version', + ])->delete(); + } +} diff --git a/conf/site/database/seeds/DatabaseSeeder.php b/conf/site/database/seeders/DatabaseSeeder.php similarity index 64% rename from conf/site/database/seeds/DatabaseSeeder.php rename to conf/site/database/seeders/DatabaseSeeder.php index 237dfc5d..79580814 100644 --- a/conf/site/database/seeds/DatabaseSeeder.php +++ b/conf/site/database/seeders/DatabaseSeeder.php @@ -1,5 +1,8 @@ call(UserSeeder::class); + $this->call(SpeedtestSeeder::class); } } diff --git a/conf/site/database/seeders/SpeedtestSeeder.php b/conf/site/database/seeders/SpeedtestSeeder.php new file mode 100644 index 00000000..5e628dbe --- /dev/null +++ b/conf/site/database/seeders/SpeedtestSeeder.php @@ -0,0 +1,21 @@ +count(250) + ->create(); + } +} diff --git a/conf/site/routes/api.php b/conf/site/routes/api.php index 939628e3..8970db36 100644 --- a/conf/site/routes/api.php +++ b/conf/site/routes/api.php @@ -7,7 +7,7 @@ use App\Http\Controllers\HomepageDataController; use App\Http\Controllers\SettingsController; use App\Http\Controllers\SpeedtestController; use App\Http\Controllers\UpdateController; -use App\Speedtest; +use App\Models\Speedtest; use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; diff --git a/conf/site/tests/Feature/APISpeedtestTest.php b/conf/site/tests/Feature/APISpeedtestTest.php index fa13e7d0..4c40ca10 100644 --- a/conf/site/tests/Feature/APISpeedtestTest.php +++ b/conf/site/tests/Feature/APISpeedtestTest.php @@ -2,7 +2,7 @@ namespace Tests\Feature; -use App\Speedtest; +use App\Models\Speedtest; use Faker\Factory; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\WithFaker; diff --git a/conf/site/tests/Feature/SpeedtestTest.php b/conf/site/tests/Feature/SpeedtestTest.php index 4efc6e17..e3560a20 100644 --- a/conf/site/tests/Feature/SpeedtestTest.php +++ b/conf/site/tests/Feature/SpeedtestTest.php @@ -3,14 +3,28 @@ namespace Tests\Feature; use App\Helpers\SpeedtestHelper; +use App\Interfaces\SpeedtestProvider; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\WithFaker; +use Tests\Mocks\OoklaTesterMocker; use Tests\TestCase; class SpeedtestTest extends TestCase { use RefreshDatabase; + public function setUp(): void + { + parent::setUp(); + + $this->app->singleton( + SpeedtestProvider::class, + function () { + return new OoklaTesterMocker(); + } + ); + } + /** * Runs a speedtest * diff --git a/conf/site/tests/Feature/Utils/InfluxDB/InfluxDBWrapperWrapperTest.php b/conf/site/tests/Feature/Utils/InfluxDB/InfluxDBWrapperWrapperTest.php new file mode 100644 index 00000000..2ccdc5e8 --- /dev/null +++ b/conf/site/tests/Feature/Utils/InfluxDB/InfluxDBWrapperWrapperTest.php @@ -0,0 +1,26 @@ +expectException(InfluxDBNotEnabledException::class); + + InfluxDB::connect(); + } +} diff --git a/conf/site/tests/Mocks/OoklaTesterMocker.php b/conf/site/tests/Mocks/OoklaTesterMocker.php new file mode 100644 index 00000000..035696c3 --- /dev/null +++ b/conf/site/tests/Mocks/OoklaTesterMocker.php @@ -0,0 +1,59 @@ +passes = $passes; + } + + public function run($output = null): Speedtest + { + $output = $output ?? $this->output(); + + try { + $output = json_decode($output, true, 512, JSON_THROW_ON_ERROR); + } catch (Exception $e) { + throw new SpeedtestFailureException(); + } + + return $this->passes + ? Speedtest::factory()->create() + : Speedtest::factory()->create([ + 'download' => 0, + 'upload' => 0, + 'ping' => 0, + 'failed' => true, + ]); + } + + public function output() + { + return !$this->passes + ? null + : json_encode([ + 'type' => 'result', + 'download' => ['bandwidth' => '50'], + 'upload' => ['bandwidth' => '50'], + 'ping' => ['latency' => '50'], + 'server' => [ + 'id' => '1', + 'name' => 'PHPUnit', + 'host' => 'phpunit', + 'port' => '443', + ], + 'result' => [ + 'url' => 'some-url', + ] + ]); + } +} diff --git a/conf/site/tests/Unit/Controllers/SpeedtestController/DeleteTest.php b/conf/site/tests/Unit/Controllers/SpeedtestController/DeleteTest.php index 00e1ed95..4265c184 100644 --- a/conf/site/tests/Unit/Controllers/SpeedtestController/DeleteTest.php +++ b/conf/site/tests/Unit/Controllers/SpeedtestController/DeleteTest.php @@ -3,7 +3,7 @@ namespace Tests\Unit\Controllers\SpeedtestController; use App\Http\Controllers\SpeedtestController; -use App\Speedtest; +use App\Models\Speedtest; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; diff --git a/conf/site/tests/Unit/Controllers/SpeedtestController/LatestTest.php b/conf/site/tests/Unit/Controllers/SpeedtestController/LatestTest.php index af7209cd..f1e18b53 100644 --- a/conf/site/tests/Unit/Controllers/SpeedtestController/LatestTest.php +++ b/conf/site/tests/Unit/Controllers/SpeedtestController/LatestTest.php @@ -3,7 +3,7 @@ namespace Tests\Unit\Controllers\SpeedtestController; use App\Http\Controllers\SpeedtestController; -use App\Speedtest; +use App\Models\Speedtest; use DB; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; diff --git a/conf/site/tests/Unit/Helpers/SpeedtestHelper/AbsoluteThresholdTest.php b/conf/site/tests/Unit/Helpers/SpeedtestHelper/AbsoluteThresholdTest.php index f257f6ff..b372dc50 100644 --- a/conf/site/tests/Unit/Helpers/SpeedtestHelper/AbsoluteThresholdTest.php +++ b/conf/site/tests/Unit/Helpers/SpeedtestHelper/AbsoluteThresholdTest.php @@ -4,7 +4,7 @@ namespace Tests\Unit\Helpers\SpeedtestHelper; use App\Helpers\SettingsHelper; use App\Helpers\SpeedtestHelper; -use App\Speedtest; +use App\Models\Speedtest; use Illuminate\Foundation\Testing\RefreshDatabase; use InvalidArgumentException; use Tests\TestCase; diff --git a/conf/site/tests/Unit/Helpers/SpeedtestHelper/CheckOutputTest.php b/conf/site/tests/Unit/Helpers/SpeedtestHelper/CheckOutputTest.php index d017cb7b..febf818f 100644 --- a/conf/site/tests/Unit/Helpers/SpeedtestHelper/CheckOutputTest.php +++ b/conf/site/tests/Unit/Helpers/SpeedtestHelper/CheckOutputTest.php @@ -4,6 +4,7 @@ namespace Tests\Unit\Helpers\SpeedtestHelper; use App\Utils\OoklaTester; use PHPUnit\Framework\TestCase; +use Tests\Mocks\OoklaTesterMocker; class CheckOutputTest extends TestCase { @@ -12,6 +13,7 @@ class CheckOutputTest extends TestCase public function setUp(): void { $this->speedtestProvider = new OoklaTester(); + $this->mocker = new OoklaTesterMocker(); } /** diff --git a/conf/site/tests/Unit/Helpers/SpeedtestHelper/FailureRateTest.php b/conf/site/tests/Unit/Helpers/SpeedtestHelper/FailureRateTest.php index fe32692e..50ab4332 100644 --- a/conf/site/tests/Unit/Helpers/SpeedtestHelper/FailureRateTest.php +++ b/conf/site/tests/Unit/Helpers/SpeedtestHelper/FailureRateTest.php @@ -3,7 +3,7 @@ namespace Tests\Unit\Helpers\SpeedtestHelper; use App\Helpers\SpeedtestHelper; -use App\Speedtest; +use App\Models\Speedtest; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; diff --git a/conf/site/tests/Unit/Helpers/SpeedtestHelper/PercentageThresholdTest.php b/conf/site/tests/Unit/Helpers/SpeedtestHelper/PercentageThresholdTest.php index 2ac63c27..d3ab232a 100644 --- a/conf/site/tests/Unit/Helpers/SpeedtestHelper/PercentageThresholdTest.php +++ b/conf/site/tests/Unit/Helpers/SpeedtestHelper/PercentageThresholdTest.php @@ -4,7 +4,7 @@ namespace Tests\Unit\Helpers\SpeedtestHelper; use App\Helpers\SettingsHelper; use App\Helpers\SpeedtestHelper; -use App\Speedtest; +use App\Models\Speedtest; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; diff --git a/conf/site/tests/Unit/Helpers/SpeedtestHelper/SpeedtestTest.php b/conf/site/tests/Unit/Helpers/SpeedtestHelper/SpeedtestTest.php index 9c5db28f..7e4670bb 100644 --- a/conf/site/tests/Unit/Helpers/SpeedtestHelper/SpeedtestTest.php +++ b/conf/site/tests/Unit/Helpers/SpeedtestHelper/SpeedtestTest.php @@ -6,6 +6,7 @@ use App\Exceptions\SpeedtestFailureException; use App\Helpers\SpeedtestHelper; use App\Utils\OoklaTester; use Illuminate\Foundation\Testing\RefreshDatabase; +use Tests\Mocks\OoklaTesterMocker; use Tests\TestCase; class SpeedtestTest extends TestCase @@ -22,17 +23,7 @@ class SpeedtestTest extends TestCase $this->speedtestProvider = new OoklaTester(); - $this->output = $this->speedtestProvider->output(); - } - - /** - * A basic unit test example. - * - * @return void - */ - public function testOutputFunction() - { - $this->assertJson($this->output); + $this->output = (new OoklaTesterMocker())->output(); } /** diff --git a/conf/site/tests/Unit/Listeners/SpeedtestCompleteListener/SlackTest.php b/conf/site/tests/Unit/Listeners/SpeedtestCompleteListener/SlackTest.php index 65708a8e..72b94ffb 100644 --- a/conf/site/tests/Unit/Listeners/SpeedtestCompleteListener/SlackTest.php +++ b/conf/site/tests/Unit/Listeners/SpeedtestCompleteListener/SlackTest.php @@ -4,7 +4,7 @@ namespace Tests\Unit\Listeners\SpeedtestCompleteListener; use App\Helpers\SettingsHelper; use App\Listeners\SpeedtestCompleteListener; -use App\Speedtest; +use App\Models\Speedtest; use Exception; use Illuminate\Foundation\Testing\RefreshDatabase; use stdClass; diff --git a/conf/site/tests/Unit/Listeners/SpeedtestCompleteListener/TelegramTest.php b/conf/site/tests/Unit/Listeners/SpeedtestCompleteListener/TelegramTest.php index 8c37051b..17fd28a2 100644 --- a/conf/site/tests/Unit/Listeners/SpeedtestCompleteListener/TelegramTest.php +++ b/conf/site/tests/Unit/Listeners/SpeedtestCompleteListener/TelegramTest.php @@ -4,7 +4,7 @@ namespace Tests\Unit\Listeners\SpeedtestCompleteListener; use App\Helpers\SettingsHelper; use App\Listeners\SpeedtestCompleteListener; -use App\Speedtest; +use App\Models\Speedtest; use Exception; use Illuminate\Foundation\Testing\RefreshDatabase; use stdClass; diff --git a/conf/site/tests/Unit/Listeners/SpeedtestFailedListener/SlackTest.php b/conf/site/tests/Unit/Listeners/SpeedtestFailedListener/SlackTest.php index fea50dc1..1ab96fda 100644 --- a/conf/site/tests/Unit/Listeners/SpeedtestFailedListener/SlackTest.php +++ b/conf/site/tests/Unit/Listeners/SpeedtestFailedListener/SlackTest.php @@ -4,7 +4,7 @@ namespace Tests\Unit\Listeners\SpeedtestFailedListener; use App\Helpers\SettingsHelper; use App\Listeners\SpeedtestFailedListener; -use App\Speedtest; +use App\Models\Speedtest; use Exception; use Illuminate\Foundation\Testing\RefreshDatabase; use stdClass; diff --git a/conf/site/tests/Unit/Listeners/SpeedtestFailedListener/TelegramTest.php b/conf/site/tests/Unit/Listeners/SpeedtestFailedListener/TelegramTest.php index 2e273738..f437abe5 100644 --- a/conf/site/tests/Unit/Listeners/SpeedtestFailedListener/TelegramTest.php +++ b/conf/site/tests/Unit/Listeners/SpeedtestFailedListener/TelegramTest.php @@ -4,7 +4,7 @@ namespace Tests\Unit\Listeners\SpeedtestFailedListener; use App\Helpers\SettingsHelper; use App\Listeners\SpeedtestFailedListener; -use App\Speedtest; +use App\Models\Speedtest; use Exception; use Illuminate\Foundation\Testing\RefreshDatabase; use stdClass; diff --git a/conf/site/tests/Unit/Listeners/SpeedtestOverviewListener/SlackTest.php b/conf/site/tests/Unit/Listeners/SpeedtestOverviewListener/SlackTest.php index 8e471aa0..aa88395c 100644 --- a/conf/site/tests/Unit/Listeners/SpeedtestOverviewListener/SlackTest.php +++ b/conf/site/tests/Unit/Listeners/SpeedtestOverviewListener/SlackTest.php @@ -4,7 +4,7 @@ namespace Tests\Unit\Listeners\SpeedtestOverviewListener; use App\Helpers\SettingsHelper; use App\Listeners\SpeedtestOverviewListener; -use App\Speedtest; +use App\Models\Speedtest; use Exception; use Illuminate\Foundation\Testing\RefreshDatabase; use stdClass; diff --git a/conf/site/tests/Unit/Listeners/SpeedtestOverviewListener/TelegramTest.php b/conf/site/tests/Unit/Listeners/SpeedtestOverviewListener/TelegramTest.php index fb841e03..001e0189 100644 --- a/conf/site/tests/Unit/Listeners/SpeedtestOverviewListener/TelegramTest.php +++ b/conf/site/tests/Unit/Listeners/SpeedtestOverviewListener/TelegramTest.php @@ -4,7 +4,7 @@ namespace Tests\Unit\Listeners\SpeedtestOverviewListener; use App\Helpers\SettingsHelper; use App\Listeners\SpeedtestOverviewListener; -use App\Speedtest; +use App\Models\Speedtest; use Exception; use Illuminate\Foundation\Testing\RefreshDatabase; use stdClass;