Skip to content

tsclient impl #474

Closed
Closed

Description

@ashu3103

Task

Implement a new client tsclient, to handle postgres and pgmoneta operations while running tests in test environment.

Requirements

  • The infrastructure to perform pgmoneta operations like backup, restore, shutdown and delete are already in place - will keep it as is (port from cli.c)
  • add a new command - exec-query to tsclient that will take server name and a query as an argument. f.ex
    pgmoneta-tscli -c </path/to/pgmoneta.conf> exec-query <server> "<query to execute>"
    
    The <server> argument will tell the host and port to the client and the database will always be postgres and user will be
    superuser (the user that executes the client - since it is assumed that the tscli is specifically for running testsuites).

@jesperpedersen, Any suggestions?

Activity

  1. self-assigned this
    on Feb 14, 2025
  2. jesperpedersen commented on Mar 4, 2025

    @jesperpedersen
    Member

    No, there is no CLI tool in this.

    It is a test suite API that executes the commands, and look at the entire response - especially Outcome of course.\

    So, a test suite / case will create a tsclient, execute, get the response and then close it.

    The test suite should use the same configuration that pgmoneta was started with

  3. jesperpedersen commented on Mar 4, 2025

    @jesperpedersen
    Member

    It is mostly copy'n'paste from cli.c - you just need to fail if Outcome: Status: false happens

  4. ashu3103 commented on Mar 4, 2025

    @ashu3103
    CollaboratorAuthor

    Okay, but how will we manage the initial postgres setup (psql commands), because those commands will have to be executed before testsuite even started.

  5. jesperpedersen commented on Mar 4, 2025

    @jesperpedersen
    Member

    Yeah, we can do that in ci.yaml to start with.

    Then we can integrate a system() call in tsclient.c later

  6. ashu3103 commented on Mar 4, 2025

    @ashu3103
    CollaboratorAuthor

    Maybe look at https://github.com/PGBuildFarm/client-code for ideas

    Kool, I'll get back to you after referring this.

  7. ashu3103 commented on Mar 18, 2025

    @ashu3103
    CollaboratorAuthor

    @jesperpedersen, I was thinking upon it and there are some things that are still not very clear.

    No, there is no CLI tool in this.

    It is a test suite API that executes the commands, and look at the entire response - especially Outcome of course.\

    So, a test suite / case will create a tsclient, execute, get the response and then close it.

    as far as I understand from testsuite API, you mean that it is not a separate process (like main, cli, admin etc) but more like a library that we can import in our tests and execute (and its usecase is limited to test directory).

    The test suite should use the same configuration that pgmoneta was started with

    If we make it a library, how will it be able to get the configuration file paths of the pgmoneta by itself.

    Maybe I am missing something here.

  8. jesperpedersen commented on Mar 18, 2025

    @jesperpedersen
    Member

    Yes, it is just an API that make the calls to the server

  9. ashu3103 commented on Mar 18, 2025

    @ashu3103
    CollaboratorAuthor

    Yes, it is just an API that make the calls to the server

    Shall I assume default configurations file location in this API?
    like build/pgmoneta-testsuite/conf/pgmoneta.conf that we set for main process in the testsuite.sh script.

    So in each testcase -

    • Initialize the tesetsuite API by reading the default configuration files
    • Make call to the server to execute appropriate command (get server details from config)
    • Check Outcome if true testcase passed else testcase failed.
  10. jesperpedersen commented on Mar 18, 2025

    @jesperpedersen
    Member

    Yes.

    @Arnabdaz is working on the generator on #516

  11. ashu3103 commented on Mar 19, 2025

    @ashu3103
    CollaboratorAuthor

    Hi @jesperpedersen,

    I was thinking of initializing the tsclient in runner (not in each testcase) and connect to the main server in the initialisation itself (so that we don’t need a new connection for every testcase), so testcase will only execute APIs on the socket (from initialisation) rather than making a new connection every single time.

    Is there anything that could go wrong in this?

  12. jesperpedersen commented on Mar 19, 2025

    @jesperpedersen
    Member

    No, should be ok. And, you can do pgmoneta_socket_isvalid for each test case

  13. added 10 commits that reference this issue on Mar 21, 2025
  14. added a commit that references this issue on Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

feature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions