Skip to content
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

feat: Integrate testcontainers into the current test environment #2524

Open
wants to merge 26 commits into
base: 2021.x
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7d20332
接入ci以及初始化项目
kaori-seasons May 2, 2022
fa0a109
删除多余测试执行命令
kaori-seasons May 2, 2022
629f70e
整理集成测试环境 编写nacos接入testcontainer用例
kaori-seasons May 2, 2022
2846b05
删除多余类
kaori-seasons May 2, 2022
3e8e1d3
删除多余生成文件
kaori-seasons May 3, 2022
b93ce60
移动接入ci文件夹
kaori-seasons May 3, 2022
bd9d64e
删除多余注释
kaori-seasons May 3, 2022
6f4be1f
clean code
kaori-seasons May 3, 2022
9b349f5
Remove redundant scripts
kaori-seasons May 3, 2022
cd5fd5b
Re-divide unit test modules
kaori-seasons May 15, 2022
8d16b4d
remove pipline
kaori-seasons May 15, 2022
9ddb22b
remove deps
kaori-seasons May 15, 2022
f572889
添加ITcase标准
kaori-seasons Jun 5, 2022
106b11a
添加docker构建以及推送镜像
kaori-seasons Jun 23, 2022
1c39390
fix ci and deploy docker
kaori-seasons Jun 23, 2022
b7465bc
add maven profile and assembly plugin
kaori-seasons Jun 23, 2022
00fa8cf
update cache maven repo
kaori-seasons Jun 23, 2022
223b4b2
update maven command
kaori-seasons Jun 23, 2022
fb412d6
fix Syntax
kaori-seasons Jun 23, 2022
40d3f2e
update version
kaori-seasons Jun 23, 2022
4fe712e
enhance integration test
kaori-seasons Jun 23, 2022
ea9b730
add module && update docker upload repo
kaori-seasons Jun 25, 2022
bbacb01
remove intergration module and move tests
kaori-seasons Jun 25, 2022
3555b45
fix checkstyle && add assembly
kaori-seasons Jun 26, 2022
27f0a02
fix checkstyle
kaori-seasons Jul 17, 2022
3738832
fix NacosAsyncRestTemplateITCase startup error
kaori-seasons Jul 29, 2022
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
Prev Previous commit
Next Next commit
整理集成测试环境 编写nacos接入testcontainer用例
kaori-seasons committed May 2, 2022
commit 629f70e9ceb287cf537b13f822f05a93912a4b8a
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ public NacosConfigManager(NacosConfigProperties nacosConfigProperties) {
/**
* Compatible with old design,It will be perfected in the future.
*/
static ConfigService createConfigService(
public static ConfigService createConfigService(
NacosConfigProperties nacosConfigProperties) {
if (Objects.isNull(service)) {
synchronized (NacosConfigManager.class) {
Original file line number Diff line number Diff line change
@@ -52,6 +52,27 @@
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rocketmq</artifactId>
<version>${revision}</version>
</dependency>

<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-bus-rocketmq</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.alibaba.cloud.integration;

import lombok.Builder;
import lombok.Getter;

@Builder
@Getter
public class NacosConfig {

private String dataId;

private String namespace;

private String group;

private String type;

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2013-2022 the original author or 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
*
* https://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 com.alibaba.cloud.integration;

import java.util.List;
import java.util.Map;

import lombok.Data;

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
*
*
* @author freeman
*/
@Data
public class UserProperties {
private String name;
private Integer age;
private Map<String, Object> map;
private List<User> users;

@Data
public static class User {
private String name;
private Integer age;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package com.alibaba.cloud.integration.common;

import java.nio.ByteBuffer;
import java.util.Objects;

public class KeyValue<K, V> {
private final K key;
private final V value;

public KeyValue(K key, V value) {
this.key = key;
this.value = value;
}

public K getKey() {
return key;
}

public V getValue() {
return value;
}

@Override
public int hashCode() {
return Objects.hash(key, value);
}

@Override
public boolean equals(Object obj) {
if (!(obj instanceof KeyValue)) {
return false;
}
KeyValue<K, V> another = (KeyValue<K, V>) obj;
return Objects.equals(key, another.key)
&& Objects.equals(value, another.value);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("(key = \"")
.append(key)
.append("\", value = \"")
.append(value)
.append("\")");
return sb.toString();
}

/**
* Decoder to decode key/value bytes.
*/
@FunctionalInterface
public interface KeyValueDecoder<K, V> {

/**
* Decode key and value bytes into a {@link KeyValue} pair.
*
* @param keyData key data
* @param valueData value data
* @return the decoded {@link KeyValue} pair
*/
KeyValue<K, V> decode(byte[] keyData, byte[] valueData);

}

/**
* Encode a <tt>key</tt> and <tt>value</tt> pair into a bytes array.
*
* @param key key object to encode
* @param keyWriter a writer to encode key object
* @param value value object to encode
* @param valueWriter a writer to encode value object
* @return the encoded bytes array
*/
public static <K, V> byte[] encode(K key, Schema<K> keyWriter,
V value, Schema<V> valueWriter) {
byte [] keyBytes;
if (key == null) {
keyBytes = new byte[0];
} else {
keyBytes = keyWriter.encode(key);
}

byte [] valueBytes;
if (value == null) {
valueBytes = new byte[0];
} else {
valueBytes = valueWriter.encode(value);
}
ByteBuffer byteBuffer = ByteBuffer.allocate(4 + keyBytes.length + 4 + valueBytes.length);
byteBuffer
.putInt(key == null ? -1 : keyBytes.length)
.put(keyBytes)
.putInt(value == null ? -1 : valueBytes.length)
.put(valueBytes);
return byteBuffer.array();
}

/**
* Decode the value into a key/value pair.
*
* @param data the encoded bytes
* @param decoder the decoder to decode encoded key/value bytes
* @return the decoded key/value pair
*/
public static <K, V> KeyValue<K, V> decode(byte[] data, KeyValueDecoder<K, V> decoder) {
ByteBuffer byteBuffer = ByteBuffer.wrap(data);
int keyLength = byteBuffer.getInt();
byte[] keyBytes = keyLength == -1 ? null : new byte[keyLength];
if (keyBytes != null) {
byteBuffer.get(keyBytes);
}

int valueLength = byteBuffer.getInt();
byte[] valueBytes = valueLength == -1 ? null : new byte[valueLength];
if (valueBytes != null) {
byteBuffer.get(valueBytes);
}

return decoder.decode(keyBytes, valueBytes);
}
}
Loading