This is an automated email from the ASF dual-hosted git repository. wusheng pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push: new 3f176bf [hotfix]Fix UITemplate storage Influxdb implamented (#4849) 3f176bf is described below commit 3f176bf50f66d3d9156eafcecf063c92122d3756 Author: Daming <zt...@foxmail.com> AuthorDate: Tue Jun 2 16:05:21 2020 +0800 [hotfix]Fix UITemplate storage Influxdb implamented (#4849) --- .../query/UITemplateManagementDAOImpl.java | 23 +++----- .../docker/ttl/docker-compose.influxdb.yml | 7 +-- .../apache/skywalking/e2e/storage/StorageE2E.java | 69 +++++++++++----------- .../storage/dashboardConfiguration-change.yml | 2 +- .../storage/dashboardConfiguration-disable.yml | 2 +- .../expected/storage/dashboardConfiguration.yml | 2 +- 6 files changed, 45 insertions(+), 60 deletions(-) diff --git a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/UITemplateManagementDAOImpl.java b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/UITemplateManagementDAOImpl.java index ddc3359..ba2e815 100644 --- a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/UITemplateManagementDAOImpl.java +++ b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/UITemplateManagementDAOImpl.java @@ -85,7 +85,7 @@ public class UITemplateManagementDAOImpl implements UITemplateManagementDAO { Point point = Point.measurement(UITemplate.INDEX_NAME) .tag(InfluxConstants.TagName.ID_COLUMN, uiTemplate.id()) .fields(builder.data2Map(uiTemplate)) - .time(0L, TimeUnit.MILLISECONDS) + .time(1L, TimeUnit.NANOSECONDS) .build(); client.write(point); return TemplateChangeStatus.builder().status(true).build(); @@ -104,8 +104,8 @@ public class UITemplateManagementDAOImpl implements UITemplateManagementDAO { if (Objects.nonNull(series)) { Point point = Point.measurement(UITemplate.INDEX_NAME) .fields(builder.data2Map(uiTemplate)) - .tag(series.getTags()) - .time(0L, TimeUnit.MILLISECONDS) + .tag(InfluxConstants.TagName.ID_COLUMN, uiTemplate.id()) + .time(1L, TimeUnit.NANOSECONDS) .build(); client.write(point); return TemplateChangeStatus.builder().status(true).build(); @@ -118,22 +118,13 @@ public class UITemplateManagementDAOImpl implements UITemplateManagementDAO { public TemplateChangeStatus disableTemplate(final String name) throws IOException { WhereQueryImpl<SelectQueryImpl> query = select().all() .from(client.getDatabase(), UITemplate.INDEX_NAME) - .where(eq(InfluxConstants.NAME, name)); + .where(eq(InfluxConstants.TagName.ID_COLUMN, name)); QueryResult.Series series = client.queryForSingleSeries(query); if (Objects.nonNull(series)) { - List<String> columnNames = series.getColumns(); - List<Object> columnValues = series.getValues().get(0); - - Map<String, Object> storageData = Maps.newHashMap(); - for (int i = 1; i < columnNames.size(); i++) { - storageData.put(columnNames.get(i), columnValues.get(i)); - } - - storageData.put(UITemplate.DISABLED, BooleanUtils.TRUE); Point point = Point.measurement(UITemplate.INDEX_NAME) - .tag(series.getTags()) - .fields(storageData) - .time(0L, TimeUnit.MILLISECONDS) + .tag(InfluxConstants.TagName.ID_COLUMN, name) + .addField(UITemplate.DISABLED, BooleanUtils.TRUE) + .time(1L, TimeUnit.NANOSECONDS) .build(); client.write(point); return TemplateChangeStatus.builder().status(true).build(); diff --git a/test/e2e/e2e-test/docker/ttl/docker-compose.influxdb.yml b/test/e2e/e2e-test/docker/ttl/docker-compose.influxdb.yml index fd7b324..c9ae20d 100644 --- a/test/e2e/e2e-test/docker/ttl/docker-compose.influxdb.yml +++ b/test/e2e/e2e-test/docker/ttl/docker-compose.influxdb.yml @@ -34,12 +34,9 @@ services: service: oap environment: SW_STORAGE: influxdb + SW_STORAGE_ES_BULK_ACTIONS: 1 SW_CORE_DATA_KEEPER_EXECUTE_PERIOD: 1 - SW_CORE_RECORD_DATA_TTL: 7 - SW_CORE_MINUTE_METRIC_DATA_TTL: 6000 - SW_CORE_HOUR_METRIC_DATA_TTL: 100 - SW_CORE_DAY_METRIC_DATA_TTL: 5 - SW_CORE_MONTH_METRIC_DATA_TTL: 4 + SW_STORAGE_ES_FLUSH_INTERVAL: 1 depends_on: influxdb: condition: service_healthy diff --git a/test/e2e/e2e-test/src/test/java/org/apache/skywalking/e2e/storage/StorageE2E.java b/test/e2e/e2e-test/src/test/java/org/apache/skywalking/e2e/storage/StorageE2E.java index f09b778..082e5f9 100644 --- a/test/e2e/e2e-test/src/test/java/org/apache/skywalking/e2e/storage/StorageE2E.java +++ b/test/e2e/e2e-test/src/test/java/org/apache/skywalking/e2e/storage/StorageE2E.java @@ -20,6 +20,7 @@ package org.apache.skywalking.e2e.storage; import java.io.IOException; import java.util.List; +import java.util.concurrent.TimeUnit; import lombok.extern.slf4j.Slf4j; import org.apache.skywalking.e2e.UIConfigurationManagementClient; import org.apache.skywalking.e2e.annotation.ContainerHostAndPort; @@ -170,55 +171,51 @@ public class StorageE2E extends SkyWalkingTestAdapter { @Test void addUITemplate() throws Exception { - try { - TemplateChangeStatus templateChangeStatus = graphql.addTemplate( + assertTrue( + graphql.addTemplate( emptySetting("test-ui-config-1").type(TemplateType.DASHBOARD) - ); - LOGGER.info("add template = {}", templateChangeStatus); - } catch (Exception e) { - LOGGER.error("add ui template error.", e); - } + ).isStatus() + ); + TimeUnit.SECONDS.sleep(2L); + verifyTemplates("expected/storage/dashboardConfiguration.yml"); } @Test void changeTemplate() throws Exception { - try { - final String name = "test-ui-config-2"; - assertTrue( - graphql.addTemplate( - emptySetting(name).type(TemplateType.TOPOLOGY_SERVICE) - ).isStatus() - ); + final String name = "test-ui-config-2"; + assertTrue( + graphql.addTemplate( + emptySetting(name).type(TemplateType.DASHBOARD) + ).isStatus() + ); + TimeUnit.SECONDS.sleep(2L); - TemplateChangeStatus templateChangeStatus = graphql.changeTemplate( - emptySetting(name).configuration("{\"key\":\"value\"}") - ); - LOGGER.info("change UITemplate = {}", templateChangeStatus); - assertTrue(templateChangeStatus.isStatus()); - } catch (Exception e) { - LOGGER.error("add ui template error.", e); - } + TemplateChangeStatus templateChangeStatus = graphql.changeTemplate( + emptySetting(name).type(TemplateType.TOPOLOGY_SERVICE) + ); + LOGGER.info("change UITemplate = {}", templateChangeStatus); + assertTrue(templateChangeStatus.isStatus()); + TimeUnit.SECONDS.sleep(2L); verifyTemplates("expected/storage/dashboardConfiguration-change.yml"); } @Test - void disableTemplate() throws IOException { - try { - final String name = "test-ui-config-3"; - assertTrue( - graphql.addTemplate( - emptySetting(name).type(TemplateType.DASHBOARD) - ).isStatus() - ); + void disableTemplate() throws Exception { + final String name = "test-ui-config-3"; + assertTrue( + graphql.addTemplate( + emptySetting(name).type(TemplateType.DASHBOARD) + ).isStatus() + ); + TimeUnit.SECONDS.sleep(2L); - TemplateChangeStatus templateChangeStatus = graphql.disableTemplate(name); - LOGGER.info("disable template = {}", templateChangeStatus); - assertTrue(templateChangeStatus.isStatus()); - } catch (Exception e) { - LOGGER.error("add ui template error.", e); - } + TemplateChangeStatus templateChangeStatus = graphql.disableTemplate(name); + LOGGER.info("disable template = {}", templateChangeStatus); + assertTrue(templateChangeStatus.isStatus()); + + TimeUnit.SECONDS.sleep(2L); verifyTemplates("expected/storage/dashboardConfiguration-disable.yml"); } diff --git a/test/e2e/e2e-test/src/test/resources/expected/storage/dashboardConfiguration-change.yml b/test/e2e/e2e-test/src/test/resources/expected/storage/dashboardConfiguration-change.yml index 636231b..4cf9684 100644 --- a/test/e2e/e2e-test/src/test/resources/expected/storage/dashboardConfiguration-change.yml +++ b/test/e2e/e2e-test/src/test/resources/expected/storage/dashboardConfiguration-change.yml @@ -16,6 +16,6 @@ configurations: - name: test-ui-config-2 type: TOPOLOGY_SERVICE - configuration: "{}" + configuration: not null activated: true disabled: false diff --git a/test/e2e/e2e-test/src/test/resources/expected/storage/dashboardConfiguration-disable.yml b/test/e2e/e2e-test/src/test/resources/expected/storage/dashboardConfiguration-disable.yml index fb24303..7a8b028 100644 --- a/test/e2e/e2e-test/src/test/resources/expected/storage/dashboardConfiguration-disable.yml +++ b/test/e2e/e2e-test/src/test/resources/expected/storage/dashboardConfiguration-disable.yml @@ -15,7 +15,7 @@ configurations: - name: test-ui-config-3 - type: not null + type: DASHBOARD configuration: not null activated: true disabled: true diff --git a/test/e2e/e2e-test/src/test/resources/expected/storage/dashboardConfiguration.yml b/test/e2e/e2e-test/src/test/resources/expected/storage/dashboardConfiguration.yml index 08a091e..6352b27 100644 --- a/test/e2e/e2e-test/src/test/resources/expected/storage/dashboardConfiguration.yml +++ b/test/e2e/e2e-test/src/test/resources/expected/storage/dashboardConfiguration.yml @@ -15,7 +15,7 @@ configurations: - name: test-ui-config-1 - type: not null + type: DASHBOARD configuration: not null activated: true disabled: false