def METHOD_NAME(inventory):
    instances = [
        {
            "name": "instance1",
            "countryCode": "SE",
            "workloadSlug": "wokrload1",
            "continent": "Europe",
            "workloadId": "id1",
            "cityCode": "ARN",
            "externalIpAddress": "20.0.0.1",
            "target": "target1",
            "stackSlug": "stack1",
            "ipAddress": "10.0.0.1",
        },
        {
            "name": "instance2",
            "countryCode": "US",
            "workloadSlug": "wokrload2",
            "continent": "America",
            "workloadId": "id2",
            "cityCode": "JFK",
            "externalIpAddress": "20.0.0.2",
            "target": "target2",
            "stackSlug": "stack1",
            "ipAddress": "10.0.0.2",
        },
        {
            "name": "instance3",
            "countryCode": "SE",
            "workloadSlug": "workload3",
            "continent": "Europe",
            "workloadId": "id3",
            "cityCode": "ARN",
            "externalIpAddress": "20.0.0.3",
            "target": "target1",
            "stackSlug": "stack2",
            "ipAddress": "10.0.0.3",
        },
        {
            "name": "instance4",
            "countryCode": "US",
            "workloadSlug": "workload3",
            "continent": "America",
            "workloadId": "id4",
            "cityCode": "JFK",
            "externalIpAddress": "20.0.0.4",
            "target": "target2",
            "stackSlug": "stack2",
            "ipAddress": "10.0.0.4",
        },
    ]
    inventory.hostname_key = "externalIpAddress"
    inventory._populate(instances)
    # get different hosts
    host1 = inventory.inventory.get_host('20.0.0.1')
    host2 = inventory.inventory.get_host('20.0.0.2')
    host3 = inventory.inventory.get_host('20.0.0.3')
    host4 = inventory.inventory.get_host('20.0.0.4')
    # get different groups
    assert 'citycode_arn' in inventory.inventory.groups
    group_citycode_arn = inventory.inventory.groups['citycode_arn']
    assert 'countrycode_se' in inventory.inventory.groups
    group_countrycode_se = inventory.inventory.groups['countrycode_se']
    assert 'continent_america' in inventory.inventory.groups
    group_continent_america = inventory.inventory.groups['continent_america']
    assert 'name_instance1' in inventory.inventory.groups
    group_name_instance1 = inventory.inventory.groups['name_instance1']
    assert 'stackslug_stack1' in inventory.inventory.groups
    group_stackslug_stack1 = inventory.inventory.groups['stackslug_stack1']
    assert 'target_target1' in inventory.inventory.groups
    group_target_target1 = inventory.inventory.groups['target_target1']
    assert 'workloadslug_workload3' in inventory.inventory.groups
    group_workloadslug_workload3 = inventory.inventory.groups['workloadslug_workload3']
    assert 'workloadid_id1' in inventory.inventory.groups
    group_workloadid_id1 = inventory.inventory.groups['workloadid_id1']
    assert group_citycode_arn.hosts == [host1, host3]
    assert group_countrycode_se.hosts == [host1, host3]
    assert group_continent_america.hosts == [host2, host4]
    assert group_name_instance1.hosts == [host1]
    assert group_stackslug_stack1.hosts == [host1, host2]
    assert group_target_target1.hosts == [host1, host3]
    assert group_workloadslug_workload3.hosts == [host3, host4]
    assert group_workloadid_id1.hosts == [host1]