Example #1
0
def test_map_empty_pod():
    pod = Pod(None, {"metadata": {}, "spec": {"containers": []}, "status": {}})
    assert map_pod(pod, 0, 0) == {
        "application": "",
        "component": "",
        "container_images": [],
        "team": "",
        "requests": {
            "cpu": 0,
            "memory": 0
        },
        "usage": {
            "cpu": 0,
            "memory": 0
        },
        "cost": 0,
    }
Example #2
0
def test_map_pod_with_resources():
    pod = Pod(
        None,
        {
            "metadata": {
                "labels": {
                    "app": "myapp",
                    "component": "mycomp",
                    "team": "myteam"
                }
            },
            "spec": {
                "containers": [{
                    "name": "main",
                    "image": "hjacobs/kube-downscaler:latest",
                    "resources": {
                        "requests": {
                            "cpu": "5m",
                            "memory": "200Mi"
                        }
                    },
                }]
            },
            "status": {},
        },
    )
    assert map_pod(pod, 0, 0) == {
        "application": "myapp",
        "component": "mycomp",
        "team": "myteam",
        "container_names": ["main"],
        "container_images": ["hjacobs/kube-downscaler:latest"],
        "requests": {
            "cpu": 0.005,
            "memory": 200 * 1024 * 1024
        },
        "usage": {
            "cpu": 0,
            "memory": 0
        },
        "cost": 0,
    }