use pg_resetwal to generate pg_control in the test

This commit is contained in:
anastasia
2021-04-02 15:09:20 +03:00
parent 9fdf1964a7
commit dc4b5f5f23
2 changed files with 13 additions and 6 deletions
+9 -4
View File
@@ -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");
}
}
+4 -2
View File
@@ -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();