Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

feat: fix asserts on client dis/connect and convert inc call to rust #1178

Merged
merged 1 commit into from
Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ install:
- pip install tox ${CODECOV:+codecov}
- if [ ${WITH_RUST:-true} != "false" ]; then curl https://sh.rustup.rs | sh -s -- -y || travis_terminate 1; fi
- export PATH=$PATH:$HOME/.cargo/bin
- export AWS_SHARED_CREDENTIALS_FILE=./automock/credentials.cfg
- export AWS_SHARED_CREDENTIALS_FILE=./automock/boto.cfg
Copy link
Member

@pjenvey pjenvey Apr 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this and the boto.cfg change still necessary? (boto.cfg should probably be killed at this point if anything)

Copy link
Member Author

@bbangert bbangert Apr 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, because rusoto wants to find itself some aws access/secret keys, and if it can't find them in a file it expects, it starts issuing HTTP calls looking for IAM keys and such which messes things up. This is also why I added random access/secret keys to the boto.cfg. (There is no credentials.cfg)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but credentials.cfg has them

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- export BOTO_CONFIG=./automock/boto.cfg
script:
- tox -- ${CODECOV:+--with-coverage --cover-xml --cover-package=autopush}
Expand Down
2 changes: 2 additions & 0 deletions automock/boto.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[default]
aws_access_key_id=ASDFASDFASDFASDFASDFSD
aws_secret_access_key=ASDFASDFASDFASDFASDFASDFASDFASDFASDFASDFASDF
endpoint_url = http://localhost:8000

[Boto]
Expand Down
35 changes: 0 additions & 35 deletions autopush/tests/test_webpush_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
DropUser,
Hello,
HelloResponse,
IncStoragePosition,
MigrateUser,
Register,
StoreMessages,
Expand Down Expand Up @@ -339,40 +338,6 @@ def test_many_messages(self):
assert len(result.messages) == 5


class TestIncrementStorageProcessor(BaseSetup):
def _makeFUT(self):
from autopush.webpush_server import IncrementStorageCommand
return IncrementStorageCommand(self.conf, self.db)

def test_inc_storage(self):
from autopush.webpush_server import CheckStorageCommand
inc_command = self._makeFUT()
check_command = CheckStorageCommand(self.conf, self.db)
check = CheckStorageFactory(message_month=self.db.current_msg_month)
uaid = check.uaid

# First store/register some messages
self._store_messages(check.uaid, num=15)

# Pull 10 out
check_result = check_command.process(check)
assert len(check_result.messages) == 10

# We should now have an updated timestamp returned, increment it
inc = IncStoragePosition(uaid=uaid.hex,
message_month=self.db.current_msg_month,
timestamp=check_result.timestamp)
inc_command.process(inc)

# Create a new check command, and verify we resume from 10 in
check = CheckStorageFactory(
uaid=uaid.hex,
message_month=self.db.current_msg_month
)
check_result = check_command.process(check)
assert len(check_result.messages) == 5


class TestDeleteMessageProcessor(BaseSetup):
def _makeFUT(self):
from autopush.webpush_server import DeleteMessageCommand
Expand Down
24 changes: 0 additions & 24 deletions autopush/webpush_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,6 @@ class CheckStorage(InputCommand):
timestamp = attrib(default=None) # type: Optional[int]


@attrs(slots=True)
class IncStoragePosition(InputCommand):
uaid = attrib(convert=uaid_from_str) # type: UUID
message_month = attrib() # type: str
timestamp = attrib() # type: int


@attrs(slots=True)
class DeleteMessage(InputCommand):
message_month = attrib() # type: str
Expand Down Expand Up @@ -202,11 +195,6 @@ class CheckStorageResponse(OutputCommand):
timestamp = attrib(default=None) # type: Optional[int]


@attrs(slots=True)
class IncStoragePositionResponse(OutputCommand):
success = attrib(default=True) # type: bool


@attrs(slots=True)
class DeleteMessageResponse(OutputCommand):
success = attrib(default=True) # type: bool
Expand Down Expand Up @@ -296,7 +284,6 @@ def __init__(self, conf, db):
self.db = db
self.hello_processor = HelloCommand(conf, db)
self.check_storage_processor = CheckStorageCommand(conf, db)
self.inc_storage_processor = IncrementStorageCommand(conf, db)
self.delete_message_processor = DeleteMessageCommand(conf, db)
self.drop_user_processor = DropUserCommand(conf, db)
self.migrate_user_proocessor = MigrateUserCommand(conf, db)
Expand All @@ -306,7 +293,6 @@ def __init__(self, conf, db):
self.deserialize = dict(
hello=Hello,
check_storage=CheckStorage,
inc_storage_position=IncStoragePosition,
delete_message=DeleteMessage,
drop_user=DropUser,
migrate_user=MigrateUser,
Expand All @@ -317,7 +303,6 @@ def __init__(self, conf, db):
self.command_dict = dict(
hello=self.hello_processor,
check_storage=self.check_storage_processor,
inc_storage_position=self.inc_storage_processor,
delete_message=self.delete_message_processor,
drop_user=self.drop_user_processor,
migrate_user=self.migrate_user_proocessor,
Expand Down Expand Up @@ -513,15 +498,6 @@ def _check_storage(self, command):
return timestamp, messages, False


class IncrementStorageCommand(ProcessorCommand):
def process(self, command):
# type: (IncStoragePosition) -> IncStoragePositionResponse
message = Message(command.message_month,
boto_resource=self.db.resource)
message.update_last_message_read(command.uaid, command.timestamp)
return IncStoragePositionResponse()


class DeleteMessageCommand(ProcessorCommand):
def process(self, command):
# type: (DeleteMessage) -> DeleteMessageResponse
Expand Down
Loading