summaryrefslogtreecommitdiffstats
path: root/node-maintainer/src/test/java/com/yahoo/vespa/hosted/node/verification/spec/HardwareNodeComparatorTest.java
blob: ec621189269608c4d4d1d11301b4da3a7f7410c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.yahoo.vespa.hosted.node.verification.spec;

import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo;
import com.yahoo.vespa.hosted.node.verification.spec.retrievers.HardwareInfo.DiskType;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
 * Created by olaa on 07/07/2017.
 */
public class HardwareNodeComparatorTest {

    private HardwareInfo actualHardware;
    private HardwareInfo nodeInfo;

    @Before
    public void setup() {
        actualHardware = new HardwareInfo();
        nodeInfo = new HardwareInfo();
        actualHardware.setMinCpuCores(24);
        nodeInfo.setMinCpuCores(24);
        actualHardware.setMinMainMemoryAvailableGb(16);
        nodeInfo.setMinMainMemoryAvailableGb(16);
        nodeInfo.setInterfaceSpeedMbs(10000);
        actualHardware.setInterfaceSpeedMbs(10000);
        actualHardware.setMinDiskAvailableGb(500);
        nodeInfo.setMinDiskAvailableGb(500);
    }

    @Test
    public void compare_should_be_equal() {
        assertTrue(HardwareNodeComparator.compare(nodeInfo, actualHardware).getMetrics().isMatch());

    }

    @Test
    public void compare_different_amount_of_cores_should_be_false() {
        actualHardware.setMinCpuCores(4);
        nodeInfo.setMinCpuCores(1);
        assertFalse(HardwareNodeComparator.compare(nodeInfo, actualHardware).getMetrics().isMatch());
    }

    @Test
    public void compare_different_disk_type_should_return_false() {
        actualHardware.setDiskType(DiskType.UNKNOWN);
        nodeInfo.setDiskType(DiskType.FAST);
        assertFalse(HardwareNodeComparator.compare(nodeInfo, actualHardware).getMetrics().isMatch());
    }


}