-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
basic anonymous usage telemetry (#597)
- Loading branch information
1 parent
912b932
commit 8fb18b0
Showing
23 changed files
with
310 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ explorer/static/ | |
# Sphinx documentation | ||
docs/_build/ | ||
.env | ||
tst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
Running Locally (quick start) | ||
----------------------------- | ||
|
||
Included is a test_project that you can use to kick the tires. Just | ||
create a new virtualenv, cd into ``test_project`` and run ``start.sh`` (or | ||
walk through the steps yourself) to get a test instance of the app up | ||
and running. | ||
|
||
You can now navigate to 127.0.0.1:8000/ and begin exploring! | ||
|
||
Installing From Source | ||
---------------------- | ||
|
||
If you are installing SQL Explorer from source (by cloning the repository), | ||
you may want to first look at simply running test_project/start.sh. | ||
|
||
If you want to install into an existing project, you can do so by following | ||
the install instructions, and then additionally building the front-end dependencies. | ||
|
||
After cloning, simply run: | ||
|
||
:: | ||
|
||
nvm install | ||
nvm use | ||
npm install | ||
npm run build | ||
|
||
The front-end assets will be built and placed in the /static/ folder | ||
and collected properly by your Django installation during the `collect static` | ||
phase. Copy the /explorer directory into site-packages and you're ready to go. | ||
|
||
Tests | ||
----- | ||
|
||
Factory Boy is needed if you'd like to run the tests, which can you do | ||
easily: | ||
|
||
``python manage.py test --settings=tests.settings`` | ||
|
||
and with coverage: | ||
|
||
``coverage run --source='.' manage.py test --settings=tests.settings`` | ||
``coverage combine`` | ||
``coverage report`` | ||
|
||
Running Celery | ||
-------------- | ||
|
||
To run tests with Celery enabled, you will need to install Redis and Celery. | ||
:: | ||
|
||
brew install redis | ||
pip install celery | ||
pip install redis | ||
|
||
Then run the redis server and the celery worker. A good way of doing it is: | ||
:: | ||
|
||
screen -d -S 'redis' -m redis-server | ||
screen -d -S 'celery' -m celery -A test_project worker | ||
|
||
Finally, set ``EXPLORER_TASKS_ENABLED`` to True in tests.settings and run the tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ Django SQL Explorer | |
|
||
features.rst | ||
install.rst | ||
development.rst | ||
settings.rst | ||
dependencies.rst | ||
history.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from test_project.settings import * # noqa | ||
|
||
EXPLORER_ENABLE_ANONYMOUS_STATS = False | ||
EXPLORER_TASKS_ENABLED = False # set to true to test async tasks | ||
CELERY_BROKER_URL = "redis://localhost:6379/0" | ||
CELERY_TASK_ALWAYS_EAGER = True | ||
|
||
DATABASES = { | ||
"default": { | ||
"ENGINE": "django.db.backends.sqlite3", | ||
"NAME": "tst", | ||
"TEST": { | ||
"NAME": "tst" | ||
} | ||
}, | ||
"alt": { | ||
"ENGINE": "django.db.backends.sqlite3", | ||
"NAME": "tst2", | ||
"TEST": { | ||
"NAME": "tst2" | ||
} | ||
}, | ||
"not_registered": { | ||
"ENGINE": "django.db.backends.sqlite3", | ||
"NAME": "tst3", | ||
"TEST": { | ||
"NAME": "tst3" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from django.test import TestCase | ||
from explorer.tracker import instance_identifier, gather_summary_stats | ||
|
||
|
||
class TestTracker(TestCase): | ||
|
||
def test_instance_identifier(self): | ||
v = instance_identifier() | ||
|
||
# The SHA-256 hash produces a fixed-length output of 256 bits. | ||
# When represented as a hexadecimal string, each byte (8 bits) is | ||
# represented by 2 hex chars. 256/8*2 = 64 | ||
self.assertEqual(len(v), 64) | ||
|
||
def test_gather_summary_stats(self): | ||
res = gather_summary_stats() | ||
self.assertEqual(res["total_query_count"], 0) | ||
self.assertEqual(res["default_database"], "sqlite") |
Oops, something went wrong.