@VisibleForTesting
    static CPUResource getDefaultCpus(final Configuration configuration) {
        int fallback = configuration.get(YarnConfigOptions.VCORES);
        double cpuCoresDouble =
                TaskExecutorProcessUtils.getCpuCoresWithFallback(configuration, fallback)
                        .getValue()
                        .doubleValue();
        @SuppressWarnings("NumericCastThatLosesPrecision")
        long cpuCoresLong = Math.max((long) Math.ceil(cpuCoresDouble), 1L);
        //noinspection FloatingPointEquality
        if (cpuCoresLong != cpuCoresDouble) {
            LOG.info(
                    "The amount of cpu cores must be a positive integer on Yarn. Rounding {} up to the closest positive integer {}.",
                    cpuCoresDouble,
                    cpuCoresLong);
        }
        if (cpuCoresLong > Integer.MAX_VALUE) {
            throw new IllegalConfigurationException(
                    String.format(
                            "The amount of cpu cores %d cannot exceed Integer.MAX_VALUE: %d",
                            cpuCoresLong, Integer.MAX_VALUE));
        }
        //noinspection NumericCastThatLosesPrecision
        return new CPUResource(cpuCoresLong);
    }
@Test
    void testGetCpuRoundUp() {
        final Configuration configuration = new Configuration();
        configuration.set(TaskManagerOptions.CPU_CORES, 0.5);

        assertThat(YarnWorkerResourceSpecFactory.getDefaultCpus(configuration))
                .isEqualTo(new CPUResource(1.0));
    }