Skip to content

Commit

Permalink
neon_local: improved docs and fix wrong connstr (#6954)
Browse files Browse the repository at this point in the history
The user created with the `--create-test-user` flag is `test` instead of
`user`.

ref #6848

Signed-off-by: Alex Chi Z <chi@neon.tech>
  • Loading branch information
skyzh authored Mar 1, 2024
1 parent e34059c commit ea0d35f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ postgres=# select * from t;
> cargo neon stop
```

More advanced usages can be found at [Control Plane and Neon Local](./control_plane/README.md).

#### Handling build failures

If you encounter errors during setting up the initial tenant, it's best to stop everything (`cargo neon stop`) and remove the `.neon` directory. Then fix the problems, and start the setup again.
Expand Down
26 changes: 26 additions & 0 deletions control_plane/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Control Plane and Neon Local

This crate contains tools to start a Neon development environment locally. This utility can be used with the `cargo neon` command.

## Example: Start with Postgres 16

To create and start a local development environment with Postgres 16, you will need to provide `--pg-version` flag to 3 of the start-up commands.

```shell
cargo neon init --pg-version 16
cargo neon start
cargo neon tenant create --set-default --pg-version 16
cargo neon endpoint create main --pg-version 16
cargo neon endpoint start main
```

## Example: Create Test User and Database

By default, `cargo neon` starts an endpoint with `cloud_admin` and `postgres` database. If you want to have a role and a database similar to what we have on the cloud service, you can do it with the following commands when starting an endpoint.

```shell
cargo neon endpoint create main --pg-version 16 --update-catalog true
cargo neon endpoint start main --create-test-user true
```

The first command creates `neon_superuser` and necessary roles. The second command creates `test` user and `neondb` database. You will see a connection string that connects you to the test user after running the second command.
2 changes: 1 addition & 1 deletion control_plane/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ impl Endpoint {
let conn_str = self.connstr("cloud_admin", "postgres");
println!("Starting postgres node at '{}'", conn_str);
if create_test_user {
let conn_str = self.connstr("user", "neondb");
let conn_str = self.connstr("test", "neondb");
println!("Also at '{}'", conn_str);
}
let mut cmd = Command::new(self.env.neon_distrib_dir.join("compute_ctl"));
Expand Down

1 comment on commit ea0d35f

@github-actions
Copy link

Choose a reason for hiding this comment

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

2549 tests run: 2416 passed, 0 failed, 133 skipped (full report)


Flaky tests (5)

Postgres 16

  • test_crafted_wal_end[last_wal_record_crossing_segment]: debug
  • test_vm_bit_clear_on_heap_lock: debug

Postgres 15

  • test_delete_timeline_client_hangup: debug

Postgres 14

  • test_ts_of_lsn_api: debug
  • test_neon_superuser: debug

Code coverage* (full report)

  • functions: 28.8% (6932 of 24085 functions)
  • lines: 47.4% (42555 of 89855 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
ea0d35f at 2024-03-01T20:47:14.378Z :recycle:

Please sign in to comment.