-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* first commit * get message tests 1 * store tests with node restarts * reliability tests * store tests * fixes * more tests * fixes * new store tests * new store tests * adjustments * adjust tests for go-waku * postgress test * postgress test * fixes * small fixes * reliability updates * postgress test * adjsutmens for go-waku
- Loading branch information
Showing
25 changed files
with
1,049 additions
and
80 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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
log/ | ||
.vscode | ||
allure-results/ | ||
postgresql | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
|
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,93 @@ | ||
class StoreResponse: | ||
def __init__(self, store_response, node): | ||
self.response = store_response | ||
self.node = node | ||
|
||
@property | ||
def request_id(self): | ||
try: | ||
if self.node.is_nwaku(): | ||
return self.response.get("requestId") | ||
else: | ||
return self.response.get("request_id") | ||
except: | ||
return None | ||
|
||
@property | ||
def status_code(self): | ||
try: | ||
if self.node.is_nwaku(): | ||
return self.response.get("statusCode") | ||
else: | ||
return self.response.get("status_code") | ||
except: | ||
return None | ||
|
||
@property | ||
def status_desc(self): | ||
try: | ||
if self.node.is_nwaku(): | ||
return self.response.get("statusDesc") | ||
else: | ||
return self.response.get("status_desc") | ||
except: | ||
return None | ||
|
||
@property | ||
def messages(self): | ||
try: | ||
return self.response.get("messages") | ||
except: | ||
return None | ||
|
||
@property | ||
def pagination_cursor(self): | ||
try: | ||
if self.node.is_nwaku(): | ||
return self.response.get("paginationCursor") | ||
else: | ||
return self.response.get("pagination_cursor") | ||
except: | ||
return None | ||
|
||
def message_hash(self, index): | ||
if self.messages is not None: | ||
if self.node.is_nwaku(): | ||
return self.messages[index]["messageHash"] | ||
else: | ||
return self.messages[index]["message_hash"] | ||
else: | ||
return None | ||
|
||
def message_payload(self, index): | ||
try: | ||
if self.messages is not None: | ||
payload = self.messages[index]["message"]["payload"] | ||
return payload | ||
else: | ||
return None | ||
except IndexError: | ||
return None | ||
|
||
def message_at(self, index): | ||
try: | ||
if self.messages is not None: | ||
message = self.messages[index]["message"] | ||
return message | ||
else: | ||
return None | ||
except IndexError: | ||
return None | ||
|
||
def message_pubsub_topic(self, index): | ||
if self.messages is not None: | ||
if self.node.is_nwaku(): | ||
return self.messages[index]["pubsubTopic"] | ||
else: | ||
return self.messages[index]["pubsub_topic"] | ||
else: | ||
return None | ||
|
||
@property | ||
def resp_json(self): | ||
return self.response |
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,44 @@ | ||
import docker | ||
import os | ||
from src.env_vars import NETWORK_NAME, PG_PASS, PG_USER | ||
from src.libs.custom_logger import get_custom_logger | ||
|
||
logger = get_custom_logger(__name__) | ||
|
||
|
||
def start_postgres(): | ||
pg_env = {"POSTGRES_USER": PG_USER, "POSTGRES_PASSWORD": PG_PASS} | ||
|
||
base_path = os.path.abspath(".") | ||
volumes = {os.path.join(base_path, "postgresql"): {"bind": "/var/lib/postgresql/data", "mode": "Z"}} | ||
|
||
client = docker.from_env() | ||
|
||
postgres_container = client.containers.run( | ||
"postgres:15.4-alpine3.18", | ||
name="postgres", | ||
environment=pg_env, | ||
volumes=volumes, | ||
command="postgres", | ||
ports={"5432/tcp": ("127.0.0.1", 5432)}, | ||
restart_policy={"Name": "on-failure", "MaximumRetryCount": 5}, | ||
healthcheck={ | ||
"Test": ["CMD-SHELL", "pg_isready -U postgres -d postgres"], | ||
"Interval": 30000000000, # 30 seconds in nanoseconds | ||
"Timeout": 60000000000, # 60 seconds in nanoseconds | ||
"Retries": 5, | ||
"StartPeriod": 80000000000, # 80 seconds in nanoseconds | ||
}, | ||
detach=True, | ||
network_mode=NETWORK_NAME, | ||
) | ||
|
||
logger.debug("Postgres container started") | ||
|
||
return postgres_container | ||
|
||
|
||
def stop_postgres(postgres_container): | ||
postgres_container.stop() | ||
postgres_container.remove() | ||
logger.debug("Postgres container stopped and removed.") |
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
Oops, something went wrong.