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

update required properties to 2023 version of ubuntu for openstack and ec2 #319

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
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
74 changes: 0 additions & 74 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,77 +31,3 @@ jobs:
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: org.opentosca.container.reporting/target/site/jacoco-aggregate/jacoco.xml

tests:
strategy:
matrix:
test:
- AdaptMultiMyTinyToDoIntegrationTest
- ApacheWebAppIntegrationTest
- ConnectToIntegrationTest
- MigrateMyTinyToDo2MultiMyTinyToDoIntegrationTest
- MultiMyTinyToDoIntegrationTest
- MyTinyToDoBPMNIntegrationTest
- MyTinyToDoIntegrationTest
#- MyTinyToDoSqlIntegrationTest
#- PlanQKServiceIntegrationTest
- QHAnaTest
runs-on: ubuntu-latest
timeout-minutes: 80
needs: build

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
cache: maven
distribution: temurin
- name: Check out TOSCA internal repository
uses: actions/checkout@v3
with:
repository: OpenTOSCA/tosca-definitions-test-applications
ref: 'main'
path: 'tosca-definitions-test-applications'
lfs: 'true'
- name: Copy TOSCA internal repository to tmp
run: cp -R $GITHUB_WORKSPACE/tosca-definitions-test-applications /tmp/
- name: Show TOSCA internal repository content
run: ls -a /tmp/tosca-definitions-test-applications
- name: Setup Docker Remote API
run: sudo sed -ie "s@ExecStart=\/usr\/bin\/dockerd -H fd:\/\/@ExecStart=\/usr\/bin\/dockerd -H fd:\/\/ -H tcp:\/\/0.0.0.0:2375 -H unix:///var/run/docker.sock@g" /lib/systemd/system/docker.service
- name: Reload Daemons
run: sudo systemctl daemon-reload
- name: Restart Docker
run: sudo service docker restart
- name: Configure runtime with test properties
run: cp test.properties ./org.opentosca.container.core/src/main/resources/application.properties
- name: Show application properties
run: cat ./org.opentosca.container.core/src/main/resources/application.properties
- name: Test Docker Remote API
run: curl -X GET http://localhost:2375/images/json
- name: Start test environment
run: docker-compose -f test.yml up -d
- name: Save engine-ia-java17 log to file
run: docker-compose -f test.yml logs -f engine-ia-java17 > engine-ia-java17.log &
- name: Save engine-ia-java8 log to file
run: docker-compose -f test.yml logs -f engine-ia-java8 > engine-ia-java8.log &
- name: Sleep for 120 seconds
uses: whatnick/wait-action@master
with:
time: '120s'
- name: Test with Maven
timeout-minutes: 60
run: mvn -B -DfailIfNoTests=false -Dtest=org.opentosca.container.war.tests.${{ matrix.test }} test --file pom.xml --fail-at-end
env:
PlanqkApiKey: ${{ secrets.PLANQK_API_KEY }}
OrganizationID: "eecfa1d7-5f52-45d4-accc-b470ad05959f"
- name: Store engine-ia log
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: engine-ia-log
path: |
engine-ia-java17.log
engine-ia-java8.log
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN rm /dev/random && ln -s /dev/urandom /dev/random
WORKDIR /tmp/opentosca/container
COPY . /tmp/opentosca/container

