mirror of
https://github.com/neondatabase/neon.git
synced 2026-10-26 13:36:45 +00:00
use pg_resetwal to generate pg_control in the test
This commit is contained in:
@@ -247,6 +247,9 @@ impl ComputeControlPlane {
|
||||
node
|
||||
}
|
||||
|
||||
// Init compute node without files, only datadir structure
|
||||
// use initdb --compute-node flag and GUC 'computenode_mode'
|
||||
// to distinguish the node
|
||||
pub fn new_minimal_node(&mut self) -> &PostgresNode {
|
||||
// allocate new node entry with generated port
|
||||
let node_id = self.nodes.len() + 1;
|
||||
@@ -386,7 +389,8 @@ impl PostgresNode {
|
||||
self.pgdata.to_str()
|
||||
}
|
||||
|
||||
pub fn create_controlfile(&self)
|
||||
/* Create stub controlfile and respective xlog to start computenode */
|
||||
pub fn setup_controlfile(&self)
|
||||
{
|
||||
let filepath = format!("{}/global/pg_control", self.pgdata.to_str().unwrap());
|
||||
|
||||
@@ -396,15 +400,16 @@ impl PostgresNode {
|
||||
|
||||
let pg_resetwal_path = self.pg_bin_dir.join("pg_resetwal");
|
||||
|
||||
let initdb = Command::new(pg_resetwal_path)
|
||||
let pg_resetwal = Command::new(pg_resetwal_path)
|
||||
.args(&["-D", self.pgdata.to_str().unwrap()])
|
||||
.arg("-f")
|
||||
// TODO probably we will have to modify pg_resetwal
|
||||
// .arg("--compute-node")
|
||||
.status()
|
||||
.expect("failed to execute pg_resetwal");
|
||||
|
||||
if !initdb.success() {
|
||||
panic!("initdb failed");
|
||||
if !pg_resetwal.success() {
|
||||
panic!("pg_resetwal failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ use pageserver::control_plane::StorageControlPlane;
|
||||
fn test_redo_cases() {
|
||||
// Allocate postgres instance, but don't start
|
||||
let mut compute_cplane = ComputeControlPlane::local();
|
||||
// Create compute node without files, only datadir structure
|
||||
let node = compute_cplane.new_minimal_node();
|
||||
|
||||
// Start pageserver that reads WAL directly from that postgres
|
||||
@@ -24,9 +25,10 @@ fn test_redo_cases() {
|
||||
page_server_connstring = 'host={} port={}'\n\
|
||||
", pageserver_addr.ip(), pageserver_addr.port()).as_str());
|
||||
|
||||
// Request info needed to build control file
|
||||
storage_cplane.simple_query_storage("postgres", node.whoami().as_str(), "controlfile");
|
||||
|
||||
node.create_controlfile();
|
||||
// Setup controlfile
|
||||
node.setup_controlfile();
|
||||
|
||||
// start postgres
|
||||
node.start();
|
||||
|
||||
Reference in New Issue
Block a user