Skip to content
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

[#136] Data Mapped by dbms-peer was not loaded into the database connected to das-peer #137

Merged
merged 3 commits into from
Nov 22, 2024
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
4 changes: 1 addition & 3 deletions src/commands/config/config_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ class ConfigSet(Command):
das_peer.container_name
Specifies the Docker container name for the DAS peer, which acts as the main server. This name is essential for managing and communicating with the DAS peer container.

das_peer.port
Defines the port on which the DAS peer server listens for incoming connections from clients.

dbms_peer.*
These variables configure settings for the DBMS Peer, such as:

Expand Down Expand Up @@ -300,6 +297,7 @@ def _das_peer(self) -> dict:

return {
"das_peer.container_name": f"das-cli-das-peer-{database_adapter_server_port}",
"das_peer.port": database_adapter_server_port,
}

def _dbms_peer(self) -> dict:
Expand Down
10 changes: 3 additions & 7 deletions src/commands/dbms_adapter/das_peer/das_peer_container_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ def __init__(
def start_container(self):
self.raise_running_container()

container = self.get_container()

command_params = [
"--server-id",
f"localhost:{self._container.port}",
f"localhost:{container.port}",
"--mongo-hostname",
self._options.get("mongodb_hostname"),
"--mongo-port",
Expand All @@ -54,12 +56,6 @@ def start_container(self):
"pgrep -f 'python /app/scripts/python/das_node_server.py' || exit 1",
],
},
extra_hosts={
"host.docker.internal": "172.17.0.1", # docker interface
},
# ports={
# "30100/tcp": self._container.port,
# },
)

return container
8 changes: 7 additions & 1 deletion src/commands/dbms_adapter/dbms_adapter_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,11 @@ def _dbms_peer_container_manager_factory(
self,
) -> DbmsPeerContainerManager:
container_name = self._settings.get("dbms_peer.container_name")
adapter_server_port = 30100

return DbmsPeerContainerManager(container_name)
return DbmsPeerContainerManager(
container_name,
options={
"das_peer_port": adapter_server_port,
},
)
27 changes: 15 additions & 12 deletions src/commands/dbms_adapter/dbms_peer/dbms_peer_container_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,17 @@ def start_container(
self.raise_running_container()

secrets = self._get_secrets_file(username, password)
das_peer_port = self._options.get("das_peer_port")

with self._store_secrets_file_temporarily(secrets) as file:
secrets_target_path = "/tmp/secrets.ini"
context_target_path = f"/tmp/{os.path.basename(context)}"

command_params = [
"--node-id",
"localhost:30200",
f"localhost:30200",
"--server-id",
"host.docker.internal:30100",
f"localhost:{das_peer_port}",
"--postgres-hostname",
hostname,
"--postgres-port",
Expand All @@ -84,19 +85,21 @@ def start_container(
context_target_path,
]

volumes = {
file.name: {
"bind": secrets_target_path,
"mode": "ro",
},
context: {
"bind": context_target_path,
"mode": "ro",
},
}

container = self._start_container(
command=command_params,
network_mode="host",
volumes={
file.name: {
"bind": secrets_target_path,
"mode": "ro",
},
context: {
"bind": context_target_path,
"mode": "ro",
},
},
volumes=volumes,
)

self.logs()
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/test_dbms_peer.bats
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ teardown() {
}

@test "Should run DBMS Peer successfuly" {
run das-cli db count-atoms

[[ "$output" -eq 0 ]]

"$(dirname "${BATS_TEST_DIRNAME}")/../scripts/start_postgres.sh" \
-n $postgres_container_name \
-p $postgres_password \
Expand Down Expand Up @@ -95,4 +99,8 @@ teardown() {

assert_line --partial "The 'public.atoms' has been mapped"
assert_line --partial "Done."

run das-cli db count-atoms

[[ "$output" -gt 0 ]]
}