committed by
GitHub
12 changed files with 752 additions and 62 deletions
@ -0,0 +1,133 @@ |
|||
/** |
|||
* Copyright © 2016-2022 The Thingsboard Authors |
|||
* |
|||
* Licensed 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.thingsboard.server.dao.timeseries; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.mockito.Answers; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.boot.test.mock.mockito.MockBean; |
|||
import org.springframework.test.context.TestPropertySource; |
|||
import org.springframework.test.context.junit4.SpringRunner; |
|||
import org.thingsboard.server.dao.cassandra.CassandraCluster; |
|||
import org.thingsboard.server.dao.nosql.CassandraBufferedRateReadExecutor; |
|||
import org.thingsboard.server.dao.nosql.CassandraBufferedRateWriteExecutor; |
|||
|
|||
import java.text.ParseException; |
|||
import java.util.List; |
|||
|
|||
import static org.apache.commons.lang3.time.DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT; |
|||
import static org.assertj.core.api.Assertions.assertThat; |
|||
|
|||
@RunWith(SpringRunner.class) |
|||
@SpringBootTest(classes = CassandraBaseTimeseriesDao.class) |
|||
@TestPropertySource(properties = { |
|||
"database.ts.type=cassandra", |
|||
"cassandra.query.ts_key_value_partitioning=DAYS", |
|||
"cassandra.query.use_ts_key_value_partitioning_on_read=false", |
|||
"cassandra.query.ts_key_value_partitions_max_cache_size=100000", |
|||
"cassandra.query.ts_key_value_partitions_cache_stats_enabled=true", |
|||
"cassandra.query.ts_key_value_partitions_cache_stats_interval=60", |
|||
"cassandra.query.ts_key_value_ttl=0", |
|||
"cassandra.query.set_null_values_enabled=false", |
|||
}) |
|||
@Slf4j |
|||
public class CassandraBaseTimeseriesDaoPartitioningDaysAlwaysExistsTest { |
|||
|
|||
@Autowired |
|||
CassandraBaseTimeseriesDao tsDao; |
|||
|
|||
@MockBean(answer = Answers.RETURNS_MOCKS) |
|||
@Qualifier("CassandraCluster") |
|||
CassandraCluster cassandraCluster; |
|||
|
|||
@MockBean |
|||
CassandraBufferedRateReadExecutor cassandraBufferedRateReadExecutor; |
|||
@MockBean |
|||
CassandraBufferedRateWriteExecutor cassandraBufferedRateWriteExecutor; |
|||
|
|||
@Test |
|||
public void testToPartitionsDays() throws ParseException { |
|||
assertThat(tsDao.getPartitioning()).isEqualTo("DAYS"); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-01-01T00:00:00Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-01-01T00:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-02T00:00:00Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-02T00:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-03T00:00:01Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-03T00:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-31T23:59:59Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-31T00:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2023-12-31T23:59:59Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2023-12-31T00:00:00Z").getTime()); |
|||
} |
|||
|
|||
@Test |
|||
public void testCalculatePartitionsDays() throws ParseException { |
|||
long startTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:00:00Z").getTime()); |
|||
long nextTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-12T23:59:59Z").getTime()); |
|||
long endTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-15T00:00:00Z").getTime()); |
|||
log.info("startTs {}, nextTs {}, endTs {}", startTs, nextTs, endTs); |
|||
|
|||
assertThat(tsDao.calculatePartitions(0, 0)).isEqualTo(List.of(0L)); |
|||
assertThat(tsDao.calculatePartitions(0, 1)).isEqualTo(List.of(0L, 1L)); |
|||
|
|||
assertThat(tsDao.calculatePartitions(startTs, startTs)).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:00:00Z").getTime())); |
|||
assertThat(tsDao.calculatePartitions(startTs, nextTs)).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-11T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-12T00:00:00Z").getTime())); |
|||
|
|||
assertThat(tsDao.calculatePartitions(startTs, endTs)).hasSize(6).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-11T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-12T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-13T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-14T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-15T00:00:00Z").getTime())); |
|||
|
|||
long leapStartTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-02-27T00:00:00Z").getTime()); |
|||
long leapEndTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-03-01T00:00:00Z").getTime()); |
|||
assertThat(tsDao.calculatePartitions(leapStartTs, leapEndTs)).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-02-27T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-02-28T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-02-29T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-03-01T00:00:00Z").getTime())); |
|||
|
|||
long newYearStartTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-12-30T00:00:00Z").getTime()); |
|||
long newYearEndTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2021-01-01T00:00:00Z").getTime()); |
|||
assertThat(tsDao.calculatePartitions(newYearStartTs, newYearEndTs)).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-12-30T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-12-31T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2021-01-01T00:00:00Z").getTime())); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,134 @@ |
|||
/** |
|||
* Copyright © 2016-2022 The Thingsboard Authors |
|||
* |
|||
* Licensed 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.thingsboard.server.dao.timeseries; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.mockito.Answers; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.boot.test.mock.mockito.MockBean; |
|||
import org.springframework.test.context.TestPropertySource; |
|||
import org.springframework.test.context.junit4.SpringRunner; |
|||
import org.thingsboard.server.dao.cassandra.CassandraCluster; |
|||
import org.thingsboard.server.dao.nosql.CassandraBufferedRateReadExecutor; |
|||
import org.thingsboard.server.dao.nosql.CassandraBufferedRateWriteExecutor; |
|||
|
|||
import java.text.ParseException; |
|||
import java.util.List; |
|||
|
|||
import static org.apache.commons.lang3.time.DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT; |
|||
import static org.assertj.core.api.Assertions.assertThat; |
|||
|
|||
@RunWith(SpringRunner.class) |
|||
@SpringBootTest(classes = CassandraBaseTimeseriesDao.class) |
|||
@TestPropertySource(properties = { |
|||
"database.ts.type=cassandra", |
|||
"cassandra.query.ts_key_value_partitioning=HOURS", |
|||
"cassandra.query.use_ts_key_value_partitioning_on_read=false", |
|||
"cassandra.query.ts_key_value_partitions_max_cache_size=100000", |
|||
"cassandra.query.ts_key_value_partitions_cache_stats_enabled=true", |
|||
"cassandra.query.ts_key_value_partitions_cache_stats_interval=60", |
|||
"cassandra.query.ts_key_value_ttl=0", |
|||
"cassandra.query.set_null_values_enabled=false", |
|||
}) |
|||
@Slf4j |
|||
public class CassandraBaseTimeseriesDaoPartitioningHoursAlwaysExistsTest { |
|||
|
|||
@Autowired |
|||
CassandraBaseTimeseriesDao tsDao; |
|||
|
|||
@MockBean(answer = Answers.RETURNS_MOCKS) |
|||
@Qualifier("CassandraCluster") |
|||
CassandraCluster cassandraCluster; |
|||
|
|||
@MockBean |
|||
CassandraBufferedRateReadExecutor cassandraBufferedRateReadExecutor; |
|||
@MockBean |
|||
CassandraBufferedRateWriteExecutor cassandraBufferedRateWriteExecutor; |
|||
|
|||
@Test |
|||
public void testToPartitionsHours() throws ParseException { |
|||
assertThat(tsDao.getPartitioning()).isEqualTo("HOURS"); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-01-01T00:00:00Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-01-01T00:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-02T01:00:00Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-02T01:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-03T02:00:01Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-03T02:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-31T23:59:59Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-31T23:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2023-12-31T23:59:59Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2023-12-31T23:00:00Z").getTime()); |
|||
} |
|||
|
|||
@Test |
|||
public void testCalculatePartitionsHours() throws ParseException { |
|||
long startTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:00:00Z").getTime()); |
|||
long nextTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T03:59:59Z").getTime()); |
|||
long endTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-11T00:59:00Z").getTime()); |
|||
log.info("startTs {}, nextTs {}, endTs {}", startTs, nextTs, endTs); |
|||
|
|||
assertThat(tsDao.calculatePartitions(0, 0)).isEqualTo(List.of(0L)); |
|||
assertThat(tsDao.calculatePartitions(0, 1)).isEqualTo(List.of(0L, 1L)); |
|||
|
|||
assertThat(tsDao.calculatePartitions(startTs, startTs)).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:00:00Z").getTime())); |
|||
assertThat(tsDao.calculatePartitions(startTs, nextTs)).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T01:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T02:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T03:00:00Z").getTime())); |
|||
|
|||
assertThat(tsDao.calculatePartitions(startTs, endTs)).hasSize(25).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T01:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T02:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T03:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T04:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T05:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T06:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T07:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T08:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T09:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T10:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T11:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T12:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T13:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T14:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T15:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T16:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T17:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T18:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T19:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T20:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T21:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T22:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T23:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-11T00:00:00Z").getTime())); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,78 @@ |
|||
/** |
|||
* Copyright © 2016-2022 The Thingsboard Authors |
|||
* |
|||
* Licensed 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.thingsboard.server.dao.timeseries; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.junit.Ignore; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.mockito.Answers; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.boot.test.mock.mockito.MockBean; |
|||
import org.springframework.test.context.TestPropertySource; |
|||
import org.springframework.test.context.junit4.SpringRunner; |
|||
import org.thingsboard.server.dao.cassandra.CassandraCluster; |
|||
import org.thingsboard.server.dao.nosql.CassandraBufferedRateReadExecutor; |
|||
import org.thingsboard.server.dao.nosql.CassandraBufferedRateWriteExecutor; |
|||
|
|||
import java.text.ParseException; |
|||
import java.util.List; |
|||
|
|||
import static org.apache.commons.lang3.time.DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT; |
|||
import static org.assertj.core.api.Assertions.assertThat; |
|||
|
|||
@RunWith(SpringRunner.class) |
|||
@SpringBootTest(classes = CassandraBaseTimeseriesDao.class) |
|||
@TestPropertySource(properties = { |
|||
"database.ts.type=cassandra", |
|||
"cassandra.query.ts_key_value_partitioning=INDEFINITE", |
|||
"cassandra.query.use_ts_key_value_partitioning_on_read=false", |
|||
"cassandra.query.ts_key_value_partitions_max_cache_size=100000", |
|||
"cassandra.query.ts_key_value_partitions_cache_stats_enabled=true", |
|||
"cassandra.query.ts_key_value_partitions_cache_stats_interval=60", |
|||
"cassandra.query.ts_key_value_ttl=0", |
|||
"cassandra.query.set_null_values_enabled=false", |
|||
}) |
|||
@Slf4j |
|||
public class CassandraBaseTimeseriesDaoPartitioningIndefiniteAlwaysExistsTest { |
|||
|
|||
@Autowired |
|||
CassandraBaseTimeseriesDao tsDao; |
|||
|
|||
@MockBean(answer = Answers.RETURNS_MOCKS) |
|||
@Qualifier("CassandraCluster") |
|||
CassandraCluster cassandraCluster; |
|||
|
|||
@MockBean |
|||
CassandraBufferedRateReadExecutor cassandraBufferedRateReadExecutor; |
|||
@MockBean |
|||
CassandraBufferedRateWriteExecutor cassandraBufferedRateWriteExecutor; |
|||
|
|||
@Test |
|||
public void testToPartitionsIndefinite() throws ParseException { |
|||
assertThat(tsDao.getPartitioning()).isEqualTo("INDEFINITE"); |
|||
assertThat(tsDao.toPartitionTs(ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-01-01T00:00:00Z").getTime())).isEqualTo(0L); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
public void testCalculatePartitionsIndefinite() throws ParseException { |
|||
//Indefinite partitioning should never call tsDao.calculatePartitions()
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,121 @@ |
|||
/** |
|||
* Copyright © 2016-2022 The Thingsboard Authors |
|||
* |
|||
* Licensed 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.thingsboard.server.dao.timeseries; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.junit.Ignore; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.mockito.Answers; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.boot.test.mock.mockito.MockBean; |
|||
import org.springframework.test.context.TestPropertySource; |
|||
import org.springframework.test.context.junit4.SpringRunner; |
|||
import org.thingsboard.server.dao.cassandra.CassandraCluster; |
|||
import org.thingsboard.server.dao.nosql.CassandraBufferedRateReadExecutor; |
|||
import org.thingsboard.server.dao.nosql.CassandraBufferedRateWriteExecutor; |
|||
|
|||
import java.text.ParseException; |
|||
import java.util.List; |
|||
|
|||
import static org.apache.commons.lang3.time.DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT; |
|||
import static org.assertj.core.api.Assertions.assertThat; |
|||
|
|||
@RunWith(SpringRunner.class) |
|||
@SpringBootTest(classes = CassandraBaseTimeseriesDao.class) |
|||
@TestPropertySource(properties = { |
|||
"database.ts.type=cassandra", |
|||
"cassandra.query.ts_key_value_partitioning=MINUTES", |
|||
"cassandra.query.use_ts_key_value_partitioning_on_read=false", |
|||
"cassandra.query.ts_key_value_partitions_max_cache_size=100000", |
|||
"cassandra.query.ts_key_value_partitions_cache_stats_enabled=true", |
|||
"cassandra.query.ts_key_value_partitions_cache_stats_interval=60", |
|||
"cassandra.query.ts_key_value_ttl=0", |
|||
"cassandra.query.set_null_values_enabled=false", |
|||
}) |
|||
@Slf4j |
|||
public class CassandraBaseTimeseriesDaoPartitioningMinutesAlwaysExistsTest { |
|||
|
|||
@Autowired |
|||
CassandraBaseTimeseriesDao tsDao; |
|||
|
|||
@MockBean(answer = Answers.RETURNS_MOCKS) |
|||
@Qualifier("CassandraCluster") |
|||
CassandraCluster cassandraCluster; |
|||
|
|||
@MockBean |
|||
CassandraBufferedRateReadExecutor cassandraBufferedRateReadExecutor; |
|||
@MockBean |
|||
CassandraBufferedRateWriteExecutor cassandraBufferedRateWriteExecutor; |
|||
|
|||
@Test |
|||
public void testToPartitionsMinutes() throws ParseException { |
|||
assertThat(tsDao.getPartitioning()).isEqualTo("MINUTES"); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-01-01T00:00:00Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-01-01T00:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-02T00:01:00Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-02T00:01:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-03T00:02:01Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-03T00:02:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-31T23:59:59Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-31T23:59:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2023-12-31T23:59:59Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2023-12-31T23:59:00Z").getTime()); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
public void testCalculatePartitionsMinutes() throws ParseException { |
|||
long startTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:00:00Z").getTime()); |
|||
long nextTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:02:59Z").getTime()); |
|||
long endTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:10:00Z").getTime()); |
|||
log.info("startTs {}, nextTs {}, endTs {}", startTs, nextTs, endTs); |
|||
|
|||
assertThat(tsDao.calculatePartitions(0, 0)).isEqualTo(List.of(0L)); |
|||
assertThat(tsDao.calculatePartitions(0, 1)).isEqualTo(List.of(0L, 1L)); |
|||
|
|||
assertThat(tsDao.calculatePartitions(startTs, startTs)).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:00:00Z").getTime())); |
|||
assertThat(tsDao.calculatePartitions(startTs, nextTs)).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:01:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:02:00Z").getTime())); |
|||
|
|||
assertThat(tsDao.calculatePartitions(startTs, endTs)).hasSize(11).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:01:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:02:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:03:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:04:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:05:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:06:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:07:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:08:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:09:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-10-10T00:10:00Z").getTime())); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,134 @@ |
|||
/** |
|||
* Copyright © 2016-2022 The Thingsboard Authors |
|||
* |
|||
* Licensed 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.thingsboard.server.dao.timeseries; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.mockito.Answers; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.boot.test.mock.mockito.MockBean; |
|||
import org.springframework.test.context.TestPropertySource; |
|||
import org.springframework.test.context.junit4.SpringRunner; |
|||
import org.thingsboard.server.dao.cassandra.CassandraCluster; |
|||
import org.thingsboard.server.dao.nosql.CassandraBufferedRateReadExecutor; |
|||
import org.thingsboard.server.dao.nosql.CassandraBufferedRateWriteExecutor; |
|||
|
|||
import java.text.ParseException; |
|||
import java.util.List; |
|||
|
|||
import static org.apache.commons.lang3.time.DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT; |
|||
import static org.assertj.core.api.Assertions.assertThat; |
|||
|
|||
@RunWith(SpringRunner.class) |
|||
@SpringBootTest(classes = CassandraBaseTimeseriesDao.class) |
|||
@TestPropertySource(properties = { |
|||
"database.ts.type=cassandra", |
|||
"cassandra.query.ts_key_value_partitioning=MONTHS", |
|||
"cassandra.query.use_ts_key_value_partitioning_on_read=false", |
|||
"cassandra.query.ts_key_value_partitions_max_cache_size=100000", |
|||
"cassandra.query.ts_key_value_partitions_cache_stats_enabled=true", |
|||
"cassandra.query.ts_key_value_partitions_cache_stats_interval=60", |
|||
"cassandra.query.ts_key_value_ttl=0", |
|||
"cassandra.query.set_null_values_enabled=false", |
|||
}) |
|||
@Slf4j |
|||
public class CassandraBaseTimeseriesDaoPartitioningMonthsAlwaysExistsTest { |
|||
|
|||
@Autowired |
|||
CassandraBaseTimeseriesDao tsDao; |
|||
|
|||
@MockBean(answer = Answers.RETURNS_MOCKS) |
|||
@Qualifier("CassandraCluster") |
|||
CassandraCluster cassandraCluster; |
|||
|
|||
@MockBean |
|||
CassandraBufferedRateReadExecutor cassandraBufferedRateReadExecutor; |
|||
@MockBean |
|||
CassandraBufferedRateWriteExecutor cassandraBufferedRateWriteExecutor; |
|||
|
|||
@Test |
|||
public void testToPartitionsMonths() throws ParseException { |
|||
assertThat(tsDao.getPartitioning()).isEqualTo("MONTHS"); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-01-01T00:00:00Z").getTime())).isEqualTo(1640995200000L).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-01-01T00:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-01T00:00:00Z").getTime())).isEqualTo(1651363200000L).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-01T00:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-01T00:00:01Z").getTime())).isEqualTo(1651363200000L).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-01T00:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-31T23:59:59Z").getTime())).isEqualTo(1651363200000L).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-01T00:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2023-12-31T23:59:59Z").getTime())).isEqualTo(1701388800000L).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2023-12-01T00:00:00Z").getTime()); |
|||
} |
|||
|
|||
@Test |
|||
public void testCalculatePartitionsMonths() throws ParseException { |
|||
long startTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2019-12-12T00:00:00Z").getTime()); |
|||
long nextTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-01-31T23:59:59Z").getTime()); |
|||
long leapTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-02-29T23:59:59Z").getTime()); |
|||
long endTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2021-01-31T23:59:59Z").getTime()); |
|||
log.info("startTs {}, nextTs {}, leapTs {}, endTs {}", startTs, nextTs, leapTs, endTs); |
|||
|
|||
assertThat(tsDao.calculatePartitions(0, 0)).isEqualTo(List.of(0L)); |
|||
assertThat(tsDao.calculatePartitions(0, 1)).isEqualTo(List.of(0L, 1L)); |
|||
|
|||
assertThat(tsDao.calculatePartitions(startTs, startTs)).isEqualTo(List.of(1575158400000L)).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2019-12-01T00:00:00Z").getTime())); |
|||
assertThat(tsDao.calculatePartitions(startTs, nextTs)).isEqualTo(List.of(1575158400000L, 1577836800000L)).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2019-12-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-01-01T00:00:00Z").getTime())); |
|||
|
|||
assertThat(tsDao.calculatePartitions(startTs, leapTs)).isEqualTo(List.of(1575158400000L, 1577836800000L, 1580515200000L)).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2019-12-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-01-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-02-01T00:00:00Z").getTime())); |
|||
|
|||
assertThat(tsDao.calculatePartitions(startTs, endTs)).hasSize(14).isEqualTo(List.of( |
|||
1575158400000L, |
|||
1577836800000L, 1580515200000L, 1583020800000L, |
|||
1585699200000L, 1588291200000L, 1590969600000L, |
|||
1593561600000L, 1596240000000L, 1598918400000L, |
|||
1601510400000L, 1604188800000L, 1606780800000L, |
|||
1609459200000L)).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2019-12-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-01-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-02-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-03-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-04-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-05-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-06-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-07-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-08-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-09-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-10-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-11-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-12-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2021-01-01T00:00:00Z").getTime())); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,116 @@ |
|||
/** |
|||
* Copyright © 2016-2022 The Thingsboard Authors |
|||
* |
|||
* Licensed 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.thingsboard.server.dao.timeseries; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.junit.Ignore; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.mockito.Answers; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.boot.test.mock.mockito.MockBean; |
|||
import org.springframework.test.context.TestPropertySource; |
|||
import org.springframework.test.context.junit4.SpringRunner; |
|||
import org.thingsboard.server.dao.cassandra.CassandraCluster; |
|||
import org.thingsboard.server.dao.nosql.CassandraBufferedRateReadExecutor; |
|||
import org.thingsboard.server.dao.nosql.CassandraBufferedRateWriteExecutor; |
|||
|
|||
import java.text.ParseException; |
|||
import java.util.List; |
|||
|
|||
import static org.apache.commons.lang3.time.DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT; |
|||
import static org.assertj.core.api.Assertions.assertThat; |
|||
|
|||
@RunWith(SpringRunner.class) |
|||
@SpringBootTest(classes = CassandraBaseTimeseriesDao.class) |
|||
@TestPropertySource(properties = { |
|||
"database.ts.type=cassandra", |
|||
"cassandra.query.ts_key_value_partitioning=YEARS", |
|||
"cassandra.query.use_ts_key_value_partitioning_on_read=false", |
|||
"cassandra.query.ts_key_value_partitions_max_cache_size=100000", |
|||
"cassandra.query.ts_key_value_partitions_cache_stats_enabled=true", |
|||
"cassandra.query.ts_key_value_partitions_cache_stats_interval=60", |
|||
"cassandra.query.ts_key_value_ttl=0", |
|||
"cassandra.query.set_null_values_enabled=false", |
|||
}) |
|||
@Slf4j |
|||
public class CassandraBaseTimeseriesDaoPartitioningYearsAlwaysExistsTest { |
|||
|
|||
@Autowired |
|||
CassandraBaseTimeseriesDao tsDao; |
|||
|
|||
@MockBean(answer = Answers.RETURNS_MOCKS) |
|||
@Qualifier("CassandraCluster") |
|||
CassandraCluster cassandraCluster; |
|||
|
|||
@MockBean |
|||
CassandraBufferedRateReadExecutor cassandraBufferedRateReadExecutor; |
|||
@MockBean |
|||
CassandraBufferedRateWriteExecutor cassandraBufferedRateWriteExecutor; |
|||
|
|||
@Test |
|||
public void testToPartitionsYears() throws ParseException { |
|||
assertThat(tsDao.getPartitioning()).isEqualTo("YEARS"); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-01-01T00:00:00Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-01-01T00:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-01T00:00:00Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-01-01T00:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-01T00:00:01Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-01-01T00:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-05-31T23:59:59Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-01-01T00:00:00Z").getTime()); |
|||
assertThat(tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2023-12-31T23:59:59Z").getTime())).isEqualTo( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2023-01-01T00:00:00Z").getTime()); |
|||
} |
|||
|
|||
@Test |
|||
public void testCalculatePartitionsYears() throws ParseException { |
|||
long startTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2019-01-01T00:00:00Z").getTime()); |
|||
long nextTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2021-10-12T23:59:59Z").getTime()); |
|||
long endTs = tsDao.toPartitionTs( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2025-07-15T00:00:00Z").getTime()); |
|||
log.info("startTs {}, nextTs {}, endTs {}", startTs, nextTs, endTs); |
|||
|
|||
assertThat(tsDao.calculatePartitions(0, 0)).isEqualTo(List.of(0L)); |
|||
assertThat(tsDao.calculatePartitions(0, 1)).isEqualTo(List.of(0L, 1L)); |
|||
|
|||
assertThat(tsDao.calculatePartitions(startTs, startTs)).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2019-01-01T00:00:00Z").getTime())); |
|||
assertThat(tsDao.calculatePartitions(startTs, nextTs)).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2019-01-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-01-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2021-01-01T00:00:00Z").getTime())); |
|||
|
|||
assertThat(tsDao.calculatePartitions(startTs, endTs)).hasSize(7).isEqualTo(List.of( |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2019-01-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2020-01-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2021-01-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2022-01-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2023-01-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2024-01-01T00:00:00Z").getTime(), |
|||
ISO_DATETIME_TIME_ZONE_FORMAT.parse("2025-01-01T00:00:00Z").getTime())); |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue