<commit_before>// _repl.js
/* 
framework for replication testing
takes 1 paramter, the function to test.
that function takes 2 paramters, first is master db, second is slave db
*/

dbDir = "../p/db/";
masterPort = 5001;
slavePort = 5002;

try {
    // start master
    sysexec( "rm -rf /tmp/db-master" );
    sysexec( "mkdir /tmp/db-master/" );
    sysexec( "touch /tmp/db-master/a" );
    
    master = fork( 
	function(){
	    print( "MASTER starting" );
	    sysexec( dbDir + "db --master --port " + masterPort + " --dbpath /tmp/db-master/" , null , null , null ,
		     { out : function( s ){ print( "MASTER out: " + s ) } ,
		       err : function( s ){ print( "MASTER err: " + s ) }
		 }
		   );
	}
    );
    
    master.start();
    
    
    
    // start slave
    sysexec( "rm -rf /tmp/db-slave" );
    sysexec( "mkdir /tmp/db-slave/" );
    sysexec( "touch /tmp/db-slave/a" );
    slave = fork(
	function(){
	    print( "SLAVE starting" );
	    sysexec( dbDir + "db --slave --port " + slavePort + " --dbpath /tmp/db-slave/" , null , null , null ,
		     { out : function( s ){ print( "SLAVE out: " + s ) } ,
		       err : function( s ){ print( "SLAVE err: " + s ) }
		     }
		   );
	}
    );
    slave.start();

    sleep( 10000 );    
    
    print( "ADDING source" );
    connect( "127.0.0.1:" + slavePort + "/local" ).sources.save( { host : "127.0.0.1:" + masterPort , source:"main"} );
    
    sleep( 2000 );


    // --------
    
    // START REAL TEST
    arguments[0]( 
	connect( "127.0.0.1:" + masterPort + "/test" ) ,
	connect( "127.0.0.1:" + slavePort + "/test" ) 
    );
}
finally {
    // SHUTDOWN
    print( "SHUTTING DOWN" );
    sysexec( dbDir + "db msg end " + slavePort );
    slave.join();    
    
    sysexec( dbDir + "db msg end " + masterPort );
    master.join();
}

<commit_msg>_repl.js : minor tweaks in output - also pass pertintent info to test related to setup params<commit_after>// _repl.js
/* 
framework for replication testing
takes 1 paramter, the function to test.
that function takes 2 paramters, first is master db, second is slave db
*/

dbDir = "../p/db/";
masterPort = 5001;
slavePort = 5002;

try {
    // start master
    sysexec( "rm -rf /tmp/db-master" );
    sysexec( "mkdir /tmp/db-master/" );
    sysexec( "touch /tmp/db-master/a" );
    
    master = fork( 
	function(){
	    print( "MASTER starting" );
	    sysexec( dbDir + "db --master --port " + masterPort + " --dbpath /tmp/db-master/" , null , null , null ,
		     { out : function( s ){ print( "MASTER out: " + s ) } ,
		       err : function( s ){ print( "MASTER err: " + s ) }
		 }
		   );
	}
    );
    
    master.start();
    
    
    
    // start slave
    sysexec( "rm -rf /tmp/db-slave" );
    sysexec( "mkdir /tmp/db-slave/" );
    sysexec( "touch /tmp/db-slave/a" );
    slave = fork(
	function(){
	    print( "SLAVE starting" );
	    sysexec( dbDir + "db --slave --port " + slavePort + " --dbpath /tmp/db-slave/" , null , null , null ,
		     { out : function( s ){ print( "SLAVE out: " + s ) } ,
		       err : function( s ){ print( "SLAVE err: " + s ) }
		     }
		   );
	}
    );
    slave.start();

    sleep( 10000 );    
    
    print( "ADDING source" );
    connect( "127.0.0.1:" + slavePort + "/local" ).sources.save( { host : "127.0.0.1:" + masterPort , source:"main"} );
    
    sleep( 2000 );


    // --------
    
    // START REAL TEST
    
    print(" #####  SETUP COMPLETE : STARTING TEST  #####");

    arguments[0]( 
	connect( "127.0.0.1:" + masterPort + "/test" ) ,
	connect( "127.0.0.1:" + slavePort + "/test" ), 
	{ masterPort : masterPort,
	  slavePort : slavePort }
    );
    
    print(" #####  TEST COMPLETE : STARTING TEARDOWN  #####");
    
}
finally {
    // SHUTDOWN
    print( "SHUTTING DOWN" );
    sysexec( dbDir + "db msg end " + slavePort );
    slave.join();    
    
    sysexec( dbDir + "db msg end " + masterPort );
    master.join();
}


{'fraction_non_alphanumeric': 0.18272425249169436, 'fraction_numerical': 0.022489138768208537, 'mean_word_length': 1.9719058466211086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3923895', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1401, 'n_words': 364}