RUN apt-get update && apt-get -y install --no-install-recommends unzip=6.0-26ubuntu3
RUN apt-get update && apt-get -y install --no-install-recommends unzip
RUN mvn package -DskipTests=true -Dmaven.javadoc.skip=true -B \
&& mkdir /tmp/build \
&& unzip /tmp/opentosca/container/org.opentosca.container.war/target/OpenTOSCA-container.war -d /tmp/build/container
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package org.opentosca.bus.management.deployment.plugin.tomcat;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -319,7 +327,22 @@ private File getWarFile(final URL warURL) {
// store WAR artifact as temporary file
final File tempFile = File.createTempFile("Artifact", ".war");
tempFile.deleteOnExit();
FileUtils.copyURLToFile(warURL, tempFile);

URLConnection urlConn = warURL.openConnection();
urlConn.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7");
urlConn.setRequestProperty("Accept-Encoding", "gzip, deflate");
urlConn.setRequestProperty("Accept-Language", "de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7");
urlConn.setRequestProperty("Accept-Charset", "UTF-8");
InputStream stream = urlConn.getInputStream();
OutputStream os = new FileOutputStream(tempFile);
byte[] buffer = new byte[4096];
int len;
while ((len = stream.read(buffer)) != -1) {
os.write(buffer, 0, len);
}
os.close();
stream.close();

return tempFile;
} catch (final IOException e) {
LOG.error("Failed to retrieve WAR-File: {}", e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,17 @@ private TNodeTemplate getNodeTemplate(Message message, Csar csar, TRelationshipT
* @param operation The script service operation to check
*/
private void addOutputParametersToResultMap(final Map<String, String> resultMap, final Object result, final TOperation operation) throws UnsupportedEncodingException {
LOG.debug("Checking if operation has output parameters to update: {}", operation.getName());
final boolean hasOutputParams = operation.getOutputParameters() != null;
if (!hasOutputParams) {
LOG.debug("No output parameters defined!");
return;
}
LOG.debug("Adding output parameters to the response message.");
if (!(result instanceof HashMap<?, ?>)) {
LOG.warn("Result of type {} not supported. The bus should return a HashMap as result class when it is used as input.", result.getClass());
return;
}
LOG.debug("Adding output parameters to the response message.");
final Map<?, ?> resultHashMap = (HashMap<?, ?>) result;

// get ScriptResult part of the response which contains the parameters
Expand All @@ -317,11 +319,15 @@ private void addOutputParametersToResultMap(final Map<String, String> resultMap,
// split result in line breaks as every parameter is returned in a separate "echo" command
final String[] resultParameters = scriptResultString.split("[\\r\\n]+");

LOG.debug("Searching for {} output parameters...", operation.getOutputParameters().size());
// add each parameter that is defined in the operation and passed back
for (final TParameter outputParameter : operation.getOutputParameters()) {
LOG.debug("Searching for output parameter: {}", outputParameter.getName());
// we expect the outputparameters at the end of the result in multiple lines
LOG.debug("Found {} lines in script result...", resultParameters.length);
for (int i = resultParameters.length - 1; i >= 0; i--) {
if (resultParameters[i].startsWith(outputParameter.getName())) {
LOG.debug("Found parameter with given name: {}", outputParameter.getName());
final String value = resultParameters[i].substring(resultParameters[i].indexOf("=") + 1);

LOG.debug("Adding parameter {} with value: {}", outputParameter, value);
Expand Down Expand Up @@ -473,12 +479,17 @@ private String createArtifactTypeSpecificCommandString(final TArtifactType artif
if (commandsString.contains("{{") && commandsString.contains("}}")) {
LOG.debug("Replacing the placeholder of the generic command with properties data and/or provided input parameter...");

final Map<String, String> paramsMap;
Map<String, String> paramsMap;
if (params instanceof HashMap) {
paramsMap = (HashMap<String, String>) params;
} else if (params instanceof Document) {
final Document paramsDoc = (Document) params;
paramsMap = MBUtils.docToMap(paramsDoc, true);
paramsMap = new HashMap<>();
try {
paramsMap = MBUtils.docToMap(paramsDoc, true);
} catch (Exception e) {
LOG.error("Error while parsing doc to map!");
}
} else {
paramsMap = new HashMap<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
</packages>
<commands>
<command>chmod +x {TARGET_FILE_PATH}</command>
<command>CAN_SUDO=$(sudo -n uptime 2&gt;&amp;1|grep "load"|wc -l); if [ ${CAN_SUDO} -gt 0 ]; then sudo -E {DA_NAME_PATH_MAP}{INPUT_PARAMETER}{TARGET_FILE_PATH}; else {DA_NAME_PATH_MAP}{INPUT_PARAMETER}{TARGET_FILE_PATH}; fi</command>
<command>CAN_SUDO=$(sudo -n uptime 2&gt;&amp;1|grep "load"|wc -l); if [ ${CAN_SUDO} -gt 0 ]; then sudo -E {DA_NAME_PATH_MAP}{INPUT_PARAMETER} bash {TARGET_FILE_PATH}; else {DA_NAME_PATH_MAP}{INPUT_PARAMETER} bash {TARGET_FILE_PATH}; fi</command>
</commands>
</artifacttype>
</artifacttype>
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,12 @@ public Exchange invoke(Exchange exchange) {
if (exchange.getIn().getHeader("ParamsMode") != null
&& exchange.getIn().getHeader("ParamsMode").equals("HashMap")) {
LOG.debug("Transforming Document to HashMap...");
final HashMap<String, String> responseMap = MBUtils.docToMap(response, false);
HashMap<String, String> responseMap = new HashMap<>();
try {
responseMap = MBUtils.docToMap(response, false);
} catch (Exception e) {
LOG.error("Error while parsing doc to map!");
}
exchange.getIn().setBody(responseMap);
} else {
exchange.getIn().setBody(response);
Expand Down
Loading
Loading