|
31 | 31 |
|
32 | 32 | @RunWith(Parameterized.class)
|
33 | 33 | public class OdoCliComponentTest extends OdoCliTest {
|
34 |
| - private final ComponentFeature feature; |
35 |
| - private String project; |
36 |
| - private String component; |
37 |
| - private String service; |
| 34 | + private final ComponentFeature feature; |
| 35 | + private String project; |
| 36 | + private String component; |
| 37 | + private String service; |
38 | 38 |
|
39 |
| - public OdoCliComponentTest(ComponentFeature feature) { |
40 |
| - this.feature = feature; |
41 |
| - } |
| 39 | + public OdoCliComponentTest(ComponentFeature feature) { |
| 40 | + this.feature = feature; |
| 41 | + } |
42 | 42 |
|
43 |
| - @Parameterized.Parameters(name = "feature: {0}") |
44 |
| - public static Iterable<?> data() { |
45 |
| - return Arrays.asList(null, ComponentFeature.DEV); |
46 |
| - } |
| 43 | + @Parameterized.Parameters(name = "feature: {0}") |
| 44 | + public static Iterable<?> data() { |
| 45 | + return Arrays.asList(null, ComponentFeature.DEV); |
| 46 | + } |
47 | 47 |
|
48 |
| - @Before |
49 |
| - public void initTestEnv() { |
50 |
| - project = PROJECT_PREFIX + random.nextInt(); |
51 |
| - component = COMPONENT_PREFIX + random.nextInt(); |
52 |
| - service = SERVICE_PREFIX + random.nextInt(); |
53 |
| - } |
| 48 | + @Before |
| 49 | + public void initTestEnv() { |
| 50 | + project = PROJECT_PREFIX + random.nextInt(); |
| 51 | + component = COMPONENT_PREFIX + random.nextInt(); |
| 52 | + service = SERVICE_PREFIX + random.nextInt(); |
| 53 | + } |
54 | 54 |
|
55 |
| - @After |
56 |
| - public void cleanUp() throws IOException { |
57 |
| - if (odo.isStarted(COMPONENT_PATH, ComponentFeature.DEV)) { |
58 |
| - odo.stop(COMPONENT_PATH, component, ComponentFeature.DEV); |
59 |
| - } |
60 |
| - if (project.equals(odo.getCurrentNamespace())) { |
61 |
| - odo.deleteProject(project); |
62 |
| - } |
| 55 | + @After |
| 56 | + public void cleanUp() throws IOException { |
| 57 | + if (odo.isStarted(COMPONENT_PATH, ComponentFeature.DEV)) { |
| 58 | + odo.stop(COMPONENT_PATH, component, ComponentFeature.DEV); |
63 | 59 | }
|
64 |
| - |
65 |
| - @Test |
66 |
| - public void checkCreateComponent() throws IOException, ExecutionException, InterruptedException { |
67 |
| - createComponent(project, component, feature); |
68 |
| - List<Component> components = odo.getComponents(project); |
69 |
| - assertNotNull(components); |
70 |
| - assertEquals(feature == ComponentFeature.DEV ? 1 : 0, components.size()); |
| 60 | + if (project.equals(odo.getCurrentNamespace())) { |
| 61 | + odo.deleteProject(project); |
71 | 62 | }
|
| 63 | + } |
72 | 64 |
|
73 |
| - @Test |
74 |
| - public void checkCreateAndDiscoverComponent() throws IOException, ExecutionException, InterruptedException { |
75 |
| - createComponent(project, component, feature); |
76 |
| - List<ComponentDescriptor> components = odo.discover(COMPONENT_PATH); |
77 |
| - assertNotNull(components); |
78 |
| - assertEquals(1, components.size()); |
79 |
| - assertEquals(new File(COMPONENT_PATH).getAbsolutePath(), components.get(0).getPath()); |
80 |
| - assertEquals(component, components.get(0).getName()); |
81 |
| - } |
| 65 | + @Test |
| 66 | + public void checkCreateComponent() throws IOException, ExecutionException, InterruptedException { |
| 67 | + createComponent(project, component, feature); |
| 68 | + List<Component> components = odo.getComponents(project); |
| 69 | + assertNotNull(components); |
| 70 | + assertEquals(feature == ComponentFeature.DEV ? 1 : 0, components.size()); |
| 71 | + } |
82 | 72 |
|
83 |
| - @Test |
84 |
| - public void checkCreateAndDeleteComponent() throws IOException, ExecutionException, InterruptedException { |
85 |
| - createComponent(project, component, feature); |
86 |
| - odo.deleteComponent(project, COMPONENT_PATH, component, ComponentKind.DEVFILE); |
87 |
| - } |
| 73 | + @Test |
| 74 | + public void checkCreateAndDiscoverComponent() throws IOException, ExecutionException, InterruptedException { |
| 75 | + createComponent(project, component, feature); |
| 76 | + List<ComponentDescriptor> components = odo.discover(COMPONENT_PATH); |
| 77 | + assertNotNull(components); |
| 78 | + assertEquals(1, components.size()); |
| 79 | + assertEquals(new File(COMPONENT_PATH).getAbsolutePath(), components.get(0).getPath()); |
| 80 | + assertEquals(component, components.get(0).getName()); |
| 81 | + } |
88 | 82 |
|
89 |
| - @Test |
90 |
| - @Ignore |
91 |
| - public void checkCreateComponentAndLinkService() throws IOException, ExecutionException, InterruptedException { |
92 |
| - Assume.assumeTrue(feature != null); |
93 |
| - createComponent(project, component, feature); |
94 |
| - ServiceTemplate serviceTemplate = getServiceTemplate(); |
95 |
| - OperatorCRD crd = getOperatorCRD(serviceTemplate); |
96 |
| - odo.createService(project, serviceTemplate, crd, service, null, true); |
97 |
| - List<Service> deployedServices = odo.getServices(project); |
98 |
| - assertNotNull(deployedServices); |
99 |
| - assertEquals(1, deployedServices.size()); |
100 |
| - Service deployedService = deployedServices.get(0); |
101 |
| - assertNotNull(deployedService); |
102 |
| - Binding binding = odo.link(COMPONENT_PATH, deployedService.getKind() + "/" + deployedService.getName()); |
103 |
| - assertNotNull(binding); |
104 |
| - } |
| 83 | + @Test |
| 84 | + public void checkCreateAndDeleteComponent() throws IOException, ExecutionException, InterruptedException { |
| 85 | + createComponent(project, component, feature); |
| 86 | + odo.deleteComponent(project, COMPONENT_PATH, component, ComponentKind.DEVFILE); |
| 87 | + } |
105 | 88 |
|
106 |
| - @Test |
107 |
| - public void checkCreateComponentAndListURLs() throws IOException, ExecutionException, InterruptedException { |
108 |
| - Assume.assumeTrue(feature != null); |
109 |
| - createComponent(project, component, feature); |
110 |
| - List<URL> urls = odo.listURLs(COMPONENT_PATH); |
111 |
| - assertEquals(1, urls.size()); |
112 |
| - } |
| 89 | + @Test |
| 90 | + @Ignore |
| 91 | + public void checkCreateComponentAndLinkService() throws IOException, ExecutionException, InterruptedException { |
| 92 | + Assume.assumeTrue(feature != null); |
| 93 | + createComponent(project, component, feature); |
| 94 | + ServiceTemplate serviceTemplate = getServiceTemplate(); |
| 95 | + OperatorCRD crd = getOperatorCRD(serviceTemplate); |
| 96 | + odo.createService(project, serviceTemplate, crd, service, null, true); |
| 97 | + List<Service> deployedServices = odo.getServices(project); |
| 98 | + assertNotNull(deployedServices); |
| 99 | + assertEquals(1, deployedServices.size()); |
| 100 | + Service deployedService = deployedServices.get(0); |
| 101 | + assertNotNull(deployedService); |
| 102 | + Binding binding = odo.link(COMPONENT_PATH, deployedService.getKind() + "/" + deployedService.getName()); |
| 103 | + assertNotNull(binding); |
| 104 | + } |
113 | 105 |
|
114 |
| - @Test |
115 |
| - public void checkCreateComponentAndDebug() throws IOException, ExecutionException, InterruptedException { |
116 |
| - Assume.assumeTrue(feature != null); |
117 |
| - createComponent(project, component, feature); |
118 |
| - odo.start(COMPONENT_PATH, component, ComponentFeature.DEV, null, null); |
119 |
| - List<URL> urls = odo.listURLs(COMPONENT_PATH); |
120 |
| - assertEquals(odo.isOpenShift() ? 2 : 1, urls.size()); |
121 |
| - int debugPort; |
122 |
| - try (ServerSocket serverSocket = new ServerSocket(0)) { |
123 |
| - debugPort = serverSocket.getLocalPort(); |
124 |
| - } |
125 |
| - ExecHelper.submit(() -> { |
126 |
| - try { |
127 |
| - odo.debug(COMPONENT_PATH, debugPort); |
128 |
| - DebugStatus status = odo.debugStatus(COMPONENT_PATH); |
129 |
| - assertEquals(DebugStatus.RUNNING, status); |
130 |
| - } catch (IOException e) { |
131 |
| - fail("Should not raise Exception"); |
132 |
| - } |
133 |
| - }); |
134 |
| - } |
| 106 | + @Test |
| 107 | + public void checkCreateComponentAndListURLs() throws IOException, ExecutionException, InterruptedException { |
| 108 | + Assume.assumeTrue(feature != null); |
| 109 | + createComponent(project, component, feature); |
| 110 | + List<URL> urls = odo.listURLs(COMPONENT_PATH); |
| 111 | + assertEquals(1, urls.size()); |
| 112 | + } |
135 | 113 |
|
136 |
| - @Test |
137 |
| - public void checkCreateComponentStarter() throws IOException, ExecutionException, InterruptedException { |
138 |
| - createProject(project); |
139 |
| - odo.createComponent("java-springboot", REGISTRY_NAME, component, |
140 |
| - Files.newTemporaryFolder().getAbsolutePath(), null, "springbootproject"); |
141 |
| - List<Component> components = odo.getComponents(project); |
142 |
| - assertNotNull(components); |
143 |
| - assertEquals(0, components.size()); |
| 114 | + @Test |
| 115 | + public void checkCreateComponentAndDebug() throws IOException, ExecutionException, InterruptedException { |
| 116 | + Assume.assumeTrue(feature != null); |
| 117 | + createComponent(project, component, feature); |
| 118 | + odo.start(COMPONENT_PATH, component, ComponentFeature.DEV, null, null); |
| 119 | + List<URL> urls = odo.listURLs(COMPONENT_PATH); |
| 120 | + assertEquals(odo.isOpenShift() ? 2 : 1, urls.size()); |
| 121 | + int debugPort; |
| 122 | + try (ServerSocket serverSocket = new ServerSocket(0)) { |
| 123 | + debugPort = serverSocket.getLocalPort(); |
144 | 124 | }
|
| 125 | + ExecHelper.submit(() -> { |
| 126 | + try { |
| 127 | + odo.debug(COMPONENT_PATH, debugPort); |
| 128 | + DebugStatus status = odo.debugStatus(COMPONENT_PATH); |
| 129 | + assertEquals(DebugStatus.RUNNING, status); |
| 130 | + } catch (IOException e) { |
| 131 | + fail("Should not raise Exception"); |
| 132 | + } |
| 133 | + }); |
| 134 | + } |
| 135 | + |
| 136 | + @Test |
| 137 | + public void checkCreateComponentStarter() throws IOException, ExecutionException, InterruptedException { |
| 138 | + createProject(project); |
| 139 | + odo.createComponent("nodejs", REGISTRY_NAME, component, |
| 140 | + Files.newTemporaryFolder().getAbsolutePath(), null, "nodejs-starter"); |
| 141 | + List<Component> components = odo.getComponents(project); |
| 142 | + assertNotNull(components); |
| 143 | + assertEquals(0, components.size()); |
| 144 | + } |
145 | 145 | }
|
0 commit comments