Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8cde0b2
Sdk springcloud (#3)
damonxue Aug 17, 2023
f349d5d
Merge branch 'master' into sdk_springcloud_1
damonxue Aug 18, 2023
79031de
Merge branch 'master' into sdk_springcloud_1
damonxue Aug 18, 2023
084d032
consumer rollback.
damonxue Aug 18, 2023
d00c7a2
Merge branch 'master' into sdk_springcloud_1
damonxue Aug 18, 2023
a5bbd75
consumer rollback +1.
damonxue Aug 18, 2023
eb96862
test.
damonxue Aug 18, 2023
6f5420c
test + 1.
damonxue Aug 18, 2023
ce07c9d
Merge remote-tracking branch 'shenyu/master' into sdk_springcloud_1
damonxue Aug 18, 2023
2e2501b
add disk info log.
damonxue Aug 18, 2023
84199dd
v1 setup-java.
damonxue Aug 18, 2023
7599855
Merge branch 'master' into sdk_springcloud_1
li-keguo Aug 19, 2023
96a1d28
Merge branch 'master' into sdk_springcloud_1
damonxue Aug 21, 2023
9dab5a7
refactor discovery client init.
damonxue Aug 21, 2023
71d8236
Under the client capability to each contextId.
damonxue Aug 21, 2023
ee8fd11
Merge branch 'master' into sdk_springcloud_1
damonxue Aug 21, 2023
57b4e62
Under the client capability to each contextId + 1.
damonxue Aug 21, 2023
b8f759e
Under the client capability to each contextId + 2.
damonxue Aug 21, 2023
f135053
change capability to singleton.
damonxue Aug 21, 2023
2d2a1f5
rename package and module name springcloud 2 feign.
damonxue Aug 22, 2023
6ef4355
rename package and module name springcloud 2 feign + 1.
damonxue Aug 22, 2023
1270646
rename package and module name springcloud 2 feign + 2.
damonxue Aug 22, 2023
64c9422
refactor starter module.
damonxue Aug 22, 2023
0f09d46
refactor starter module + 1.
damonxue Aug 22, 2023
0d556ef
Merge branch 'master' into sdk_springcloud_1
damonxue Aug 23, 2023
e2a49ab
fix ci.
damonxue Aug 23, 2023
a4ae50e
fix ci +1.
damonxue Aug 23, 2023
190ac8c
fix ci +2.
damonxue Aug 23, 2023
0bb61c8
fix ci +3.
damonxue Aug 23, 2023
57ab629
fix ci + 4.
damonxue Aug 23, 2023
e5da3c2
Merge branch 'master' into sdk_springcloud_1
moremind Aug 24, 2023
cbf3daa
change datasync config 2 static.
damonxue Aug 24, 2023
000e84c
try fix ci.
damonxue Aug 24, 2023
8043a49
try fix ci +1.
damonxue Aug 24, 2023
42e03fa
try fix ci + 2.
damonxue Aug 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ jobs:
if: steps.filter.outputs.changed == 'true'
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: maven
- name: Build with Maven
if: steps.filter.outputs.changed == 'true'
run: ./mvnw -B clean install -Prelease
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
cache: maven

- name: Build shenyu-e2e-engine with Maven
run: ./mvnw -B -f ./shenyu-e2e/pom.xml -am -pl shenyu-e2e-engine clean install
run: ./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-engine -am clean install

- name: Upload Docker Image Artifacts
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -140,7 +140,7 @@ jobs:
storage: ${{ matrix.storage }}
run: |
bash ./shenyu-e2e/script/storage_init.sh
./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-case/shenyu-e2e-case-http -Dstorage=${{ matrix.storage }} test
./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-case/shenyu-e2e-case-http -am -Dstorage=${{ matrix.storage }} test

e2e-case:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -193,7 +193,7 @@ jobs:
storage: mysql
run: |
bash ./shenyu-e2e/script/storage_init.sh
./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-case/${{ matrix.case }} -Dstorage=mysql test
./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-case/${{ matrix.case }} -am -Dstorage=mysql test

e2e-alibaba-dubbo:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -251,7 +251,7 @@ jobs:
storage: mysql
run: |
bash ./shenyu-e2e/script/storage_init.sh
./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-case/shenyu-e2e-case-alibaba-dubbo -Dstorage=mysql test
./mvnw -B -f ./shenyu-e2e/pom.xml -pl shenyu-e2e-case/shenyu-e2e-case-alibaba-dubbo -am -Dstorage=mysql test

requirement:
name: e2e
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/integrated-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true
# Copied from https://github.com/jens-maus/RaspberryMatic/blob/ea6b8ce0dd2d53ea88b2766ba8d7f8e1d667281f/.github/workflows/ci.yml#L34-L40
# and https://github.com/actions/virtual-environments/issues/709#issuecomment-612569242
- name: Free disk space
run: |
df --human-readable
sudo apt clean
docker rmi $(docker image ls --all --quiet)
rm --recursive --force "$AGENT_TOOLSDIRECTORY"
df --human-readable
- uses: dorny/paths-filter@v2
id: filter
with:
Expand Down Expand Up @@ -79,6 +88,9 @@ jobs:
- name: Wait for docker compose start up completely
if: steps.filter.outputs.changed == 'true'
run: bash ./shenyu-integrated-test/${{ matrix.case }}/script/healthcheck.sh
- name: Disk space info
run: |
df --human-readable
- name: Run test
id: test
if: steps.filter.outputs.changed == 'true'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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.shenyu.common.enums;

/**
* The http scheme enum.
*/
public enum HttpSchemeEnum {

/**
* The http schema enum.
*/
HTTP("http"),

/**
* The https schema enum.
*/
HTTPS("https");

private final String scheme;

HttpSchemeEnum(final String scheme) {
this.scheme = scheme;
}

/**
* get schema.
* @return String
*/
public String getScheme() {
return scheme;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,30 @@
* Gateway DataSyn Handler.
*/
public class DataSyncHandler {

private static final Map<String, Map<String, Object>> DATA_SYNC_MAP = new HashMap<>();

private static final Map<String, Object> ADMIN_WEBSOCKET_MAP = new HashMap<>();

private static final Map<String, Object> GATEWAY_WEBSOCKET_MAP = new HashMap<>();

private static final Map<String, Object> ZOOKEEPER_MAP = new HashMap<>();

private static final Map<String, Object> ADMIN_APOLLO_MAP = new HashMap<>();

private static final Map<String, Object> GATEWAY_APOLLO_MAP = new HashMap<>();

private static final Map<String, Object> ADMIN_HTTP_MAP = new HashMap<>();

private static final Map<String, Object> GATEWAY_HTTP_MAP = new HashMap<>();

private static final Map<String, Object> NACOS_MAP = new HashMap<>();

private static final Map<String, Object> ACM_MAP = new HashMap<>();

private static final Map<String, Object> ETCD_MAP = new HashMap<>();

/**
* init data sync handler.
*/
public static void init() {
DATA_SYNC_MAP.put("admin_websocket", ADMIN_WEBSOCKET_MAP);
DATA_SYNC_MAP.put("gateway_websocket", GATEWAY_WEBSOCKET_MAP);
DATA_SYNC_MAP.put("zookeeper", ZOOKEEPER_MAP);
DATA_SYNC_MAP.put("admin_apollo", ADMIN_APOLLO_MAP);
DATA_SYNC_MAP.put("gateway_apollo", GATEWAY_APOLLO_MAP);
DATA_SYNC_MAP.put("admin_http", ADMIN_HTTP_MAP);
DATA_SYNC_MAP.put("gateway_http", GATEWAY_HTTP_MAP);
DATA_SYNC_MAP.put("nacos", NACOS_MAP);
DATA_SYNC_MAP.put("etcd", ETCD_MAP);

static {
ADMIN_WEBSOCKET_MAP.put("enabled", "true");
GATEWAY_WEBSOCKET_MAP.put("urls", "ws://admin:9095/websocket");

Expand Down Expand Up @@ -98,8 +85,18 @@ public static void init() {
GATEWAY_APOLLO_MAP.put("namespace", "application");

ETCD_MAP.put("url", "http://etcd:2379");

DATA_SYNC_MAP.put("admin_websocket", ADMIN_WEBSOCKET_MAP);
DATA_SYNC_MAP.put("gateway_websocket", GATEWAY_WEBSOCKET_MAP);
DATA_SYNC_MAP.put("zookeeper", ZOOKEEPER_MAP);
DATA_SYNC_MAP.put("admin_apollo", ADMIN_APOLLO_MAP);
DATA_SYNC_MAP.put("gateway_apollo", GATEWAY_APOLLO_MAP);
DATA_SYNC_MAP.put("admin_http", ADMIN_HTTP_MAP);
DATA_SYNC_MAP.put("gateway_http", GATEWAY_HTTP_MAP);
DATA_SYNC_MAP.put("nacos", NACOS_MAP);
DATA_SYNC_MAP.put("etcd", ETCD_MAP);
}

/**
* get data sync map.
* @param dataSyn dataSyn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import java.util.HashMap;
import junit.framework.AssertionFailedError;
import org.apache.shenyu.e2e.client.ExternalServiceClient;
import org.apache.shenyu.e2e.client.admin.AdminClient;
Expand Down Expand Up @@ -67,7 +68,7 @@ public class DockerServiceCompose implements ServiceCompose {
private final DockerComposeContainer<?> container;

private final DockerConfigure configure;

private final DockerServiceConfigure adminConfigure;

private final DockerServiceConfigure gatewayConfigure;
Expand All @@ -79,29 +80,28 @@ public DockerServiceCompose(final DockerConfigure configure) {
this.adminConfigure = configure.getAdmin();
this.gatewayConfigure = configure.getGateway();
modifyGatewayConfiguration(this.gatewayConfigure);
DataSyncHandler.init();
chooseDataSyn(GATEWAY_YML_LOCATION, this.gatewayConfigure);
chooseDataSyn(ADMIN_YML_LOCATION, this.adminConfigure);
DockerComposeFile parsedDockerComposeFile = DockerComposeFile.parse(configure.getDockerComposeFile());
container = new DockerComposeContainer<>("e2e", parsedDockerComposeFile.getFile());
List<String> services = parsedDockerComposeFile.getServices();
services.forEach(name -> container.withLogConsumer(name, new ShenYuLogConsumer(name)));
}

/**
* start.
*/
@Override
public void start() {
exposedServices();
waitingForAvailable();

container.start();

NamingResolver.INSTANCE.ofDockerConfigure(container);
printServices();
}

private void exposedServices() {
Builder<DockerServiceConfigure> builder = ImmutableList.<DockerServiceConfigure>builder()
.addAll(configure.getExternalServices());
Expand All @@ -112,12 +112,12 @@ private void exposedServices() {
builder.add(gatewayConfigure);
}
externalServiceConfigurations = builder.build();

externalServiceConfigurations.stream()
.filter(conf -> conf.getPort() > 1024)
.forEach(conf -> container.withExposedService(conf.getServiceName(), conf.getPort()));
}

private void waitingForAvailable() {
if (Objects.nonNull(adminConfigure)) {
container.waitingFor(
Expand All @@ -131,9 +131,9 @@ private void waitingForAvailable() {
WaitingForStrategies.newGatewayStrategy(gatewayConfigure.getPort())
);
}

}

private void printServices() {
TableView tableView = new TableView("service name", "container port", "mapped host port");
for (DockerServiceConfigure serviceConfigure : externalServiceConfigurations) {
Expand All @@ -145,44 +145,44 @@ private void printServices() {
tableView.addRow(serviceConfigure.getServiceName(), binding.split(":"));
}
}

if (serviceConfigure.getPort() > 1024) {
Integer hostPort = container.getServicePort(serviceConfigure.getServiceName(), serviceConfigure.getPort());
tableView.addRow(serviceConfigure.getServiceName(), serviceConfigure.getPort(), hostPort);
}
}
log.info(System.lineSeparator() + tableView.printAsString() + System.lineSeparator());

if (Objects.isNull(adminConfigure) && Objects.isNull(gatewayConfigure)) {
log.warn("configure of shenyu-admin or shenyu-bootstrap(gateway) has not seen");
}
}

private String getAdminBaseUrl() {
return getBaseUrlByService(adminConfigure);
}

private String getGatewayBaseUrl() {
return getBaseUrlByService(gatewayConfigure);
}

private String getBaseUrlByService(final DockerServiceConfigure configure) {
return configure.getSchema() + "://"
+ container.getServiceHost(configure.getServiceName(), configure.getPort())
+ ":"
+ container.getServicePort(configure.getServiceName(), configure.getPort());
}

@Override
public GatewayClient newGatewayClient(final String scenarioId) {
return new GatewayClient(scenarioId, getGatewayBaseUrl(), gatewayConfigure.getProperties());
}

@Override
public AdminClient newAdminClient(final String scenarioId) {
return new AdminClient(scenarioId, getAdminBaseUrl(), adminConfigure.getProperties());
}

@Override
public ExternalServiceClient newExternalServiceClient(final String externalServiceName) {
DockerServiceConfigure dockerServiceConfigure = configure.getExternalServices().stream()
Expand All @@ -192,7 +192,7 @@ public ExternalServiceClient newExternalServiceClient(final String externalServi
String url = getBaseUrlByService(dockerServiceConfigure);
return new ExternalServiceClient(url, dockerServiceConfigure.getProperties());
}

/**
* stop.
*/
Expand Down Expand Up @@ -279,19 +279,18 @@ private void chooseDataSyn(final String path, final DockerServiceConfigure docke
Yaml yaml = new Yaml();
Map<String, Object> yamlData = yaml.load(inputStream);
Map<String, Object> shenyuParameter = (Map<String, Object>) yamlData.get("shenyu");
Map<String, Object> parameter = (Map<String, Object>) shenyuParameter.get("sync");
Map<String, Object> subParameters = DataSyncHandler.getDataSynMap(dockerServiceConfigure.getProperties().getProperty("dataSyn"));
Map<String, Object> subParameters = DataSyncHandler.getDataSynMap(value);
String synMethod = "";
if (dockerServiceConfigure.getProperties().getProperty("dataSyn").contains("_")) {
synMethod = dockerServiceConfigure.getProperties().getProperty("dataSyn").split("_")[1];
if (value.contains("_")) {
synMethod = value.split("_")[1];
} else {
synMethod = dockerServiceConfigure.getProperties().getProperty("dataSyn");
synMethod = value;
}
Map<String, Object> parameter = new HashMap<>(1);
parameter.put(synMethod, subParameters);
shenyuParameter.put("sync", parameter);
log.info("--- " + subParameters.toString() + " ---");
log.info("--- " + synMethod.toString() + " ---");
String finalSynMethod = synMethod;
parameter.keySet().removeIf(key -> !key.equals(finalSynMethod));
log.info("--- " + synMethod + " ---");
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setExplicitStart(true);
Expand Down
8 changes: 6 additions & 2 deletions shenyu-examples/shenyu-examples-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</modules>

<properties>
<shenyu-sdk.version>2.6.1-SNAPSHOT</shenyu-sdk.version>
<shenyu-sdk.version>${project.version}</shenyu-sdk.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -65,7 +65,11 @@
<artifactId>shenyu-spring-boot-starter-sdk</artifactId>
<version>${shenyu-sdk.version}</version>
</dependency>

<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-sdk-feign</artifactId>
<version>${shenyu-sdk.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-sdk</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
Expand Down
Loading