-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Add Tokenserver integration tests #1152
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ebd86a7
test: Add Tokenserver integration tests
9343bf1
remove unnecessary requirements
edb91e0
use absolute paths
248929e
fix flake8 errors
7de1c09
add test
708ba57
fix schema
722d0ce
minor changes; remove file
172f3e6
flake8
4401cb9
use sqlalchemy
f39978a
flake8
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
2 changes: 2 additions & 0 deletions
2
src/tokenserver/migrations/2021-09-30-142643_remove_foreign_key_constraints/down.sql
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,2 @@ | ||
ALTER TABLE `nodes` ADD CONSTRAINT `nodes_ibfk_1` FOREIGN KEY (`service`) REFERENCES `services` (`id`); | ||
ALTER TABLE `users` ADD CONSTRAINT `users_ibfk_1` FOREIGN KEY (`nodeid`) REFERENCES `nodes` (`id`); |
2 changes: 2 additions & 0 deletions
2
src/tokenserver/migrations/2021-09-30-142643_remove_foreign_key_constraints/up.sql
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,2 @@ | ||
ALTER TABLE `nodes` DROP FOREIGN KEY `nodes_ibfk_1`; | ||
ALTER TABLE `users` DROP FOREIGN KEY `users_ibfk_1`; |
5 changes: 5 additions & 0 deletions
5
src/tokenserver/migrations/2021-09-30-142654_remove_node_defaults/down.sql
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,5 @@ | ||
ALTER TABLE `nodes` ALTER `available` SET DEFAULT 0; | ||
ALTER TABLE `nodes` ALTER `current_load` SET DEFAULT 0; | ||
ALTER TABLE `nodes` ALTER `capacity` SET DEFAULT 0; | ||
ALTER TABLE `nodes` ALTER `downed` SET DEFAULT 0; | ||
ALTER TABLE `nodes` ALTER `backoff` SET DEFAULT 0; |
5 changes: 5 additions & 0 deletions
5
src/tokenserver/migrations/2021-09-30-142654_remove_node_defaults/up.sql
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,5 @@ | ||
ALTER TABLE `nodes` ALTER `available` DROP DEFAULT; | ||
ALTER TABLE `nodes` ALTER `current_load` DROP DEFAULT; | ||
ALTER TABLE `nodes` ALTER `capacity` DROP DEFAULT; | ||
ALTER TABLE `nodes` ALTER `downed` DROP DEFAULT; | ||
ALTER TABLE `nodes` ALTER `backoff` DROP DEFAULT; |
4 changes: 4 additions & 0 deletions
4
src/tokenserver/migrations/2021-09-30-142746_add_indexes/down.sql
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,4 @@ | ||
ALTER TABLE `nodes` DROP INDEX `unique_idx`; | ||
ALTER TABLE `users` DROP INDEX `lookup_idx`; | ||
ALTER TABLE `users` DROP INDEX `replaced_at_idx`; | ||
ALTER TABLE `users` DROP INDEX `node_idx`; |
4 changes: 4 additions & 0 deletions
4
src/tokenserver/migrations/2021-09-30-142746_add_indexes/up.sql
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,4 @@ | ||
ALTER TABLE `nodes` ADD UNIQUE KEY `unique_idx` (`service`, `node`); | ||
ALTER TABLE `users` ADD INDEX `lookup_idx` (`email`, `service`, `created_at`); | ||
ALTER TABLE `users` ADD INDEX `replaced_at_idx` (`service`, `replaced_at`); | ||
ALTER TABLE `users` ADD INDEX `node_idx` (`nodeid`); |
1 change: 1 addition & 0 deletions
1
src/tokenserver/migrations/2021-09-30-144043_remove_nodes_service_key/down.sql
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 @@ | ||
ALTER TABLE `nodes` ADD KEY `service` (`service`); |
1 change: 1 addition & 0 deletions
1
src/tokenserver/migrations/2021-09-30-144043_remove_nodes_service_key/up.sql
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 @@ | ||
ALTER TABLE `nodes` DROP KEY `service`; |
1 change: 1 addition & 0 deletions
1
src/tokenserver/migrations/2021-09-30-144225_remove_users_nodeid_key/down.sql
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 @@ | ||
ALTER TABLE `users` ADD KEY `nodeid` (`nodeid`); |
1 change: 1 addition & 0 deletions
1
src/tokenserver/migrations/2021-09-30-144225_remove_users_nodeid_key/up.sql
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 @@ | ||
ALTER TABLE `users` DROP KEY `nodeid`; |
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
Empty file.
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,33 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at http://mozilla.org/MPL/2.0/. | ||
import unittest | ||
|
||
from tokenserver.test_authorization import TestAuthorization | ||
from tokenserver.test_e2e import TestE2e | ||
from tokenserver.test_misc import TestMisc | ||
from tokenserver.test_node_assignment import TestNodeAssignment | ||
|
||
|
||
def run_local_tests(): | ||
return run_tests([TestAuthorization, TestMisc, TestNodeAssignment]) | ||
|
||
|
||
def run_end_to_end_tests(): | ||
return run_tests([TestE2e]) | ||
|
||
|
||
def run_tests(test_cases): | ||
loader = unittest.TestLoader() | ||
success = True | ||
|
||
for test_case in test_cases: | ||
suite = loader.loadTestsFromTestCase(test_case) | ||
runner = unittest.TextTestRunner() | ||
res = runner.run(suite) | ||
success = success and res.wasSuccessful() | ||
|
||
if success: | ||
return 0 | ||
else: | ||
return 1 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔I wonder if this pattern might creep up enough that it's worth creating a macro or function that encapsulates it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you foresee other types of requests aside from TS ones for which we wouldn't want to render the default Sync 404 response?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, probably not. Just seemed like a pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep things simpler, I'd probably wait to add another macro/function until we have another instance of the pattern, but I'd be happy to add it now if you feel strongly about it!