aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java
blob: 25b98bb6fb707994edec653b0fa07f4acc267843 (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package org.openecomp.sdc.validation.impl.validators.namingconvention;

import org.openecomp.core.validation.types.MessageContainer;
import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes;
import org.openecomp.sdc.validation.impl.validators.NamingConventionGuideLineValidator;
import org.openecomp.sdc.validation.util.ValidationTestUtil;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.io.IOException;
import java.util.Map;

/**
 * Created by TALIO on 2/28/2017.
 */
public class NovaServerNamingConventionGuideLineValidatorTest {

  NamingConventionGuideLineValidator baseValidator = new NamingConventionGuideLineValidator();
  NovaServerNamingConventionGuideLineValidator resourceValidator = new
      NovaServerNamingConventionGuideLineValidator();

  @Test
  public void testHeatNovaServerMetaDataValidation() {
    Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
        resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
        "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaServerMetaDataValidation/positive/");
    Assert.assertNotNull(messages);
    Assert.assertEquals(messages.size(), 0);

    messages = ValidationTestUtil.testValidator(baseValidator,
        resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
        "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaServerMetaDataValidation/negative/");
    Assert.assertNotNull(messages);
    Assert.assertEquals(messages.size(), 1);
    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
        "WARNING: Missing VNF_ID in Metadata property, Resource ID [FSB2]");
  }

  @Test
  public void testNovaServerAvailabilityZoneName() {
    Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
        resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
        "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaServerAvailabilityZoneName/positive");
    Assert.assertNotNull(messages);
    Assert.assertEquals(messages.size(), 0);

    messages = ValidationTestUtil.testValidator(baseValidator,
        resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
        "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaServerAvailabilityZoneName/negative");
    Assert.assertNotNull(messages);
    Assert.assertEquals(messages.size(), 1);
    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 3);
    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
        "WARNING: Server 'Availability Zone' Parameter Name not aligned with Guidelines, Parameter Name [availability_zone_a], Resource ID [FSB2]. As a result, VF/VFC Profile may miss this information");
    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
        "WARNING: Server 'Availability Zone' Parameter Name not aligned with Guidelines, Parameter Name [availability_zone], Resource ID [FSB3]. As a result, VF/VFC Profile may miss this information");
  }

  @Test
  public void testNovaImageAndFlavorNames() {
    Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
        resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
        "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaServerImageAndFlavor/positive");
    Assert.assertNotNull(messages);
    Assert.assertEquals(messages.size(), 0);

    messages = ValidationTestUtil.testValidator(baseValidator,
        resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
        "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaServerImageAndFlavor/negative");
    Assert.assertNotNull(messages);
    Assert.assertEquals(messages.size(), 1);
    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 2);
    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
        "WARNING: Server 'flavor' Parameter Name not aligned with Guidelines, Parameter Name [fsb2-flavor], Resource ID [FSB2]. As a result, VF/VFC Profile may miss this information");
    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
        "WARNING: Server 'image' Parameter Name not aligned with Guidelines, Parameter Name [fsb2-image], Resource ID [FSB3]. As a result, VF/VFC Profile may miss this information");
  }

  @Test
  public void testNovaResourceNetworkUniqueRole() {
    Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
        resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
        "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaNetworkUniqueRoleConvention/positive/");
    Assert.assertNotNull(messages);
    Assert.assertEquals(messages.size(), 0);

    messages = ValidationTestUtil.testValidator(baseValidator,
        resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
        "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaNetworkUniqueRoleConvention/negative/");
    Assert.assertNotNull(messages);
    Assert.assertEquals(messages.size(), 1);
    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 1);
    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
        "WARNING: A resource is connected twice to the same network role, Network Role [FSB2], Resource ID [Internal1]");
  }

  @Test
  public void testNovaServerName() {
    Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
        resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
        "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaServerNameValidation/positive");
    Assert.assertNotNull(messages);
    Assert.assertEquals(messages.size(), 0);

    messages = ValidationTestUtil.testValidator(baseValidator,
        resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
        "/org/openecomp/validation/validators/attGuideLineValidator/heatNovaServerNameValidation/negative/");
    Assert.assertNotNull(messages);
    Assert.assertEquals(messages.size(), 1);
    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 2);
    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
        "WARNING: Server 'name' Parameter Name not aligned with Guidelines, Parameter Name [pcrf_pps_server_4], Resource ID [FSB2]. As a result, VF/VFC Profile may miss this information");
  }

  @Test
  public void testVMNameSyncInNova() {
    Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
        resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
        "/org/openecomp/validation/validators/attGuideLineValidator/novaVMNameSync/input");

    Assert.assertNotNull(messages);
    Assert.assertEquals(messages.size(), 1);

    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().size(), 4);
    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(),
        "WARNING: Server 'name' Parameter Name not aligned with Guidelines, Parameter Name [CE_server_name], Resource ID [FSB2_legal_2]. As a result, VF/VFC Profile may miss this information");
    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(1).getMessage(),
        "WARNING: Server 'flavor' Parameter Name not aligned with Guidelines, Parameter Name [fsb_flavor_names], Resource ID [FSB2_legal_3]. As a result, VF/VFC Profile may miss this information");
    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(2).getMessage(),
        "WARNING: Nova Server naming convention in image, flavor and name properties is not consistent, Resource ID [FSB2_illegal_1]");
    Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(3).getMessage(),
        "WARNING: Nova Server naming convention in image, flavor and name properties is not consistent, Resource ID [FSB2_illegal_2]");

  }

  @Test
  public void testAvailabilityZoneName() throws IOException {
    Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
        resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
        "/org/openecomp/validation/validators/att_naming_convention/availability_zone_name/input");

    Assert.assertNotNull(messages);
    Assert.assertEquals(messages.size(), 1);

    Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 2);
    Assert.assertEquals(
        messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
        "WARNING: Server 'Availability Zone' Parameter Name not aligned with Guidelines, Parameter Name [availability_zone_name], Resource ID [availability_zone_illegal_name_1]. As a result, VF/VFC Profile may miss this information");
    Assert.assertEquals(
        messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(),
        "WARNING: Server 'Availability Zone' Parameter Name not aligned with Guidelines, Parameter Name [availability_zone], Resource ID [availability_zone_illegal_name_2]. As a result, VF/VFC Profile may miss this information");
  }
}