@VisibleForTesting
    MemoryTrackingContext getQueryMemoryContext()
    {
        return queryMemoryContext;
    }
@Test(expectedExceptions = ExceededMemoryLimitException.class, expectedExceptionsMessageRegExp = ".*Query exceeded per-node total memory limit of 20B.*")
    public void testChecksTotalMemoryOnUserMemoryAllocation()
    {
        try (LocalQueryRunner localQueryRunner = new LocalQueryRunner(TEST_SESSION)) {
            QueryContext queryContext = new QueryContext(
                    new QueryId("query"),
                    new DataSize(10, BYTE), // user memory limit
                    new DataSize(20, BYTE), // total memory limit
                    new DataSize(10, BYTE),
                    new DataSize(1, GIGABYTE),
                    new MemoryPool(GENERAL_POOL, new DataSize(10, BYTE)),
                    new TestingGcMonitor(),
                    localQueryRunner.getExecutor(),
                    localQueryRunner.getScheduler(),
                    new DataSize(0, BYTE),
                    new SpillSpaceTracker(new DataSize(0, BYTE)),
                    listJsonCodec(TaskMemoryReservationSummary.class));

            queryContext.getQueryMemoryContext().initializeLocalMemoryContexts("test");
            LocalMemoryContext systemMemoryContext = queryContext.getQueryMemoryContext().localSystemMemoryContext();
            LocalMemoryContext userMemoryContext = queryContext.getQueryMemoryContext().localUserMemoryContext();
            systemMemoryContext.setBytes(15);
            userMemoryContext.setBytes(6);
        }
    }