Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

stream update should not require --properties #5785

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 the original author or authors.
* Copyright 2018-2024 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.
Expand Down Expand Up @@ -203,7 +203,7 @@ public Table listPlatforms() {
@ShellMethodAvailability("availableWithModifyRole")
public String updateStream(
@ShellOption(value = { "", "--name" }, help = "the name of the stream", valueProvider = StreamNameValueProvider.class) String name,
@ShellOption(help = "Flattened YAML style properties to update the stream") String properties,
@ShellOption(value = "--properties", help = "Flattened YAML style properties to update the stream", defaultValue = ShellOption.NULL) String properties,
@ShellOption(value = "--propertiesFile", help = "the properties for the stream update (as a File)", defaultValue = ShellOption.NULL) File propertiesFile,
@ShellOption(value = "--packageVersion", help = "the package version of the package to update when using Skipper", defaultValue = ShellOption.NULL) String packageVersion,
@ShellOption(value = "--repoName", help = "the name of the local repository to upload the package when using Skipper", defaultValue = ShellOption.NULL) String repoName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
Expand Down Expand Up @@ -112,6 +112,30 @@ private void doCreate(String streamname, String streamdefinition, boolean deploy
verifyExists(streamname, actualDefinition, deploy);
}

/**
* Update the given stream
*
* @param streamname name of the stream
* @param propertyValue the value to update stream
*
*/
public void update(String streamname, String propertyValue, String expectedResult) {
Object result = commandRunner.executeCommand("stream update --name " + streamname + " --properties " + propertyValue);
assertThat((String)result).contains(expectedResult);
}

/**
* Update the given stream
*
* @param streamname name of the stream
* @param propertyFile the file that contains the properties
*
*/
public void updateFile(String streamname, String propertyFile, String expectedResult) {
Object result = commandRunner.executeCommand("stream update --name " + streamname + " --propertiesFile " + propertyFile);
assertThat((String)result).contains(expectedResult);
}

/**
* Deploy the given stream
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2022 the original author or authors.
* Copyright 2015-2024 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.
Expand All @@ -16,6 +16,7 @@

package org.springframework.cloud.dataflow.shell.command;

import java.io.File;
import java.util.Arrays;

import org.junit.jupiter.api.AfterEach;
Expand All @@ -38,6 +39,7 @@
import org.springframework.shell.table.Table;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.in;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -67,20 +69,48 @@ public void destroyStreams() {

@Test
public void testStreamLifecycleForTickTock() throws InterruptedException {
logger.info("Starting Stream Test for TickTock");
Thread.sleep(2000);
String streamName = generateUniqueStreamOrTaskName();
Info info = new Info();
Status status = new Status();
status.setStatusCode(StatusCode.UNKNOWN);
status.setPlatformStatus(null);
info.setStatus(status);
when(skipperClient.status(ArgumentMatchers.anyString())).thenReturn(setupBaseTest());
AppDeployer appDeployer = applicationContext.getBean(AppDeployer.class);
Deployer deployer = new Deployer("testDeployer", "testType", appDeployer, mock(ActuatorOperations.class));
when(skipperClient.listDeployers()).thenReturn(Arrays.asList(deployer));
stream().create(streamName, "time | log");
}

when(skipperClient.status(ArgumentMatchers.anyString())).thenReturn(info);
@Test
public void testStreamUpdateForTickTock() throws InterruptedException {
String streamName = generateUniqueStreamOrTaskName();

when(skipperClient.status(ArgumentMatchers.anyString())).thenReturn(setupBaseTest());
AppDeployer appDeployer = applicationContext.getBean(AppDeployer.class);
Deployer deployer = new Deployer("testDeployer", "testType", appDeployer, mock(ActuatorOperations.class));
when(skipperClient.listDeployers()).thenReturn(Arrays.asList(deployer));
stream().create(streamName, "time | log");
stream().update(streamName, "version.log=3.2.1","Update request has been sent for the stream");
}

@Test
public void testStreamUpdatePropFileForTickTock() throws InterruptedException {
String streamName = generateUniqueStreamOrTaskName();

when(skipperClient.status(ArgumentMatchers.anyString())).thenReturn(setupBaseTest());
AppDeployer appDeployer = applicationContext.getBean(AppDeployer.class);
Deployer deployer = new Deployer("testDeployer", "testType", appDeployer, mock(ActuatorOperations.class));
when(skipperClient.listDeployers()).thenReturn(Arrays.asList(deployer));
stream().create(streamName, "time | log");
File resourcesDirectory = new File("src/test/resources");
stream().updateFile(streamName, resourcesDirectory.getAbsolutePath() + "/myproperties.properties","Update request has been sent for the stream");
}

private Info setupBaseTest() throws InterruptedException {
logger.info("Starting Stream Test for TickTock Update");
Thread.sleep(2000);
Info info = new Info();
Status status = new Status();
status.setStatusCode(StatusCode.UNKNOWN);
status.setPlatformStatus(null);
info.setStatus(status);
return info;
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version.log=3.2.1
Loading