Skip to content

Commit f21b7ef

Browse files
committed
adjust CI config to use new make targets; fix imports for SDK v1/v2 compatibility
1 parent 2b99466 commit f21b7ef

File tree

7 files changed

+25
-26
lines changed

7 files changed

+25
-26
lines changed

Diff for: .travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ install:
1515

1616
script:
1717
- set -e
18+
- nohup docker pull localstack/localstack > /dev/null &
19+
- make compile
1820
- mvn -q -DskipTests test
19-
- docker pull localstack/localstack-light > /dev/null
20-
- docker tag localstack/localstack-light localstack/localstack
2121
- make test
2222
- docker ps -a
2323

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build: ## Build the code using Maven
77
mvn -Pfatjar $(ADDITIONAL_MVN_ARGS) clean javadoc:jar source:jar package $(ADDITIONAL_MVN_TARGETS)
88

99
compile:
10-
mvn -Pawssdkv1,awssdkv2 -DskipTests compile test-compile
10+
mvn -Pawssdkv1,awssdkv2 $(ADDITIONAL_MVN_ARGS) -DskipTests compile test-compile
1111

1212
publish-maven: ## Publish artifacts to Maven Central
1313
ADDITIONAL_MVN_TARGETS=deploy ADDITIONAL_MVN_ARGS="-DskipTests" make build

Diff for: pom.xml

+8-6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@
8787
<scope>provided</scope>
8888
</dependency>
8989

90+
<!-- core AWS libs (independent of v1/v2 SDK) -->
91+
<dependency>
92+
<groupId>com.amazonaws</groupId>
93+
<artifactId>aws-lambda-java-core</artifactId>
94+
<version>${lambda.core.version}</version>
95+
<scope>provided</scope>
96+
</dependency>
97+
9098
<!-- required to build on java 9+ -->
9199
<dependency>
92100
<groupId>javax.xml.bind</groupId>
@@ -206,12 +214,6 @@
206214
</exclusion>
207215
</exclusions>
208216
</dependency>
209-
<dependency>
210-
<groupId>com.amazonaws</groupId>
211-
<artifactId>aws-lambda-java-core</artifactId>
212-
<version>${lambda.core.version}</version>
213-
<scope>provided</scope>
214-
</dependency>
215217
<dependency>
216218
<groupId>com.amazonaws</groupId>
217219
<artifactId>aws-lambda-java-events</artifactId>

Diff for: src/main/java/cloud/localstack/docker/Container.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ public int getExternalPortFor(int internalPort) {
125125
.map(PortMapping::getExternalPort)
126126
.findFirst().orElse(null);
127127

128-
if (externalPort == null && internalPort == Localstack.DEFAULT_EDGE_PORT) {
128+
if (externalPort != null) {
129+
return externalPort;
130+
}
131+
if (internalPort == Localstack.DEFAULT_EDGE_PORT) {
129132
return internalPort;
130133
}
131134

Diff for: src/test/java/cloud/localstack/awssdkv2/KinesisSchedulerTest.java

-3
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,13 @@ public Scheduler createScheduler(ConfigsBuilder configsBuilder) {
7878
public void createStream(KinesisAsyncClient kinesisClient) throws Exception {
7979
CreateStreamRequest request = CreateStreamRequest.builder().streamName(streamName).shardCount(1).build();
8080
CreateStreamResponse response = kinesisClient.createStream(request).get();
81-
8281
Assert.assertNotNull(response);
8382
}
8483

8584
public void putRecord(KinesisAsyncClient kinesisClient) throws Exception {
86-
System.out.println("PUTTING RECORD");
8785
PutRecordRequest request = PutRecordRequest.builder().partitionKey("partitionkey").streamName(streamName)
8886
.data(SdkBytes.fromUtf8String(testMessage)).build();
8987
PutRecordResponse response = kinesisClient.putRecord(request).get();
90-
9188
Assert.assertNotNull(response);
9289
}
9390

Diff for: src/test/java/cloud/localstack/awssdkv2/consumer/DeliveryStatusProcessor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void processRecords(ProcessRecordsInput processRecordsInput) {
3636
}
3737

3838
public void processRecord(KinesisClientRecord record) throws IOException {
39-
LOG.info("RECORD PROCESSING");
39+
LOG.info("Processing record: " + record);
4040
this.eventProcessor.RECORD_RECEIVED = true;
4141
byte[] message = new byte[record.data().remaining()];
4242
record.data().get(message);

Diff for: src/test/java/cloud/localstack/utils/LocalTestUtil.java

+9-12
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,29 @@
99
import java.util.zip.ZipEntry;
1010
import java.util.zip.ZipOutputStream;
1111

12-
import com.amazonaws.services.lambda.runtime.events.SQSEvent;
1312
import lombok.val;
1413
import org.apache.commons.io.IOUtils;
1514

16-
import com.amazonaws.services.kinesis.model.Record;
17-
import com.amazonaws.services.lambda.model.FunctionCode;
18-
import software.amazon.awssdk.core.SdkBytes;
19-
2015
/**
2116
* Utility methods used for the LocalStack unit and integration tests.
2217
*
2318
* @author Waldemar Hummer
2419
*/
2520
public class LocalTestUtil {
2621

27-
public static FunctionCode createFunctionCode(Class<?> clazz) throws Exception {
28-
val code = new FunctionCode();
29-
code.setZipFile(createFunctionByteBuffer(clazz));
22+
public static com.amazonaws.services.lambda.model.FunctionCode createFunctionCode(Class<?> clazz) throws Exception {
23+
val code = new com.amazonaws.services.lambda.model.FunctionCode();
24+
code.setZipFile(createFunctionByteBuffer(clazz, false));
3025
return code;
3126
}
3227

3328
public static software.amazon.awssdk.services.lambda.model.FunctionCode createFunctionCodeSDKV2(Class<?> clazz) throws Exception{
3429
val codeBuilder = software.amazon.awssdk.services.lambda.model.FunctionCode.builder();
35-
codeBuilder.zipFile(SdkBytes.fromByteBuffer(createFunctionByteBuffer(clazz)));
30+
codeBuilder.zipFile(software.amazon.awssdk.core.SdkBytes.fromByteBuffer(createFunctionByteBuffer(clazz, true)));
3631
return codeBuilder.build();
3732
}
3833

39-
private static ByteBuffer createFunctionByteBuffer(Class<?> clazz) throws Exception{
34+
private static ByteBuffer createFunctionByteBuffer(Class<?> clazz, boolean sdkv2) throws Exception{
4035
ByteArrayOutputStream zipOut = new ByteArrayOutputStream();
4136
ByteArrayOutputStream jarOut = new ByteArrayOutputStream();
4237
// create zip file
@@ -46,8 +41,10 @@ private static ByteBuffer createFunctionByteBuffer(Class<?> clazz) throws Except
4641

4742
// write class files into jar stream
4843
addClassToJar(clazz, jarStream);
49-
addClassToJar(Record.class, jarStream);
50-
addClassToJar(SQSEvent.class, jarStream);
44+
if (!sdkv2) {
45+
addClassToJar(com.amazonaws.services.kinesis.model.Record.class, jarStream);
46+
addClassToJar(com.amazonaws.services.lambda.runtime.events.SQSEvent.class, jarStream);
47+
}
5148
// write MANIFEST into jar stream
5249
JarEntry mfEntry = new JarEntry("META-INF/MANIFEST.MF");
5350
jarStream.putNextEntry(mfEntry);

0 commit comments

Comments
 (0)