Skip to content

Commit

Permalink
feat: fix e2e case order and use real zookeeper
Browse files Browse the repository at this point in the history
  • Loading branch information
xjlgod committed Oct 25, 2024
1 parent fd5f1e0 commit ed284a8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static org.apache.seata.util.LogUtils.printProcessLog;
Expand All @@ -35,6 +36,14 @@ public class SkyWalkingController {
public static final int RETRY_MAX_TIMES = 3;
private static final Logger LOGGER = LoggerFactory.getLogger(SkyWalkingController.class);
private String e2eDir;
private static final Map<Character, Integer> caseOrder = new HashMap<>();

public SkyWalkingController() {
caseOrder.put('a', 1);
caseOrder.put('x', 2);
caseOrder.put('t', 3);
caseOrder.put('s', 4);
}

public String getE2eDir() {
return e2eDir;
Expand All @@ -48,7 +57,15 @@ public void runE2ETests() {
File e2eDir = new File(this.e2eDir);
List<String> passedProjects = new ArrayList<>();
File[] files = e2eDir.listFiles();
List<File> filterFiles = Arrays.stream(files).sorted(Comparator.reverseOrder()).collect(Collectors.toList());
// use this order to run saga test first, because saga test is easy to fail
List<File> filterFiles = Arrays.stream(files).sorted((a, b) -> {
int scoreA = caseOrder.getOrDefault(a.getName().charAt(0), 0);
int scoreB = caseOrder.getOrDefault(b.getName().charAt(0), 0);
if (scoreA == scoreB) {
return b.getName().compareTo(a.getName());
}
return scoreB - scoreA;
}).collect(Collectors.toList());
for (File file : filterFiles) {
if (file.isDirectory()) {
LOGGER.info("Running Seate e2e test by SkyWalking-E2E: " + file.getName());
Expand Down
17 changes: 15 additions & 2 deletions tcc-sample/spring-dubbo-seata-tcc/seata-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ e2e:
condition: service_started
environment:
seata.address: seata
zookeeper.address: spring-dubbo-seata-tcc-provider
zookeeper.address: zookeeper
E2E_ENV: open
# provider service
providers:
Expand All @@ -34,9 +34,11 @@ e2e:
depends_on:
seata-server:
condition: service_started
zookeeper:
condition: service_healthy
environment:
seata.address: seata
zookeeper.address: spring-dubbo-seata-tcc-provider
zookeeper.address: zookeeper
E2E_ENV: open
# infrastructure services
infrastructures:
Expand All @@ -50,6 +52,17 @@ e2e:
environment:
SEATA_PORT: 8091
STORE_MODE: file
- name: zookeeper
docker_service:
hostname: zookeeper
image: zookeeper:3.8.4
# ports:
# - "2181:2181"
healthcheck:
test: '[ "CMD", "echo", "ruok", "|", "nc", "localhost", "2181", "|", "grep", "imok" ]'
interval: 30s
timeout: 10s
retries: 3

replace:
- source: e2e-replace/file.conf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import org.apache.curator.test.TestingServer;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.IOException;

import static org.apache.seata.e2e.E2EUtil.isInE2ETest;

public class TccProviderStarter {
Expand All @@ -32,19 +30,19 @@ public static void main(String[] args) throws Exception {
}

protected void start0(String[] args) throws Exception {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (server != null) {
try {
server.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}));


//mock zk server
mockZKServer();
// Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// if (server != null) {
// try {
// server.close();
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// }
// }));
//
//
// //mock zk server
// mockZKServer();

if (isInE2ETest()) {
// wait seata-server
Expand Down

0 comments on commit ed284a8

Please sign in to comment.