-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BIGTOP-4348: Add some unit tests for stack bigtop module (#167)
- Loading branch information
Showing
32 changed files
with
1,956 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
.../test/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/flink/FlinkClientScriptTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.bigtop.manager.stack.bigtop.v3_3_0.flink; | ||
|
||
import org.apache.bigtop.manager.stack.core.spi.param.Params; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
@Slf4j | ||
public class FlinkClientScriptTest { | ||
|
||
private final FlinkClientScript flinkClientScript = new FlinkClientScript(); | ||
|
||
@Test | ||
public void testGetComponentName() { | ||
assertEquals("flink_client", flinkClientScript.getComponentName()); | ||
} | ||
|
||
@Test | ||
public void testAddParamsNull() { | ||
Params params = null; | ||
assertThrows(NullPointerException.class, () -> flinkClientScript.add(params)); | ||
} | ||
|
||
@Test | ||
public void testConfigureParamsNull() { | ||
Params params = null; | ||
assertThrows(NullPointerException.class, () -> flinkClientScript.configure(params)); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...ava/org/apache/bigtop/manager/stack/bigtop/v3_3_0/flink/FlinkHistoryServerScriptTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.bigtop.manager.stack.bigtop.v3_3_0.flink; | ||
|
||
import org.apache.bigtop.manager.stack.core.spi.param.Params; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
class FlinkHistoryServerScriptTest { | ||
|
||
private final FlinkHistoryServerScript flinkHistoryServerScript = new FlinkHistoryServerScript(); | ||
|
||
@Test | ||
void testGetComponentName() { | ||
assertEquals("flink_historyserver", flinkHistoryServerScript.getComponentName()); | ||
} | ||
|
||
@Test | ||
public void testAddParamsNull() { | ||
Params params = null; | ||
assertThrows(NullPointerException.class, () -> flinkHistoryServerScript.add(params)); | ||
} | ||
|
||
@Test | ||
public void testConfigureParamsNull() { | ||
Params params = null; | ||
assertThrows(NullPointerException.class, () -> flinkHistoryServerScript.configure(params)); | ||
} | ||
|
||
@Test | ||
public void testStartParamsNull() { | ||
Params params = null; | ||
assertThrows(NullPointerException.class, () -> flinkHistoryServerScript.start(params)); | ||
} | ||
|
||
@Test | ||
public void testStopParamsNull() { | ||
Params params = null; | ||
assertThrows(NullPointerException.class, () -> flinkHistoryServerScript.stop(params)); | ||
} | ||
|
||
@Test | ||
public void testStatusParamsNull() { | ||
Params params = null; | ||
assertThrows(NullPointerException.class, () -> flinkHistoryServerScript.status(params)); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...op/src/test/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/flink/FlinkParamsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.bigtop.manager.stack.bigtop.v3_3_0.flink; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class FlinkParamsTest { | ||
|
||
private FlinkParams flinkParams; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
flinkParams = mock(FlinkParams.class); | ||
when(flinkParams.stackHome()).thenReturn("/stack"); | ||
when(flinkParams.getServiceName()).thenCallRealMethod(); | ||
when(flinkParams.serviceHome()).thenCallRealMethod(); | ||
when(flinkParams.hadoopHome()).thenCallRealMethod(); | ||
when(flinkParams.hadoopConfDir()).thenCallRealMethod(); | ||
when(flinkParams.confDir()).thenCallRealMethod(); | ||
} | ||
|
||
@Test | ||
public void testServiceHome() { | ||
assertEquals("/stack/flink", flinkParams.serviceHome()); | ||
} | ||
|
||
@Test | ||
public void testConfDir() { | ||
assertEquals("/stack/flink/conf", flinkParams.confDir()); | ||
} | ||
|
||
@Test | ||
public void testHadoopConfDir() { | ||
assertEquals("/stack/hadoop/etc/hadoop", flinkParams.hadoopConfDir()); | ||
} | ||
|
||
@Test | ||
public void testHadoopHome() { | ||
assertEquals("/stack/hadoop", flinkParams.hadoopHome()); | ||
} | ||
|
||
@Test | ||
public void testGetServiceName() { | ||
assertEquals("flink", flinkParams.getServiceName()); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...rc/test/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/hadoop/DataNodeScriptTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.bigtop.manager.stack.bigtop.v3_3_0.hadoop; | ||
|
||
import org.apache.bigtop.manager.stack.core.spi.param.Params; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class DataNodeScriptTest { | ||
|
||
private final DataNodeScript dataNodeScript = new DataNodeScript(); | ||
|
||
@Test | ||
public void testGetComponentName() { | ||
assertEquals("datanode", dataNodeScript.getComponentName()); | ||
} | ||
|
||
@Test | ||
public void testAddParamsNull() { | ||
Params params = null; | ||
assertThrows(NullPointerException.class, () -> dataNodeScript.add(params)); | ||
} | ||
|
||
@Test | ||
public void testConfigureParamsNull() { | ||
Params params = null; | ||
assertThrows(NullPointerException.class, () -> dataNodeScript.configure(params)); | ||
} | ||
|
||
@Test | ||
public void testStartParamsNull() { | ||
Params params = null; | ||
assertThrows(NullPointerException.class, () -> dataNodeScript.start(params)); | ||
} | ||
|
||
@Test | ||
public void testStopParamsNull() { | ||
Params params = null; | ||
assertThrows(NullPointerException.class, () -> dataNodeScript.stop(params)); | ||
} | ||
|
||
@Test | ||
public void testStatusParamsNull() { | ||
Params params = null; | ||
assertThrows(NullPointerException.class, () -> dataNodeScript.status(params)); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...est/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/hadoop/HadoopClientScriptTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.bigtop.manager.stack.bigtop.v3_3_0.hadoop; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
@Slf4j | ||
public class HadoopClientScriptTest { | ||
|
||
private final HadoopClientScript hadoopClientScript = new HadoopClientScript(); | ||
|
||
@Test | ||
public void testGetComponentName() { | ||
assertEquals("hadoop_client", hadoopClientScript.getComponentName()); | ||
} | ||
|
||
@Test | ||
public void testAddParamsNull() { | ||
assertThrows(NullPointerException.class, () -> hadoopClientScript.add(null)); | ||
} | ||
|
||
@Test | ||
public void testConfigureParamsNull() { | ||
assertThrows(NullPointerException.class, () -> hadoopClientScript.configure(null)); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
.../src/test/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/hadoop/HadoopParamsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.bigtop.manager.stack.bigtop.v3_3_0.hadoop; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class HadoopParamsTest { | ||
|
||
private HadoopParams hadoopParams; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
hadoopParams = mock(HadoopParams.class); | ||
when(hadoopParams.stackHome()).thenReturn("/stack"); | ||
when(hadoopParams.getServiceName()).thenCallRealMethod(); | ||
when(hadoopParams.serviceHome()).thenCallRealMethod(); | ||
when(hadoopParams.confDir()).thenCallRealMethod(); | ||
when(hadoopParams.binDir()).thenCallRealMethod(); | ||
} | ||
|
||
@Test | ||
public void testServiceHome() { | ||
assertEquals("/stack/hadoop", hadoopParams.serviceHome()); | ||
} | ||
|
||
@Test | ||
public void testConfDir() { | ||
assertEquals("/stack/hadoop/etc/hadoop", hadoopParams.confDir()); | ||
} | ||
|
||
@Test | ||
public void testBinDir() { | ||
assertEquals("/stack/hadoop/bin", hadoopParams.binDir()); | ||
} | ||
|
||
@Test | ||
public void testGetServiceName() { | ||
assertEquals("hadoop", hadoopParams.getServiceName()); | ||
} | ||
} |
Oops, something went wrong.