From 6f89acce235599ef3023728d69f179df9b7b7710 Mon Sep 17 00:00:00 2001 From: huangguojie2024 <503601315@qq.com> Date: Fri, 7 Feb 2025 17:33:25 +0800 Subject: [PATCH] Add some unit tests for stack infra module. --- .../v1_0_0/grafana/GrafanaParamsTest.java | 32 +++++++++++++ .../grafana/GrafanaServerScriptTest.java | 32 +++++++++++++ .../v1_0_0/mysql/MySQLClientScriptTest.java | 48 +++++++++++++++++++ .../infra/v1_0_0/mysql/MySQLParamsTest.java | 32 +++++++++++++ .../v1_0_0/mysql/MySQLServerScriptTest.java | 32 +++++++++++++ .../prometheus/PrometheusParamsTest.java | 32 +++++++++++++ .../PrometheusServerScriptTest.java | 32 +++++++++++++ 7 files changed, 240 insertions(+) create mode 100644 bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/grafana/GrafanaParamsTest.java create mode 100644 bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/grafana/GrafanaServerScriptTest.java create mode 100644 bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/mysql/MySQLClientScriptTest.java create mode 100644 bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/mysql/MySQLParamsTest.java create mode 100644 bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/mysql/MySQLServerScriptTest.java create mode 100644 bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusParamsTest.java create mode 100644 bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusServerScriptTest.java diff --git a/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/grafana/GrafanaParamsTest.java b/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/grafana/GrafanaParamsTest.java new file mode 100644 index 00000000..6c82b234 --- /dev/null +++ b/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/grafana/GrafanaParamsTest.java @@ -0,0 +1,32 @@ +/* + * 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.infra.v1_0_0.grafana; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class GrafanaParamsTest { + + @Test + public void testGetServiceName() { + GrafanaParams grafanaParams = new GrafanaParams(); + assertEquals("grafana", grafanaParams.getServiceName()); + } +} diff --git a/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/grafana/GrafanaServerScriptTest.java b/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/grafana/GrafanaServerScriptTest.java new file mode 100644 index 00000000..813a690b --- /dev/null +++ b/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/grafana/GrafanaServerScriptTest.java @@ -0,0 +1,32 @@ +/* + * 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.infra.v1_0_0.grafana; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class GrafanaServerScriptTest { + + @Test + public void testGetComponentName() { + GrafanaServerScript grafanaServerScript = new GrafanaServerScript(); + assertEquals("grafana_server", grafanaServerScript.getComponentName()); + } +} diff --git a/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/mysql/MySQLClientScriptTest.java b/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/mysql/MySQLClientScriptTest.java new file mode 100644 index 00000000..4aeb1175 --- /dev/null +++ b/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/mysql/MySQLClientScriptTest.java @@ -0,0 +1,48 @@ +/* + * 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.infra.v1_0_0.mysql; + +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 MySQLClientScriptTest { + + private final MySQLClientScript clientScript = new MySQLClientScript(); + + @Test + public void testGetComponentName() { + assertEquals("mysql_client", clientScript.getComponentName()); + } + + @Test + public void testAddParamsNull() { + Params params = null; + assertThrows(NullPointerException.class, () -> clientScript.add(params)); + } + + @Test + public void testConfigureParamsNull() { + Params params = null; + assertThrows(NullPointerException.class, () -> clientScript.configure(params)); + } +} diff --git a/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/mysql/MySQLParamsTest.java b/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/mysql/MySQLParamsTest.java new file mode 100644 index 00000000..296a7d28 --- /dev/null +++ b/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/mysql/MySQLParamsTest.java @@ -0,0 +1,32 @@ +/* + * 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.infra.v1_0_0.mysql; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class MySQLParamsTest { + + @Test + public void testGetServiceName() { + MySQLParams mySQLParams = new MySQLParams(); + assertEquals("mysql", mySQLParams.getServiceName()); + } +} diff --git a/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/mysql/MySQLServerScriptTest.java b/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/mysql/MySQLServerScriptTest.java new file mode 100644 index 00000000..33aab4a1 --- /dev/null +++ b/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/mysql/MySQLServerScriptTest.java @@ -0,0 +1,32 @@ +/* + * 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.infra.v1_0_0.mysql; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class MySQLServerScriptTest { + + @Test + void testGetComponentName() { + MySQLServerScript mysqlServerScript = new MySQLServerScript(); + assertEquals("mysql_server", mysqlServerScript.getComponentName()); + } +} diff --git a/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusParamsTest.java b/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusParamsTest.java new file mode 100644 index 00000000..5851f341 --- /dev/null +++ b/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusParamsTest.java @@ -0,0 +1,32 @@ +/* + * 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.infra.v1_0_0.prometheus; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class PrometheusParamsTest { + + @Test + public void testGetServiceName() { + PrometheusParams prometheusParams = new PrometheusParams(); + assertEquals("prometheus", prometheusParams.getServiceName()); + } +} diff --git a/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusServerScriptTest.java b/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusServerScriptTest.java new file mode 100644 index 00000000..e506c46f --- /dev/null +++ b/bigtop-manager-stack/bigtop-manager-stack-infra/src/test/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusServerScriptTest.java @@ -0,0 +1,32 @@ +/* + * 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.infra.v1_0_0.prometheus; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class PrometheusServerScriptTest { + + @Test + public void testGetComponentName() { + PrometheusServerScript script = new PrometheusServerScript(); + assertEquals("prometheus_server", script.getComponentName()); + } +}