-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ISSUE #42] fix the problem HealthExcutor don't doCheck asynchronously #43
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
034b193
fix: let HealthExecutor support async doCheck
Lambert-Rao 403d2d4
chore: move test files out of unit folder
Lambert-Rao 7db1411
chore: add HealthConstant
Lambert-Rao d276bff
chore
Lambert-Rao 03be1d6
style: rewrite description assign in CheckResultCache in if-else
Lambert-Rao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
70 changes: 70 additions & 0 deletions
70
...org/apache/eventmesh/dashboard/console/integration/health/HealthServiceIntegrateTest.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,70 @@ | ||
/* | ||
* 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.eventmesh.dashboard.console.integration.health; | ||
|
||
import java.util.List; | ||
import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity; | ||
import org.apache.eventmesh.dashboard.console.enums.health.HealthCheckType; | ||
import org.apache.eventmesh.dashboard.console.health.CheckResultCache; | ||
import org.apache.eventmesh.dashboard.console.health.HealthService; | ||
import org.apache.eventmesh.dashboard.console.health.check.config.HealthCheckObjectConfig; | ||
import org.apache.eventmesh.dashboard.console.service.health.HealthDataService; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.jdbc.Sql; | ||
|
||
@SpringBootTest | ||
@ActiveProfiles("test") | ||
@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) | ||
public class HealthServiceIntegrateTest { | ||
HealthService healthService = new HealthService(); | ||
|
||
@Autowired | ||
private HealthDataService healthDataService; | ||
|
||
private final CheckResultCache checkResultCache = new CheckResultCache(); | ||
@BeforeEach | ||
void init() { | ||
healthService.createExecutor(healthDataService, checkResultCache); | ||
} | ||
|
||
@Test | ||
void testStorageRedis() throws InterruptedException { | ||
HealthCheckObjectConfig config = new HealthCheckObjectConfig(); | ||
config.setClusterId(1L); | ||
config.setInstanceId(1L); | ||
config.setHealthCheckResourceType("storage"); | ||
config.setHealthCheckResourceSubType("redis"); | ||
config.setConnectUrl("redis://localhost:6379"); | ||
healthService.insertCheckService(config); | ||
healthService.executeAll(); | ||
Thread.sleep(1000); | ||
healthService.executeAll(); | ||
|
||
HealthCheckResultEntity queryEntity = new HealthCheckResultEntity(); | ||
queryEntity.setClusterId(1L); | ||
queryEntity.setType(HealthCheckType.STORAGE.getNumber()); | ||
queryEntity.setTypeId(1L); | ||
List<HealthCheckResultEntity> results = healthDataService.queryHealthCheckResultByClusterIdAndTypeAndTypeId(queryEntity); | ||
Assertions.assertEquals(2,results.size()); | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
oldDesc
should have a\n
at the end?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newdesc
is added afteroldDesc
, just to distinguishThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean like this?
By the way,
Objects.isNull
is intended for use within Java 8 lambda filtering. Just keep the code simple usingwhatever != null
will be better.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's what I mean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then such writting will be better:
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, using a constant is meant to split
oldDesc
andnewDesc
strings. So the following is better:Also, a constant can be referenced by its class name to indicate its usage field, so a
HEALTH_
prefix is unnecessary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if
oldDesc
is an empty string""
, this add anNEW_LINE_ENDING
is the beginning of thedescription
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if-else is acceptable~