@Test
  public void testExecutionOnAllNodes_NoLastResult() throws Exception {
    VM datastore0 = getHost(0).getVM(0);
    VM datastore1 = getHost(0).getVM(1);
    VM datastore2 = getHost(0).getVM(2);
    VM datastore3 = getHost(0).getVM(3);

    datastore0.invoke(() -> {
      createPartitionedRegion(regionName, 10, 0, 17);
      FunctionService.registerFunction(new TestFunction(true, TEST_FUNCTION_NO_LASTRESULT));
    });

    datastore1.invoke(() -> {
      createPartitionedRegion(regionName, 10, 0, 17);
      FunctionService.registerFunction(new TestFunction(true, TEST_FUNCTION_NO_LASTRESULT));
    });

    datastore2.invoke(() -> {
      createPartitionedRegion(regionName, 10, 0, 17);
      FunctionService.registerFunction(new TestFunction(true, TEST_FUNCTION_NO_LASTRESULT));
    });

    datastore3.invoke(() -> {
      createPartitionedRegion(regionName, 10, 0, 17);
      FunctionService.registerFunction(new TestFunction(true, TEST_FUNCTION_NO_LASTRESULT));
    });

    datastore3.invoke(() -> {
      PartitionedRegion pr = getPartitionedRegion(regionName);

      Collection<String> stringKeys = new HashSet<>();
      for (int i = pr.getTotalNumberOfBuckets() * 3; i > 0; i--) {
        stringKeys.add(STRING_KEY + i);
      }

      int valueIndex = 0;
      for (String key : stringKeys) {
        int value = valueIndex++;
        pr.put(key, value);
      }

      // Assert there is data in each bucket
      for (int bucketId = 0; bucketId < pr.getTotalNumberOfBuckets(); bucketId++) {
        assertThat(pr.getBucketKeys(bucketId).size()).isGreaterThan(0);
      }

      Function<Boolean> function = new TestFunction<>(true, TEST_FUNCTION_NO_LASTRESULT);
      FunctionService.registerFunction(function);
      Execution<Boolean, Boolean, List<Boolean>> execution = FunctionService.onRegion(pr);

      ResultCollector resultCollector = execution.setArguments(true).execute(function.getId());

      assertThatThrownBy(resultCollector::getResult).isInstanceOf(FunctionException.class)
          .hasMessageContaining("did not send last result");
    });
  }
Test execution on all datastores with function that doesn't send last result. FunctionException
is expected in this case
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/PRFunctionExecutionWithResultSenderDUnitTest.java