This is an automated email from the ASF dual-hosted git repository. shaofengshi pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kylin.git
commit 2d718c83db2abd91d053b77a44ed4a98648adcdc Author: Zhong, Yanghong <nju_y...@apache.org> AuthorDate: Wed May 20 18:21:19 2020 +0800 KYLIN-4508 Add more unit tests for core-metrics module Signed-off-by: shaofengshi <shaofeng...@apache.org> --- core-metrics/pom.xml | 17 +++ .../kylin/metrics/lib/impl/BlockingReservoir.java | 21 +++- .../apache/kylin/metrics/lib/impl/RecordEvent.java | 6 +- .../kylin/metrics/lib/impl/TimePropertyEnum.java | 2 +- .../metrics/lib/impl/BlockingReservoirTest.java | 76 ++++++++++++ .../metrics/lib/impl/InstantReservoirTest.java | 64 ++++++++++ .../kylin/metrics/lib/impl/MetricsSystemTest.java | 67 +++++++++++ .../kylin/metrics/lib/impl/RecordEventTest.java | 82 +++++++++++++ .../metrics/property/MetricsPropertyEnumTest.java | 132 +++++++++++++++++++++ 9 files changed, 463 insertions(+), 4 deletions(-) diff --git a/core-metrics/pom.xml b/core-metrics/pom.xml index b9bc566..eca9e5e 100644 --- a/core-metrics/pom.xml +++ b/core-metrics/pom.xml @@ -45,5 +45,22 @@ <artifactId>metrics-core</artifactId> </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + + <!-- Env & Test --> + <dependency> + <groupId>org.apache.kylin</groupId> + <artifactId>kylin-core-common</artifactId> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> </dependencies> </project> \ No newline at end of file diff --git a/core-metrics/src/main/java/org/apache/kylin/metrics/lib/impl/BlockingReservoir.java b/core-metrics/src/main/java/org/apache/kylin/metrics/lib/impl/BlockingReservoir.java index 6158096..4798e52 100644 --- a/core-metrics/src/main/java/org/apache/kylin/metrics/lib/impl/BlockingReservoir.java +++ b/core-metrics/src/main/java/org/apache/kylin/metrics/lib/impl/BlockingReservoir.java @@ -22,6 +22,8 @@ import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Preconditions; import org.apache.kylin.metrics.lib.ActiveReservoirListener; import org.apache.kylin.metrics.lib.Record; import org.slf4j.Logger; @@ -58,6 +60,10 @@ public class BlockingReservoir extends AbstractActiveReservoir { } public BlockingReservoir(int minReportSize, int maxReportSize, int maxReportTime) { + Preconditions.checkArgument(minReportSize > 0, "minReportSize should be larger than 0"); + Preconditions.checkArgument(maxReportSize >= minReportSize, + "maxReportSize should not be less than minBatchSize"); + Preconditions.checkArgument(maxReportTime > 0, "maxReportTime should be larger than 0"); this.minReportSize = minReportSize; this.maxReportSize = maxReportSize; this.maxReportTime = maxReportTime * 60 * 1000L; @@ -95,9 +101,11 @@ public class BlockingReservoir extends AbstractActiveReservoir { if (ifAll) { records = Lists.newArrayList(); recordsQueue.drainTo(records); + logger.info("Will report {} metrics records", records.size()); } else { records.clear(); recordsQueue.drainTo(records, maxReportSize); + logger.info("Will report {} metrics records, remaining {} records", records.size(), size()); } boolean ifSucceed = true; @@ -127,9 +135,18 @@ public class BlockingReservoir extends AbstractActiveReservoir { return true; } - @Override - public void start() { + @VisibleForTesting + void notifyUpdate() { + onRecordUpdate(false); + } + + @VisibleForTesting + void setReady() { super.start(); + } + + public void start() { + setReady(); scheduledReporter.start(); } diff --git a/core-metrics/src/main/java/org/apache/kylin/metrics/lib/impl/RecordEvent.java b/core-metrics/src/main/java/org/apache/kylin/metrics/lib/impl/RecordEvent.java index bc4faf0..59aa7e3 100644 --- a/core-metrics/src/main/java/org/apache/kylin/metrics/lib/impl/RecordEvent.java +++ b/core-metrics/src/main/java/org/apache/kylin/metrics/lib/impl/RecordEvent.java @@ -66,6 +66,10 @@ public class RecordEvent implements Record, Map<String, Object>, Serializable { this(eventType, LOCAL_HOSTNAME); } + public RecordEvent(String eventType, long time) { + this(eventType, LOCAL_HOSTNAME, time); + } + public RecordEvent(String eventType, String host) { this(eventType, host, System.currentTimeMillis()); } @@ -268,7 +272,7 @@ public class RecordEvent implements Record, Map<String, Object>, Serializable { return reserveKey; } - public RecordReserveKeyEnum getByKey(String key) { + public static RecordReserveKeyEnum getByKey(String key) { for (RecordReserveKeyEnum reserveKey : RecordReserveKeyEnum.values()) { if (reserveKey.reserveKey.equalsIgnoreCase(key)) { return reserveKey; diff --git a/core-metrics/src/main/java/org/apache/kylin/metrics/lib/impl/TimePropertyEnum.java b/core-metrics/src/main/java/org/apache/kylin/metrics/lib/impl/TimePropertyEnum.java index 03f188b..01eefa1 100644 --- a/core-metrics/src/main/java/org/apache/kylin/metrics/lib/impl/TimePropertyEnum.java +++ b/core-metrics/src/main/java/org/apache/kylin/metrics/lib/impl/TimePropertyEnum.java @@ -38,7 +38,7 @@ public enum TimePropertyEnum { this.propertyName = propertyName; } - public static TimePropertyEnum getByPropertyName(String propertyName) { + public static TimePropertyEnum getByKey(String propertyName) { if (Strings.isNullOrEmpty(propertyName)) { return null; } diff --git a/core-metrics/src/test/java/org/apache/kylin/metrics/lib/impl/BlockingReservoirTest.java b/core-metrics/src/test/java/org/apache/kylin/metrics/lib/impl/BlockingReservoirTest.java new file mode 100644 index 0000000..47c9f46 --- /dev/null +++ b/core-metrics/src/test/java/org/apache/kylin/metrics/lib/impl/BlockingReservoirTest.java @@ -0,0 +1,76 @@ +/* + * 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 + * + * http://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.kylin.metrics.lib.impl; + +import static org.junit.Assert.assertEquals; + +import org.apache.kylin.common.util.LocalFileMetadataTestCase; +import org.apache.kylin.metrics.lib.Record; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class BlockingReservoirTest extends LocalFileMetadataTestCase { + + @Before + public void setUp() throws Exception { + this.createTestMetadata(); + } + + @After + public void after() throws Exception { + this.cleanupTestMetadata(); + } + + @Test + public void testUpdate() { + BlockingReservoir reservoir = new BlockingReservoir(); + + Record record = new RecordEvent("TEST"); + reservoir.update(record); + assertEquals(0, reservoir.size()); + + reservoir.start(); + reservoir.update(record); + assertEquals(1, reservoir.size()); + + reservoir.stop(); + assertEquals(0, reservoir.size()); + } + + @Test + public void testBatchSize() { + BlockingReservoir reservoir = new BlockingReservoir(5, 12); + reservoir.setReady(); + + for (int i = 0; i < 30; i++) { + Record record = new RecordEvent("TEST" + i); + reservoir.update(record); + } + reservoir.notifyUpdate(); + Assert.assertEquals(18, reservoir.size()); + + reservoir.notifyUpdate(); + Assert.assertEquals(6, reservoir.size()); + + reservoir.notifyUpdate(); + Assert.assertEquals(0, reservoir.size()); + } +} diff --git a/core-metrics/src/test/java/org/apache/kylin/metrics/lib/impl/InstantReservoirTest.java b/core-metrics/src/test/java/org/apache/kylin/metrics/lib/impl/InstantReservoirTest.java new file mode 100644 index 0000000..982978e --- /dev/null +++ b/core-metrics/src/test/java/org/apache/kylin/metrics/lib/impl/InstantReservoirTest.java @@ -0,0 +1,64 @@ +/* + * 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 + * + * http://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.kylin.metrics.lib.impl; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.apache.kylin.common.util.LocalFileMetadataTestCase; +import org.apache.kylin.metrics.lib.ActiveReservoirListener; +import org.apache.kylin.metrics.lib.Record; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.google.common.collect.Lists; + +public class InstantReservoirTest extends LocalFileMetadataTestCase { + + @Before + public void setUp() throws Exception { + this.createTestMetadata(); + } + + @After + public void after() throws Exception { + this.cleanupTestMetadata(); + } + + @Test + public void testUpdate() { + InstantReservoir reservoir = new InstantReservoir(); + ActiveReservoirListener listener = new StubReservoirReporter().listener; + reservoir.addListener(listener); + + Record record = new RecordEvent("TEST"); + assertTrue(listener.onRecordUpdate(Lists.newArrayList(record))); + + reservoir.update(record); + assertEquals(0, reservoir.size()); + + reservoir.start(); + reservoir.update(record); + assertEquals(0, reservoir.size()); + + reservoir.stop(); + assertEquals(0, reservoir.size()); + } +} diff --git a/core-metrics/src/test/java/org/apache/kylin/metrics/lib/impl/MetricsSystemTest.java b/core-metrics/src/test/java/org/apache/kylin/metrics/lib/impl/MetricsSystemTest.java new file mode 100644 index 0000000..12caf14 --- /dev/null +++ b/core-metrics/src/test/java/org/apache/kylin/metrics/lib/impl/MetricsSystemTest.java @@ -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 + * + * http://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.kylin.metrics.lib.impl; + +import static org.apache.kylin.metrics.lib.impl.MetricsSystem.Metrics; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.apache.kylin.metrics.lib.ActiveReservoir; +import org.apache.kylin.metrics.lib.ActiveReservoirRecordFilter; +import org.junit.Test; + +public class MetricsSystemTest { + + @Test(expected = IllegalArgumentException.class) + public void testDuplicateRegister() { + String name = "test1"; + Metrics.register(name, new StubReservoir()); + Metrics.register(name, new StubReservoir()); + } + + @Test(expected = IllegalArgumentException.class) + public void testNullRegister1() { + Metrics.register(null, new StubReservoir()); + } + + @Test + public void testActiveReservoir() { + //Remove all ActiveReservoirs + Metrics.removeActiveReservoirMatching(ActiveReservoirRecordFilter.ALL); + assertEquals(0, Metrics.getActiveReservoirs().size()); + + //Get all the ActiveReservoirs + int n = 10; + for (int i = 0; i < n; i++) { + Metrics.register("ActiveReservoir-" + i, new StubReservoir()); + } + assertEquals(n, Metrics.getActiveReservoirs().size()); + + String name = "test2"; + ActiveReservoir activeReservoir = new StubReservoir(); + Metrics.register(name, activeReservoir); + + //Get ActiveReservoir by name + assertEquals(activeReservoir, Metrics.activeReservoir(name)); + //Remove ActiveReservoir by name + assertTrue(Metrics.removeActiveReservoir(name)); + assertFalse(Metrics.removeActiveReservoir(name)); + } +} diff --git a/core-metrics/src/test/java/org/apache/kylin/metrics/lib/impl/RecordEventTest.java b/core-metrics/src/test/java/org/apache/kylin/metrics/lib/impl/RecordEventTest.java new file mode 100644 index 0000000..0c53d56 --- /dev/null +++ b/core-metrics/src/test/java/org/apache/kylin/metrics/lib/impl/RecordEventTest.java @@ -0,0 +1,82 @@ +/* + * 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 + * + * http://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.kylin.metrics.lib.impl; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.Map; + +import org.apache.kylin.common.util.JsonUtil; +import org.junit.Test; + +import com.google.common.collect.Maps; + +public class RecordEventTest { + + @Test(expected = IllegalArgumentException.class) + public void testSetEventType() { + new RecordEvent(null, System.currentTimeMillis()); + } + + @Test + public void testBasic() throws IOException { + String type = "TEST"; + String localHostname; + try { + InetAddress addr = InetAddress.getLocalHost(); + localHostname = addr.getHostName() + ":" + addr.getHostAddress(); + } catch (UnknownHostException e) { + localHostname = "Unknown"; + } + long time = System.currentTimeMillis(); + RecordEvent event = new RecordEvent(type, localHostname, time); + + assertEquals(type, event.getEventType()); + assertEquals(localHostname, event.getHost()); + assertTrue(time == event.getTime()); + + String key = "PROJECT"; + String value = "test"; + event.put(key, value); + assertEquals(value, event.remove(key)); + + int len1 = event.size(); + Map<String, Object> entryMap = Maps.newHashMap(); + for (int i = 0; i < 5; i++) { + entryMap.put(key + "-" + i, value + "-" + i); + } + event.putAll(entryMap); + assertEquals(entryMap.size(), event.size() - len1); + + assertTrue(event.clone().equals(event)); + + Map<String, Object> rawValue = JsonUtil.readValue(event.getValue(), Map.class); + assertEquals(event.size() - 1, rawValue.size()); + + assertNull(rawValue.get(RecordEvent.RecordReserveKeyEnum.EVENT_SUBJECT.toString())); + + event.clear(); + assertTrue(event.isEmpty()); + } +} diff --git a/core-metrics/src/test/java/org/apache/kylin/metrics/property/MetricsPropertyEnumTest.java b/core-metrics/src/test/java/org/apache/kylin/metrics/property/MetricsPropertyEnumTest.java new file mode 100644 index 0000000..81471fe --- /dev/null +++ b/core-metrics/src/test/java/org/apache/kylin/metrics/property/MetricsPropertyEnumTest.java @@ -0,0 +1,132 @@ +/* + * 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 + * + * http://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.kylin.metrics.property; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.apache.kylin.metrics.lib.impl.RecordEvent; +import org.apache.kylin.metrics.lib.impl.TimePropertyEnum; +import org.junit.Test; + +public class MetricsPropertyEnumTest { + + @Test + public void testJobPropertyEnum() { + assertEquals(JobPropertyEnum.ID_CODE, JobPropertyEnum.getByName("JOB_ID")); + assertEquals(JobPropertyEnum.USER, JobPropertyEnum.getByName("KUSER")); + assertEquals(JobPropertyEnum.PROJECT, JobPropertyEnum.getByName("PROJECT")); + assertEquals(JobPropertyEnum.CUBE, JobPropertyEnum.getByName("CUBE_NAME")); + assertEquals(JobPropertyEnum.TYPE, JobPropertyEnum.getByName("JOB_TYPE")); + assertEquals(JobPropertyEnum.ALGORITHM, JobPropertyEnum.getByName("CUBING_TYPE")); + assertEquals(JobPropertyEnum.STATUS, JobPropertyEnum.getByName("JOB_STATUS")); + assertEquals(JobPropertyEnum.EXCEPTION, JobPropertyEnum.getByName("EXCEPTION")); + assertEquals(JobPropertyEnum.SOURCE_SIZE, JobPropertyEnum.getByName("TABLE_SIZE")); + assertEquals(JobPropertyEnum.CUBE_SIZE, JobPropertyEnum.getByName("CUBE_SIZE")); + assertEquals(JobPropertyEnum.BUILD_DURATION, JobPropertyEnum.getByName("DURATION")); + assertEquals(JobPropertyEnum.WAIT_RESOURCE_TIME, JobPropertyEnum.getByName("WAIT_RESOURCE_TIME")); + assertEquals(JobPropertyEnum.PER_BYTES_TIME_COST, JobPropertyEnum.getByName("PER_BYTES_TIME_COST")); + assertEquals(JobPropertyEnum.STEP_DURATION_DISTINCT_COLUMNS, + JobPropertyEnum.getByName("STEP_DURATION_DISTINCT_COLUMNS")); + assertEquals(JobPropertyEnum.STEP_DURATION_DICTIONARY, JobPropertyEnum.getByName("STEP_DURATION_DICTIONARY")); + assertEquals(JobPropertyEnum.STEP_DURATION_INMEM_CUBING, + JobPropertyEnum.getByName("STEP_DURATION_INMEM_CUBING")); + assertEquals(JobPropertyEnum.STEP_DURATION_HFILE_CONVERT, + JobPropertyEnum.getByName("STEP_DURATION_HFILE_CONVERT")); + assertNull(RecordEvent.RecordReserveKeyEnum.getByKey(null)); + } + + @Test + public void testQueryPropertyEnum() { + assertEquals(QueryPropertyEnum.ID_CODE, QueryPropertyEnum.getByName("QUERY_HASH_CODE")); + assertEquals(QueryPropertyEnum.TYPE, QueryPropertyEnum.getByName("QUERY_TYPE")); + assertEquals(QueryPropertyEnum.USER, QueryPropertyEnum.getByName("KUSER")); + assertEquals(QueryPropertyEnum.PROJECT, QueryPropertyEnum.getByName("PROJECT")); + assertEquals(QueryPropertyEnum.REALIZATION, QueryPropertyEnum.getByName("REALIZATION")); + assertEquals(QueryPropertyEnum.REALIZATION_TYPE, QueryPropertyEnum.getByName("REALIZATION_TYPE")); + assertEquals(QueryPropertyEnum.EXCEPTION, QueryPropertyEnum.getByName("EXCEPTION")); + assertEquals(QueryPropertyEnum.TIME_COST, QueryPropertyEnum.getByName("QUERY_TIME_COST")); + assertEquals(QueryPropertyEnum.CALCITE_RETURN_COUNT, QueryPropertyEnum.getByName("CALCITE_COUNT_RETURN")); + assertEquals(QueryPropertyEnum.STORAGE_RETURN_COUNT, QueryPropertyEnum.getByName("STORAGE_COUNT_RETURN")); + assertEquals(QueryPropertyEnum.AGGR_FILTER_COUNT, + QueryPropertyEnum.getByName("CALCITE_COUNT_AGGREGATE_FILTER")); + assertNull(RecordEvent.RecordReserveKeyEnum.getByKey(null)); + } + + @Test + public void testQueryCubePropertyEnum() { + assertEquals(QueryCubePropertyEnum.PROJECT, QueryCubePropertyEnum.getByName("PROJECT")); + assertEquals(QueryCubePropertyEnum.CUBE, QueryCubePropertyEnum.getByName("CUBE_NAME")); + assertEquals(QueryCubePropertyEnum.SEGMENT, QueryCubePropertyEnum.getByName("SEGMENT_NAME")); + assertEquals(QueryCubePropertyEnum.CUBOID_SOURCE, QueryCubePropertyEnum.getByName("CUBOID_SOURCE")); + assertEquals(QueryCubePropertyEnum.CUBOID_TARGET, QueryCubePropertyEnum.getByName("CUBOID_TARGET")); + assertEquals(QueryCubePropertyEnum.IF_MATCH, QueryCubePropertyEnum.getByName("IF_MATCH")); + assertEquals(QueryCubePropertyEnum.FILTER_MASK, QueryCubePropertyEnum.getByName("FILTER_MASK")); + assertEquals(QueryCubePropertyEnum.IF_SUCCESS, QueryCubePropertyEnum.getByName("IF_SUCCESS")); + assertEquals(QueryCubePropertyEnum.TIME_SUM, QueryCubePropertyEnum.getByName("STORAGE_CALL_TIME_SUM")); + assertEquals(QueryCubePropertyEnum.TIME_MAX, QueryCubePropertyEnum.getByName("STORAGE_CALL_TIME_MAX")); + assertEquals(QueryCubePropertyEnum.WEIGHT_PER_HIT, QueryCubePropertyEnum.getByName("WEIGHT_PER_HIT")); + assertEquals(QueryCubePropertyEnum.CALL_COUNT, QueryCubePropertyEnum.getByName("STORAGE_CALL_COUNT")); + assertEquals(QueryCubePropertyEnum.SKIP_COUNT, QueryCubePropertyEnum.getByName("STORAGE_COUNT_SKIP")); + assertEquals(QueryCubePropertyEnum.SCAN_COUNT, QueryCubePropertyEnum.getByName("STORAGE_COUNT_SCAN")); + assertEquals(QueryCubePropertyEnum.RETURN_COUNT, QueryCubePropertyEnum.getByName("STORAGE_COUNT_RETURN")); + assertEquals(QueryCubePropertyEnum.AGGR_FILTER_COUNT, + QueryCubePropertyEnum.getByName("STORAGE_COUNT_AGGREGATE_FILTER")); + assertEquals(QueryCubePropertyEnum.AGGR_COUNT, QueryCubePropertyEnum.getByName("STORAGE_COUNT_AGGREGATE")); + assertNull(RecordEvent.RecordReserveKeyEnum.getByKey(null)); + } + + @Test + public void testQueryRPCPropertyEnum() { + assertEquals(QueryRPCPropertyEnum.PROJECT, QueryRPCPropertyEnum.getByName("PROJECT")); + assertEquals(QueryRPCPropertyEnum.REALIZATION, QueryRPCPropertyEnum.getByName("REALIZATION")); + assertEquals(QueryRPCPropertyEnum.RPC_SERVER, QueryRPCPropertyEnum.getByName("RPC_SERVER")); + assertEquals(QueryRPCPropertyEnum.EXCEPTION, QueryRPCPropertyEnum.getByName("EXCEPTION")); + assertEquals(QueryRPCPropertyEnum.CALL_TIME, QueryRPCPropertyEnum.getByName("CALL_TIME")); + assertEquals(QueryRPCPropertyEnum.SKIP_COUNT, QueryRPCPropertyEnum.getByName("COUNT_SKIP")); + assertEquals(QueryRPCPropertyEnum.SCAN_COUNT, QueryRPCPropertyEnum.getByName("COUNT_SCAN")); + assertEquals(QueryRPCPropertyEnum.RETURN_COUNT, QueryRPCPropertyEnum.getByName("COUNT_RETURN")); + assertEquals(QueryRPCPropertyEnum.AGGR_FILTER_COUNT, QueryRPCPropertyEnum.getByName("COUNT_AGGREGATE_FILTER")); + assertEquals(QueryRPCPropertyEnum.AGGR_COUNT, QueryRPCPropertyEnum.getByName("COUNT_AGGREGATE")); + assertNull(RecordEvent.RecordReserveKeyEnum.getByKey(null)); + } + + @Test + public void testTimePropertyEnum() { + assertEquals(TimePropertyEnum.YEAR, TimePropertyEnum.getByKey("KYEAR_BEGIN_DATE")); + assertEquals(TimePropertyEnum.MONTH, TimePropertyEnum.getByKey("KMONTH_BEGIN_DATE")); + assertEquals(TimePropertyEnum.WEEK_BEGIN_DATE, TimePropertyEnum.getByKey("KWEEK_BEGIN_DATE")); + assertEquals(TimePropertyEnum.DAY_DATE, TimePropertyEnum.getByKey("KDAY_DATE")); + assertEquals(TimePropertyEnum.DAY_TIME, TimePropertyEnum.getByKey("KDAY_TIME")); + assertEquals(TimePropertyEnum.TIME_HOUR, TimePropertyEnum.getByKey("KTIME_HOUR")); + assertEquals(TimePropertyEnum.TIME_MINUTE, TimePropertyEnum.getByKey("KTIME_MINUTE")); + assertEquals(TimePropertyEnum.TIME_SECOND, TimePropertyEnum.getByKey("KTIME_SECOND")); + assertNull(RecordEvent.RecordReserveKeyEnum.getByKey(null)); + } + + @Test + public void testRecordReserveKeyEnum() { + assertEquals(RecordEvent.RecordReserveKeyEnum.EVENT_SUBJECT, + RecordEvent.RecordReserveKeyEnum.getByKey("EVENT_TYPE")); + assertEquals(RecordEvent.RecordReserveKeyEnum.ID, RecordEvent.RecordReserveKeyEnum.getByKey("EVENT_ID")); + assertEquals(RecordEvent.RecordReserveKeyEnum.HOST, RecordEvent.RecordReserveKeyEnum.getByKey("HOST")); + assertEquals(RecordEvent.RecordReserveKeyEnum.TIME, RecordEvent.RecordReserveKeyEnum.getByKey("KTIMESTAMP")); + assertNull(RecordEvent.RecordReserveKeyEnum.getByKey(null)); + } +} \ No newline at end of file