jstests/libs/override_methods/inject_tenant_prefix.js
/**
 * If the database with the given name can be migrated, prepend a tenant prefix if one has not
 * already been applied.
 */
If the database with the given name can be migrated, prepend a tenant prefix if one has not
already been applied.
If the database with the given name can be migrated prepend a tenant prefix if one has not already been applied .
function prependTenantIdToDbNameIfApplicable(dbName) {
    if (dbName.length === 0) {
        return dbName;
    }
    let prefix;
    if (isShardSplitPassthrough()) {
        if (!kTenantPrefixMap[dbName]) {
            const tenantId =
                TestData.tenantIds[Math.floor(Math.random() * TestData.tenantIds.length)];
            kTenantPrefixMap[dbName] = `${tenantId}_`;
        }
        prefix = kTenantPrefixMap[dbName];
    } else {
        prefix = `${TestData.tenantId}_`;
    }
    return (isDenylistedDb(dbName) || dbName.startsWith(prefix)) ? dbName : `${prefix}${dbName}`;
}
function prependTenantIdToDbNameIfApplicable ( dbName ) { if ( dbName . length === 0 ) { return dbName ; } let prefix ; if ( isShardSplitPassthrough ( ) ) { if ( ! kTenantPrefixMap [ dbName ] ) { const tenantId = TestData . tenantIds [ Math . floor ( Math . random ( ) * TestData . tenantIds . length ) ] ; kTenantPrefixMap [ dbName ] = ` ${ tenantId } ` ; } prefix = kTenantPrefixMap [ dbName ] ; } else { prefix = ` ${ TestData . tenantId } ` ; } return ( isDenylistedDb ( dbName ) || dbName . startsWith ( prefix ) ) ? dbName : ` ${ prefix } ${ dbName } ` ; }
If the database with the given name can be migrated, prepend a tenant prefix if one has not
 already been applied.
If the database with the given name can be migrated prepend a tenant prefix if one has not already been applied .
// There are input validation tests that use invalid database names, those should be // ignored. // If running shard split passthroughs, then assign a database to a randomly selected tenant