@Test
    public void test_autoscaling_single_content_group_with_some_local_traffic() {
        var fixture = DynamicProvisioningTester.fixture().awsProdSetup(true).build();

        // Baseline: No local traffic, group traffic indicates much higher cpu usage than local
        fixture.tester().clock().advance(Duration.ofDays(2));
        fixture.store(new BcpGroupInfo(200, 1.3, 0.45));
        fixture.loader().addCpuMeasurements(0.7f, 10);
        fixture.tester().assertResources("Scaling up cpu using bcp group cpu info",
                                         8, 1, 12.6, 7.2, 28.8,
                                         fixture.autoscale());

        // Some local traffic
        fixture.tester().clock().advance(Duration.ofDays(2));
        fixture.store(new BcpGroupInfo(200, 1.3, 0.45));
        Duration duration1 = fixture.loader().addCpuMeasurements(0.7f, 10);
        fixture.tester().clock().advance(duration1.negated());
        fixture.loader().addQueryRateMeasurements(10, __ -> 10.0);
        fixture.tester().assertResources("Scaling up cpu using bcp group cpu info",
                                         8, 1, 7.3, 7.2, 28.8,
                                         fixture.autoscale());

        // Enough local traffic to get half the votes
        fixture.tester().clock().advance(Duration.ofDays(2));
        fixture.store(new BcpGroupInfo(200, 1.3, 0.45));
        Duration duration2 = fixture.loader().addCpuMeasurements(0.7f, 10);
        fixture.tester().clock().advance(duration2.negated());
        fixture.loader().addQueryRateMeasurements(10, __ -> 50.0);
        fixture.tester().assertResources("Scaling up cpu using bcp group cpu info",
                                         8, 1, 3.2, 7.2, 28.8,
                                         fixture.autoscale());

        // Mostly local
        fixture.tester().clock().advance(Duration.ofDays(2));
        fixture.store(new BcpGroupInfo(200, 1.3, 0.45));
        Duration duration3 = fixture.loader().addCpuMeasurements(0.7f, 10);
        fixture.tester().clock().advance(duration3.negated());
        fixture.loader().addQueryRateMeasurements(10, __ -> 90.0);
        fixture.tester().assertResources("Scaling up cpu using bcp group cpu info",
                                         8, 1, 2.3, 7.2, 28.8,
                                         fixture.autoscale());

        // Local only
        fixture.tester().clock().advance(Duration.ofDays(2));
        fixture.store(new BcpGroupInfo(200, 1.3, 0.45));
        Duration duration4 = fixture.loader().addCpuMeasurements(0.7f, 10);
        fixture.tester().clock().advance(duration4.negated());
        fixture.loader().addQueryRateMeasurements(10, __ -> 100.0);
        fixture.tester().assertResources("Scaling up cpu using bcp group cpu info",
                                         8, 1, 2.2, 7.2, 28.8,
                                         fixture.autoscale());

        // No group info, should be the same as the above
        fixture.tester().clock().advance(Duration.ofDays(2));
        fixture.store(BcpGroupInfo.empty());
        Duration duration5 = fixture.loader().addCpuMeasurements(0.7f, 10);
        fixture.tester().clock().advance(duration5.negated());
        fixture.loader().addQueryRateMeasurements(10, __ -> 100.0);
        fixture.tester().assertResources("Scaling up cpu using bcp group cpu info",
                                         8, 1, 2.2, 7.2, 28.8,
                                         fixture.autoscale());

        // 40 query rate, no group info (for reference to the below)
        fixture.tester().clock().advance(Duration.ofDays(2));
        fixture.store(BcpGroupInfo.empty());
        Duration duration6 = fixture.loader().addCpuMeasurements(0.7f, 10);
        fixture.tester().clock().advance(duration6.negated());
        fixture.loader().addQueryRateMeasurements(10, __ -> 40.0);
        fixture.tester().assertResources("Scaling up cpu using bcp group cpu info",
                                         8, 1, 1.6, 7.2, 28.8,
                                         fixture.autoscale());

        // Local query rate is too low but global is even lower so disregard it, giving the same as above
        fixture.tester().clock().advance(Duration.ofDays(2));
        fixture.store(new BcpGroupInfo(200 / 40.0, 1.3, 0.45 * 40.0));
        Duration duration7 = fixture.loader().addCpuMeasurements(0.7f, 10);
        fixture.tester().clock().advance(duration7.negated());
        fixture.loader().addQueryRateMeasurements(10, __ -> 40.0);
        fixture.tester().assertResources("Scaling up cpu using bcp group cpu info",
                                         8, 1, 1.6, 7.2, 28.8,
                                         fixture.autoscale());

        // Local query rate is too low to be fully confident, and so is global but as it is slightly larger, incorporate it slightly
        fixture.tester().clock().advance(Duration.ofDays(2));
        fixture.store(new BcpGroupInfo(200 / 4.0, 1.3, 0.45 * 4.0));
        Duration duration8 = fixture.loader().addCpuMeasurements(0.7f, 10);
        fixture.tester().clock().advance(duration8.negated());
        fixture.loader().addQueryRateMeasurements(10, __ -> 40.0);
        fixture.tester().assertResources("Scaling up cpu using bcp group cpu info",
                                         8, 1, 1.9, 7.2, 28.8,
                                         fixture.autoscale());
    }
Tests with varying BCP group info parameters for containers.
Differences from content
- No host sharing.
- Memory and disk is independent of cluster size.
node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingUsingBcpGroupInfoTest.java