static void test__createReaderGang(void **state) { int segmentCount = TOTOAL_SEGMENTS; int ftsVersion = 1; PGconn *conn = &pgconn; const char *portalName = "portal1"; int motionListener = 10000; int qePid = 2000; int i = 0; will_return(IsTransactionOrTransactionBlock, true); will_return_count(getgpsegmentCount, segmentCount, -1); will_return_count(getFtsVersion, ftsVersion, 1); expect_any_count(isSockAlive, sock, -1); will_return_count(isSockAlive, true, -1); mockLibpq(conn, motionListener, qePid); cdbgang_setAsync(false); Gang * gang = AllocateReaderGang(GANGTYPE_PRIMARY_READER, portalName); /* validate gang */ assert_int_equal(gang->size, TOTOAL_SEGMENTS); assert_int_equal(gang->gang_id, 2); assert_string_equal(gang->portal_name, portalName); assert_int_equal(gang->type, GANGTYPE_PRIMARY_READER); assert_int_equal(gang->noReuse, false); assert_int_equal(gang->dispatcherActive, false); assert_int_equal(gang->allocated, true); for (i = 0; i < gang->size; i++) { SegmentDatabaseDescriptor *segdb = &gang->db_descriptors[i]; CdbComponentDatabaseInfo *cdbinfo = segdb->segment_database_info; assert_int_equal(segdb->backendPid, qePid); assert_int_equal(segdb->conn, conn); assert_int_equal(segdb->errcode, 0); assert_int_equal(segdb->error_message.len, 0); assert_int_equal(segdb->motionListener, motionListener); assert_int_equal(segdb->myAgent, NULL); assert_int_equal(segdb->segindex, i); validateCdbInfo(segdb->segment_database_info, segdb->segindex); } }
/* * Assign hook routine for "gp_connections_per_thread" option. This variable has context * PGC_SUSET so that is can only be set by a superuser via the SET command. * (It can also be set in config file, but not inside of PGOPTIONS.) * * See src/backend/util/misc/guc.c for option definition. */ bool assign_gp_connections_per_thread(int newval, bool doit, GucSource source __attribute__((unused))) { #if FALSE elog(DEBUG1, "assign_gp_connections_per_thread: gp_connections_per_thread=%s, newval=%d, doit=%s", show_gp_connections_per_thread(), newval, (doit ? "true" : "false")); #endif if (doit) { if (newval < 0) return false; cdbdisp_setAsync(newval == 0); cdbgang_setAsync(newval == 0); gp_connections_per_thread = newval; } return true; }