From 11a3eb19f2df59c821c8e08fa710433974dfe07c Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 09:42:26 -0300 Subject: [PATCH 01/85] Update build.gradle --- build.gradle | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build.gradle b/build.gradle index ee2bd23f9..ea9141790 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'org.springframework.boot' version '2.6.3' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' + id 'org.sonarqube' version '4.2.1.3168' } group = 'com.example' @@ -17,6 +18,14 @@ dependencies { testImplementation('org.springframework.boot:spring-boot-starter-test') } +sonar { + properties { + property 'sonar.projectKey', 'lobozoldick_microservicio-java' + property 'sonar.organization', 'lobozoldick' + property 'sonar.host.url', 'https://sonarcloud.io/' + } +} + test { useJUnitPlatform() } From 5ea58af957aea02a0f9131f21c769a7e9b8ca4a7 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 09:43:42 -0300 Subject: [PATCH 02/85] Update GreetingService.java --- src/main/java/com/example/testingweb/GreetingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/testingweb/GreetingService.java b/src/main/java/com/example/testingweb/GreetingService.java index 6661c82bc..a1be9e91b 100644 --- a/src/main/java/com/example/testingweb/GreetingService.java +++ b/src/main/java/com/example/testingweb/GreetingService.java @@ -5,6 +5,6 @@ @Service public class GreetingService { public String greet() { - return "Hello, World"; + return "Lab Final DevOps-Fundamentos-v6"; } } From 642af310778e4c1b665bf9ca248159a1c3ba99a1 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 09:43:52 -0300 Subject: [PATCH 03/85] Update HomeController.java --- src/main/java/com/example/testingweb/HomeController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/testingweb/HomeController.java b/src/main/java/com/example/testingweb/HomeController.java index 6472ecdf7..1a8392aab 100644 --- a/src/main/java/com/example/testingweb/HomeController.java +++ b/src/main/java/com/example/testingweb/HomeController.java @@ -9,7 +9,7 @@ public class HomeController { @RequestMapping("/") public @ResponseBody String greeting() { - return "Hello, World"; + return "Lab Final DevOps-Fundamentos-v6"; } } From 2948b87f0e5e314ea258443131e0823d250655cc Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 09:44:12 -0300 Subject: [PATCH 04/85] Update HttpRequestTest.java --- src/test/java/com/example/testingweb/HttpRequestTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/example/testingweb/HttpRequestTest.java b/src/test/java/com/example/testingweb/HttpRequestTest.java index 79e679e60..c6c17d6f4 100644 --- a/src/test/java/com/example/testingweb/HttpRequestTest.java +++ b/src/test/java/com/example/testingweb/HttpRequestTest.java @@ -22,6 +22,6 @@ public class HttpRequestTest { @Test public void greetingShouldReturnDefaultMessage() throws Exception { assertThat(this.restTemplate.getForObject("http://localhost:" + port + "/", - String.class)).contains("Hello, World"); + String.class)).contains("Lab Final DevOps-Fundamentos-v6"); } } From ece4256861b2eb15ae378829bd7c5e8324051ab9 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 09:44:26 -0300 Subject: [PATCH 05/85] Update TestingWebApplicationTest.java --- .../java/com/example/testingweb/TestingWebApplicationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/example/testingweb/TestingWebApplicationTest.java b/src/test/java/com/example/testingweb/TestingWebApplicationTest.java index 135f48986..21162ea72 100644 --- a/src/test/java/com/example/testingweb/TestingWebApplicationTest.java +++ b/src/test/java/com/example/testingweb/TestingWebApplicationTest.java @@ -23,6 +23,6 @@ public class TestingWebApplicationTest { @Test public void shouldReturnDefaultMessage() throws Exception { this.mockMvc.perform(get("/")).andDo(print()).andExpect(status().isOk()) - .andExpect(content().string(containsString("Hello, World"))); + .andExpect(content().string(containsString("Lab Final DevOps-Fundamentos-v6"))); } } From 209441613f447180ee903ee38e2081f145c245fd Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 09:44:54 -0300 Subject: [PATCH 06/85] Update WebLayerTest.java --- src/test/java/com/example/testingweb/WebLayerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/example/testingweb/WebLayerTest.java b/src/test/java/com/example/testingweb/WebLayerTest.java index a0e87a8db..283ad5d00 100644 --- a/src/test/java/com/example/testingweb/WebLayerTest.java +++ b/src/test/java/com/example/testingweb/WebLayerTest.java @@ -22,7 +22,7 @@ public class WebLayerTest { @Test public void shouldReturnDefaultMessage() throws Exception { this.mockMvc.perform(get("/")).andDo(print()).andExpect(status().isOk()) - .andExpect(content().string(containsString("Hello, World"))); + .andExpect(content().string(containsString("Lab Final DevOps-Fundamentos-v6"))); } } //end::test[] From 2884a191617b59751f70305cd81d5e0148d82a75 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 09:45:11 -0300 Subject: [PATCH 07/85] Update WebMockTest.java --- src/test/java/com/example/testingweb/WebMockTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/example/testingweb/WebMockTest.java b/src/test/java/com/example/testingweb/WebMockTest.java index 245b6cccb..d5ecf28b1 100644 --- a/src/test/java/com/example/testingweb/WebMockTest.java +++ b/src/test/java/com/example/testingweb/WebMockTest.java @@ -25,8 +25,8 @@ public class WebMockTest { @Test public void greetingShouldReturnMessageFromService() throws Exception { - when(service.greet()).thenReturn("Hello, Mock"); + when(service.greet()).thenReturn("Lab Final DevOps-Fundamentos-v6"); this.mockMvc.perform(get("/greeting")).andDo(print()).andExpect(status().isOk()) - .andExpect(content().string(containsString("Hello, Mock"))); + .andExpect(content().string(containsString("Lab Final DevOps-Fundamentos-v6"))); } } From 235685b8c1200b8352ec34699a8ed83390ff6cfc Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 09:51:06 -0300 Subject: [PATCH 08/85] Create main.yml --- .github/workflows/main.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..4c8cb1105 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,34 @@ +name: CI + +on: + push: + workflow_dispatch: + +jobs: + build: + name: Build and Analyze SonarCLoud + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Cache SonarCloud packages + uses: actions/cache@v3 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Cache Gradle packages + uses: actions/cache@v3 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + + - name: Build and analyze + run: | + chmod +x gradlew + ./gradlew build sonar -Dsonar.token=${{ secrets.TOKEN_SONARCLOUD }} --info --stacktrace + From 9142b6da8f23af58d46c6d06d1cc4d3a851b3085 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 09:55:49 -0300 Subject: [PATCH 09/85] Se Agregan las propiedades de Sonar Cloud --- build.gradle | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index ea9141790..fde6141d3 100644 --- a/build.gradle +++ b/build.gradle @@ -19,11 +19,12 @@ dependencies { } sonar { - properties { - property 'sonar.projectKey', 'lobozoldick_microservicio-java' - property 'sonar.organization', 'lobozoldick' - property 'sonar.host.url', 'https://sonarcloud.io/' - } + properties { + property 'sonar.projectKey', 'lobozoldick_microservicio-java' + property 'sonar.organization', 'lobozoldick' + property 'sonar.host.url', 'https://sonarcloud.io/' + property 'sonar.projectName', 'microservicio-java' + } } test { From becd1533658e6590ea2b1c0428b31c092fc62989 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 10:24:44 -0300 Subject: [PATCH 10/85] Se agrega los job de Jmeter y Postman --- .github/workflows/main.yml | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4c8cb1105..4fcd4e8b6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,8 @@ jobs: name: Build and Analyze SonarCLoud runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v3 with: fetch-depth: 0 @@ -32,3 +33,37 @@ jobs: chmod +x gradlew ./gradlew build sonar -Dsonar.token=${{ secrets.TOKEN_SONARCLOUD }} --info --stacktrace + jmeter: + name: Execute Jmeter + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download Apache JMeter + run: | + curl -LJO https://downloads.apache.org/jmeter/binaries/apache-jmeter-5.6.2.tgz + tar -xvzf apache-jmeter-5.6.2.tgz + + #- name: Run JMeter tests + # run: | + # ./path/to/apache-jmeter/bin/jmeter.sh -n -t Jmeter/scripts/testscript.jmx -l Jmeter/resultados/testresult.jtl + + postman: + name: Execute Postman + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download Node.js And Newman + run: | + sudo apt-get install -y nodejs + npm install -g newman + + #- name: Run JMeter tests + # run: | + # newman run Postman/scripts/postman-collection.json + From f24e325fdd3fee93166bcdce39811a829d79a764 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 10:35:28 -0300 Subject: [PATCH 11/85] Se agrega el build --- .github/workflows/main.yml | 41 ++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4fcd4e8b6..124a85452 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ on: jobs: build: - name: Build and Analyze SonarCLoud + name: Build runs-on: ubuntu-latest steps: - name: Checkout code @@ -14,25 +14,40 @@ jobs: with: fetch-depth: 0 - - name: Cache SonarCloud packages - uses: actions/cache@v3 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - name: Cache Gradle packages - uses: actions/cache@v3 + uses: actions/cache@v2 with: path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} restore-keys: ${{ runner.os }}-gradle - - name: Build and analyze + - name: Build run: | chmod +x gradlew - ./gradlew build sonar -Dsonar.token=${{ secrets.TOKEN_SONARCLOUD }} --info --stacktrace - + ./gradlew build --info --stacktrace + + sonarcloud: + name: Analyze SonarCloud + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Cache SonarCloud packages + uses: actions/cache@v2 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Analyze SonarCloud + run: | + chmod +x gradlew + ./gradlew sonar -Dsonar.login=${{ secrets.TOKEN_SONARCLOUD }} --info --stacktrace + jmeter: name: Execute Jmeter runs-on: ubuntu-latest From b5d56834dbbd7d1728f6236305d778f75dd9e0dd Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 10:40:58 -0300 Subject: [PATCH 12/85] Create prueba --- dist/prueba | 1 + 1 file changed, 1 insertion(+) create mode 100644 dist/prueba diff --git a/dist/prueba b/dist/prueba new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/dist/prueba @@ -0,0 +1 @@ + From b1cfb59f9604b6a3e682092db93bb290ce93392a Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 10:41:17 -0300 Subject: [PATCH 13/85] Delete dist/prueba --- dist/prueba | 1 - 1 file changed, 1 deletion(-) delete mode 100644 dist/prueba diff --git a/dist/prueba b/dist/prueba deleted file mode 100644 index 8b1378917..000000000 --- a/dist/prueba +++ /dev/null @@ -1 +0,0 @@ - From a7e5aaafd110b0ef5baed80f093d01db3efc37d0 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 10:48:02 -0300 Subject: [PATCH 14/85] Se agrega la copia del build al directorio dist --- .github/workflows/main.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 124a85452..b330c583c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,13 @@ jobs: - name: Build run: | chmod +x gradlew - ./gradlew build --info --stacktrace + ./gradlew build + + - name: Copy artifacts to directory dist + run: | + rm -rf $GITHUB_WORKSPACE/dist + mkdir -p $GITHUB_WORKSPACE/dist + cp -r build/* $GITHUB_WORKSPACE/dist/ sonarcloud: name: Analyze SonarCloud From d4324776a68113a969584faed81ac1671ee3318b Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 11:02:35 -0300 Subject: [PATCH 15/85] Update main.yml --- .github/workflows/main.yml | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b330c583c..aa70a0f51 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,10 +28,38 @@ jobs: - name: Copy artifacts to directory dist run: | - rm -rf $GITHUB_WORKSPACE/dist mkdir -p $GITHUB_WORKSPACE/dist cp -r build/* $GITHUB_WORKSPACE/dist/ + deploy: + name: Deploy Github + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Remove existing artifacts + run: rm -rf dist + + - name: Download artifacts + uses: actions/download-artifact@v2 + with: + name: dist + + - name: Copy new artifacts and replace existing + run: | + cp -r $GITHUB_WORKSPACE/dist/* dist/ + + - name: List contents of updated dist + run: ls -R dist + + - name: Upload updated artifacts + uses: actions/upload-artifact@v2 + with: + name: dist + path: dist + sonarcloud: name: Analyze SonarCloud runs-on: ubuntu-latest From 7a63ea76db57136d20e07c4e1e872c662dffcc55 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 11:08:14 -0300 Subject: [PATCH 16/85] Se comprueba que primero compile antes de seguir con los jobs --- .github/workflows/main.yml | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aa70a0f51..3b17046b2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,45 +25,12 @@ jobs: run: | chmod +x gradlew ./gradlew build - - - name: Copy artifacts to directory dist - run: | - mkdir -p $GITHUB_WORKSPACE/dist - cp -r build/* $GITHUB_WORKSPACE/dist/ - - deploy: - name: Deploy Github - runs-on: ubuntu-latest - needs: build - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Remove existing artifacts - run: rm -rf dist - - - name: Download artifacts - uses: actions/download-artifact@v2 - with: - name: dist - - - name: Copy new artifacts and replace existing - run: | - cp -r $GITHUB_WORKSPACE/dist/* dist/ - - - name: List contents of updated dist - run: ls -R dist - - - name: Upload updated artifacts - uses: actions/upload-artifact@v2 - with: - name: dist - path: dist sonarcloud: name: Analyze SonarCloud runs-on: ubuntu-latest needs: build + if: failure() != 'failure' steps: - name: Checkout code uses: actions/checkout@v3 @@ -86,6 +53,7 @@ jobs: name: Execute Jmeter runs-on: ubuntu-latest needs: build + if: failure() != 'failure' steps: - name: Checkout code uses: actions/checkout@v3 @@ -103,6 +71,7 @@ jobs: name: Execute Postman runs-on: ubuntu-latest needs: build + if: failure() != 'failure' steps: - name: Checkout code uses: actions/checkout@v3 From 5e49a2aac33a10496573ecee62f24b18bc89abbd Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 11:11:36 -0300 Subject: [PATCH 17/85] =?UTF-8?q?Se=20actualiza=20la=20versi=C3=B3n=20de?= =?UTF-8?q?=20la=20cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3b17046b2..8b6ac6a18 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: fetch-depth: 0 - name: Cache Gradle packages - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} @@ -38,7 +38,7 @@ jobs: fetch-depth: 0 - name: Cache SonarCloud packages - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar From 3bbdde9e5c7ae88c6d1a39490aa8266584f91583 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 11:28:54 -0300 Subject: [PATCH 18/85] Se agrega jacoco --- build.gradle | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build.gradle b/build.gradle index fde6141d3..16528829e 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'org.springframework.boot' version '2.6.3' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' + id "jacoco" id 'org.sonarqube' version '4.2.1.3168' } @@ -24,9 +25,17 @@ sonar { property 'sonar.organization', 'lobozoldick' property 'sonar.host.url', 'https://sonarcloud.io/' property 'sonar.projectName', 'microservicio-java' + property 'sonar.java.coveragePlugin', 'jacoco' } } +jacoco { + toolVersion = "0.8.9" +} + test { + jacoco { + enabled = true + } useJUnitPlatform() } From 2ef05f002f67a2b640b06bdb0fd8f6bbfb448742 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 11:31:31 -0300 Subject: [PATCH 19/85] Update main.yml usando jacoco --- .github/workflows/main.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8b6ac6a18..f4cbe09c8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,10 +21,14 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} restore-keys: ${{ runner.os }}-gradle - - name: Build + - name: Build with Gradle run: | chmod +x gradlew ./gradlew build + + - name: Run JaCoCo for code coverage + run: | + ./gradlew jacocoTestReport sonarcloud: name: Analyze SonarCloud From a1964d362915c3bfb4d6e8ae1a224891285ad664 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 11:39:42 -0300 Subject: [PATCH 20/85] Update build.gradle --- build.gradle | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build.gradle b/build.gradle index 16528829e..92457fc3e 100644 --- a/build.gradle +++ b/build.gradle @@ -33,6 +33,13 @@ jacoco { toolVersion = "0.8.9" } +jacocoTestReport { + dependsOn test + reports { + xml.enabled true + } +} + test { jacoco { enabled = true From 13b09aed95a337ef7a2268241d115cb76376d61e Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 11:40:55 -0300 Subject: [PATCH 21/85] Cambios en jacoco --- .github/workflows/main.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f4cbe09c8..0fcc9dcff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,10 +25,6 @@ jobs: run: | chmod +x gradlew ./gradlew build - - - name: Run JaCoCo for code coverage - run: | - ./gradlew jacocoTestReport sonarcloud: name: Analyze SonarCloud @@ -51,7 +47,7 @@ jobs: - name: Analyze SonarCloud run: | chmod +x gradlew - ./gradlew sonar -Dsonar.login=${{ secrets.TOKEN_SONARCLOUD }} --info --stacktrace + ./gradlew jacocoTestReport sonar -Dsonar.login=${{ secrets.TOKEN_SONARCLOUD }} --info --stacktrace jmeter: name: Execute Jmeter From e4e38f71edad52b42b62b669b516507906bf1d21 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 14:01:20 -0300 Subject: [PATCH 22/85] Se agrega deploy docker --- .github/workflows/main.yml | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0fcc9dcff..73d66a6b8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,11 +48,37 @@ jobs: run: | chmod +x gradlew ./gradlew jacocoTestReport sonar -Dsonar.login=${{ secrets.TOKEN_SONARCLOUD }} --info --stacktrace + + deploy: + name: Docker build + runs-on: ubuntu-latest + needs: build + if: failure() != 'failure' + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Docker login + uses: docker/login-action@v2.2.0 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Docker build + run: | + docker build --tag lobozoldick/microservicio-java:latest . + docker images + + - name: Docker push + run: | + docker push lobozoldick/microservicio-java jmeter: name: Execute Jmeter runs-on: ubuntu-latest - needs: build + needs: deploy if: failure() != 'failure' steps: - name: Checkout code @@ -70,7 +96,7 @@ jobs: postman: name: Execute Postman runs-on: ubuntu-latest - needs: build + needs: deploy if: failure() != 'failure' steps: - name: Checkout code From 4278525a759aff40d53dabcb443ce7384c5f24a5 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 14:11:29 -0300 Subject: [PATCH 23/85] Update main.yml --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 73d66a6b8..85244de88 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,6 +25,8 @@ jobs: run: | chmod +x gradlew ./gradlew build + cd $GITHUB_WORKSPACE/build/libs/ + ls -lah sonarcloud: name: Analyze SonarCloud From 71cac1ed1a4ebfb190ad088c89cd364b33dddd71 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 14:14:21 -0300 Subject: [PATCH 24/85] Se copia el jar al proyecto --- .github/workflows/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 85244de88..0ec6fca38 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -68,6 +68,12 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - name: Copy build into proyect + run: | + cp $GITHUB_WORKSPACE/build/libs/testing-web-0.0.1-SNAPSHOT.jar . + chmod 755 testing-web-0.0.1-SNAPSHOT.jar + ls -lah + - name: Docker build run: | docker build --tag lobozoldick/microservicio-java:latest . From 5f471c3802f5754193f5c8c65dc8c5341ab09f20 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 14:22:38 -0300 Subject: [PATCH 25/85] Traspaso de artefactos --- .github/workflows/main.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0ec6fca38..1ac4e0930 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,6 +27,12 @@ jobs: ./gradlew build cd $GITHUB_WORKSPACE/build/libs/ ls -lah + + - name: Archive artifact java app + uses: actions/upload-artifact@v2 + with: + name: java-app + path: $GITHUB_WORKSPACE/build/libs/testing-web-0.0.1-SNAPSHOT.jar sonarcloud: name: Analyze SonarCloud @@ -67,15 +73,17 @@ jobs: with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Download artifact java app + uses: actions/download-artifact@v2 + with: + name: java-app + path: . - - name: Copy build into proyect + - name: Docker build run: | - cp $GITHUB_WORKSPACE/build/libs/testing-web-0.0.1-SNAPSHOT.jar . chmod 755 testing-web-0.0.1-SNAPSHOT.jar ls -lah - - - name: Docker build - run: | docker build --tag lobozoldick/microservicio-java:latest . docker images From bcfb74cdae22fb8c74e1966d9b10566fdf80b680 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 14:28:33 -0300 Subject: [PATCH 26/85] Update main.yml --- .github/workflows/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1ac4e0930..cce87cf90 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,8 @@ jobs: ls -lah - name: Archive artifact java app - uses: actions/upload-artifact@v2 + if: success() + uses: actions/upload-artifact@v3 with: name: java-app path: $GITHUB_WORKSPACE/build/libs/testing-web-0.0.1-SNAPSHOT.jar @@ -75,7 +76,7 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} - name: Download artifact java app - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: java-app path: . From 9901f837434888d662f615259e9d7c9b56681921 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 14:34:47 -0300 Subject: [PATCH 27/85] Update main.yml --- .github/workflows/main.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cce87cf90..28f418cd9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,15 +25,14 @@ jobs: run: | chmod +x gradlew ./gradlew build - cd $GITHUB_WORKSPACE/build/libs/ - ls -lah + ls -lah $GITHUB_WORKSPACE/build/libs/ - name: Archive artifact java app if: success() uses: actions/upload-artifact@v3 with: name: java-app - path: $GITHUB_WORKSPACE/build/libs/testing-web-0.0.1-SNAPSHOT.jar + path: build/libs/testing-web-0.0.1-SNAPSHOT.jar sonarcloud: name: Analyze SonarCloud From 64e9dacccf58b6c6f20f23b332188967ab9f8f02 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 14:40:05 -0300 Subject: [PATCH 28/85] Create Dockerfile --- Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..b31688907 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM openjdk:11-jre + +EXPOSE 8085 + +ADD testing-web-0.0.1-SNAPSHOT.jar /app/testing-web-0.0.1-SNAPSHOT.jar + +WORKDIR /app + +CMD java -jar testing-web-0.0.1-SNAPSHOT.jar From 8b8cb7bcee978f4bba2899e8c8a4616138f22a83 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 15:16:30 -0300 Subject: [PATCH 29/85] Create deployment.yaml --- deploy/deployment.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 deploy/deployment.yaml diff --git a/deploy/deployment.yaml b/deploy/deployment.yaml new file mode 100644 index 000000000..80a366b67 --- /dev/null +++ b/deploy/deployment.yaml @@ -0,0 +1,21 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: microservicio-java-deployment + labels: + app: microservicio-java +spec: + replicas: 1 + selector: + matchLabels: + app: microservicio-java + template: + metadata: + labels: + app: microservicio-java + spec: + containers: + - name: microservicio-java + image: lobozoldick/microservicio-java:latest + ports: + - containerPort: 8085 From 2ff1103f379bc03958273fbb286c80fa1ec5b888 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 15:28:54 -0300 Subject: [PATCH 30/85] Rename deployment.yaml to deployment.yml --- deploy/{deployment.yaml => deployment.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename deploy/{deployment.yaml => deployment.yml} (100%) diff --git a/deploy/deployment.yaml b/deploy/deployment.yml similarity index 100% rename from deploy/deployment.yaml rename to deploy/deployment.yml From 4d0c30d489813d9a537a9c327d9b4574696231b4 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 15:30:33 -0300 Subject: [PATCH 31/85] Delete deploy directory --- deploy/deployment.yml | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 deploy/deployment.yml diff --git a/deploy/deployment.yml b/deploy/deployment.yml deleted file mode 100644 index 80a366b67..000000000 --- a/deploy/deployment.yml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: microservicio-java-deployment - labels: - app: microservicio-java -spec: - replicas: 1 - selector: - matchLabels: - app: microservicio-java - template: - metadata: - labels: - app: microservicio-java - spec: - containers: - - name: microservicio-java - image: lobozoldick/microservicio-java:latest - ports: - - containerPort: 8085 From d95dde71348f4023e5fdd1aa3a8027fcbf00a1ee Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 15:30:51 -0300 Subject: [PATCH 32/85] Create deployment.yml --- deployment.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 deployment.yml diff --git a/deployment.yml b/deployment.yml new file mode 100644 index 000000000..80a366b67 --- /dev/null +++ b/deployment.yml @@ -0,0 +1,21 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: microservicio-java-deployment + labels: + app: microservicio-java +spec: + replicas: 1 + selector: + matchLabels: + app: microservicio-java + template: + metadata: + labels: + app: microservicio-java + spec: + containers: + - name: microservicio-java + image: lobozoldick/microservicio-java:latest + ports: + - containerPort: 8085 From c852bddd1db2883d7a005e52ca25d778441f3d7b Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 15:35:25 -0300 Subject: [PATCH 33/85] Update main.yml --- .github/workflows/main.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 28f418cd9..1f95f4ace 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,10 +57,10 @@ jobs: chmod +x gradlew ./gradlew jacocoTestReport sonar -Dsonar.login=${{ secrets.TOKEN_SONARCLOUD }} --info --stacktrace - deploy: + dockerbuild: name: Docker build runs-on: ubuntu-latest - needs: build + needs: sonarcloud if: failure() != 'failure' steps: - name: Checkout code @@ -91,6 +91,19 @@ jobs: run: | docker push lobozoldick/microservicio-java + deploy: + name: Docker Deployment + runs-on: self-hosted + needs: dockerbuild + if: failure() != 'failure' + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Deploy to Minikube + run: | + kubectl apply -f deployment.yml + jmeter: name: Execute Jmeter runs-on: ubuntu-latest From aeec06a14655b37a81ee844c2ead1a1e46d6c2e7 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 15:45:18 -0300 Subject: [PATCH 34/85] Update deployment.yml --- deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment.yml b/deployment.yml index 80a366b67..8e0b71de4 100644 --- a/deployment.yml +++ b/deployment.yml @@ -18,4 +18,4 @@ spec: - name: microservicio-java image: lobozoldick/microservicio-java:latest ports: - - containerPort: 8085 + - containerPort: 8080 From e22a4fe69ff5f05f3d851a2ab23d4237e8cc82e0 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 16:13:04 -0300 Subject: [PATCH 35/85] Update main.yml --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1f95f4ace..6aa609736 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -103,6 +103,7 @@ jobs: - name: Deploy to Minikube run: | kubectl apply -f deployment.yml + curl -I http://localhost:8080/ jmeter: name: Execute Jmeter From b72053326b6670d26dea7dc0eb75722d6fe1f986 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 16:19:00 -0300 Subject: [PATCH 36/85] Update main.yml --- .github/workflows/main.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6aa609736..25882e279 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,7 +38,7 @@ jobs: name: Analyze SonarCloud runs-on: ubuntu-latest needs: build - if: failure() != 'failure' + if: success() steps: - name: Checkout code uses: actions/checkout@v3 @@ -61,7 +61,7 @@ jobs: name: Docker build runs-on: ubuntu-latest needs: sonarcloud - if: failure() != 'failure' + if: success() steps: - name: Checkout code uses: actions/checkout@v3 @@ -95,7 +95,7 @@ jobs: name: Docker Deployment runs-on: self-hosted needs: dockerbuild - if: failure() != 'failure' + if: success() steps: - name: Checkout code uses: actions/checkout@v3 @@ -103,13 +103,14 @@ jobs: - name: Deploy to Minikube run: | kubectl apply -f deployment.yml + kubectl port-forward deployment/microservicio-java-deployment 8080:8080 curl -I http://localhost:8080/ jmeter: name: Execute Jmeter runs-on: ubuntu-latest needs: deploy - if: failure() != 'failure' + if: success() steps: - name: Checkout code uses: actions/checkout@v3 @@ -127,7 +128,7 @@ jobs: name: Execute Postman runs-on: ubuntu-latest needs: deploy - if: failure() != 'failure' + if: success() steps: - name: Checkout code uses: actions/checkout@v3 From 61f7aa44f046363af2cdd4c6cbf949b0d961bb16 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 16:36:31 -0300 Subject: [PATCH 37/85] Update GreetingService.java --- src/main/java/com/example/testingweb/GreetingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/testingweb/GreetingService.java b/src/main/java/com/example/testingweb/GreetingService.java index a1be9e91b..b4b1f28bf 100644 --- a/src/main/java/com/example/testingweb/GreetingService.java +++ b/src/main/java/com/example/testingweb/GreetingService.java @@ -5,6 +5,6 @@ @Service public class GreetingService { public String greet() { - return "Lab Final DevOps-Fundamentos-v6"; + return "Lab Final DevOps-Fundamentos-v6 Greeting"; } } From e68087257f41528c01c2af64678e75d2537e728c Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 16:37:24 -0300 Subject: [PATCH 38/85] Update WebMockTest.java --- src/test/java/com/example/testingweb/WebMockTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/example/testingweb/WebMockTest.java b/src/test/java/com/example/testingweb/WebMockTest.java index d5ecf28b1..5fdaf0a3a 100644 --- a/src/test/java/com/example/testingweb/WebMockTest.java +++ b/src/test/java/com/example/testingweb/WebMockTest.java @@ -25,8 +25,8 @@ public class WebMockTest { @Test public void greetingShouldReturnMessageFromService() throws Exception { - when(service.greet()).thenReturn("Lab Final DevOps-Fundamentos-v6"); + when(service.greet()).thenReturn("Lab Final DevOps-Fundamentos-v6 Greeting"); this.mockMvc.perform(get("/greeting")).andDo(print()).andExpect(status().isOk()) - .andExpect(content().string(containsString("Lab Final DevOps-Fundamentos-v6"))); + .andExpect(content().string(containsString("Lab Final DevOps-Fundamentos-v6 Greeting"))); } } From 1422f34089816c9bf76caf712239a2375549d168 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 16:50:16 -0300 Subject: [PATCH 39/85] Update main.yml --- .github/workflows/main.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 25882e279..1abc6e7fd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -133,12 +133,22 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Download artifact java app + uses: actions/download-artifact@v3 + with: + name: java-app + path: . + - name: Download Node.js And Newman run: | sudo apt-get install -y nodejs npm install -g newman - #- name: Run JMeter tests - # run: | + - name: Run Postman tests + run: | + chmod 755 testing-web-0.0.1-SNAPSHOT.jar + java -jar testing-web-0.0.1-SNAPSHOT.jar > /dev/null 2>&1 & + curl -I http://localhost:8080/ + kill -SIGTERM $(ps aux | grep "java -jar testing-w" | awk '{print $2}') # newman run Postman/scripts/postman-collection.json From 884ea00ce224b064dec1b2b33d2d73e5be4be69f Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 16:58:33 -0300 Subject: [PATCH 40/85] Se agregar Postman --- .github/workflows/main.yml | 101 ++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1abc6e7fd..30b7427be 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -56,11 +56,59 @@ jobs: run: | chmod +x gradlew ./gradlew jacocoTestReport sonar -Dsonar.login=${{ secrets.TOKEN_SONARCLOUD }} --info --stacktrace + + jmeter: + name: Execute Jmeter + runs-on: ubuntu-latest + needs: sonarcloud + if: success() + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download Apache JMeter + run: | + curl -LJO https://downloads.apache.org/jmeter/binaries/apache-jmeter-5.6.2.tgz + tar -xvzf apache-jmeter-5.6.2.tgz + + #- name: Run JMeter tests + # run: | + # ./path/to/apache-jmeter/bin/jmeter.sh -n -t Jmeter/scripts/testscript.jmx -l Jmeter/resultados/testresult.jtl + + postman: + name: Execute Postman + runs-on: ubuntu-latest + needs: sonarcloud + if: success() + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download artifact java app + uses: actions/download-artifact@v3 + with: + name: java-app + path: . + - name: Download Node.js And Newman + run: | + sudo apt-get install -y nodejs + npm install -g newman + + - name: Run Postman tests + run: | + chmod 755 testing-web-0.0.1-SNAPSHOT.jar + java -jar testing-web-0.0.1-SNAPSHOT.jar > /dev/null 2>&1 & + curl -I http://localhost:8080/ + kill -SIGTERM $(ps aux | grep "java -jar testing-w" | awk '{print $2}') + # newman run Postman/scripts/postman-collection.json + dockerbuild: name: Docker build runs-on: ubuntu-latest - needs: sonarcloud + needs: + - postman + - jmeter if: success() steps: - name: Checkout code @@ -90,7 +138,7 @@ jobs: - name: Docker push run: | docker push lobozoldick/microservicio-java - + deploy: name: Docker Deployment runs-on: self-hosted @@ -103,52 +151,3 @@ jobs: - name: Deploy to Minikube run: | kubectl apply -f deployment.yml - kubectl port-forward deployment/microservicio-java-deployment 8080:8080 - curl -I http://localhost:8080/ - - jmeter: - name: Execute Jmeter - runs-on: ubuntu-latest - needs: deploy - if: success() - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Download Apache JMeter - run: | - curl -LJO https://downloads.apache.org/jmeter/binaries/apache-jmeter-5.6.2.tgz - tar -xvzf apache-jmeter-5.6.2.tgz - - #- name: Run JMeter tests - # run: | - # ./path/to/apache-jmeter/bin/jmeter.sh -n -t Jmeter/scripts/testscript.jmx -l Jmeter/resultados/testresult.jtl - - postman: - name: Execute Postman - runs-on: ubuntu-latest - needs: deploy - if: success() - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Download artifact java app - uses: actions/download-artifact@v3 - with: - name: java-app - path: . - - - name: Download Node.js And Newman - run: | - sudo apt-get install -y nodejs - npm install -g newman - - - name: Run Postman tests - run: | - chmod 755 testing-web-0.0.1-SNAPSHOT.jar - java -jar testing-web-0.0.1-SNAPSHOT.jar > /dev/null 2>&1 & - curl -I http://localhost:8080/ - kill -SIGTERM $(ps aux | grep "java -jar testing-w" | awk '{print $2}') - # newman run Postman/scripts/postman-collection.json - From 0d2d0aad304371108f1a6d57fa43e0ed93859114 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 17:05:41 -0300 Subject: [PATCH 41/85] Create pruebas_Aceptacion.postman_collection.json --- ...pruebas_Aceptacion.postman_collection.json | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Postman/sctips/pruebas_Aceptacion.postman_collection.json diff --git a/Postman/sctips/pruebas_Aceptacion.postman_collection.json b/Postman/sctips/pruebas_Aceptacion.postman_collection.json new file mode 100644 index 000000000..46dacccaa --- /dev/null +++ b/Postman/sctips/pruebas_Aceptacion.postman_collection.json @@ -0,0 +1,90 @@ +{ + "info": { + "_postman_id": "6b85cbae-208e-4cd5-b20c-6cff0dcf7709", + "name": "Pruebas de Aceptación", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "4933448" + }, + "item": [ + { + "name": "homeServices", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Prueba de contenido del Body\", function () {", + " pm.response.to.have.body(\"Lab Final DevOps-Fundamentos-v6\");", + "});", + "", + "pm.test(\"Response time is less than 50ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(50);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8080/", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "" + ] + } + }, + "response": [] + }, + { + "name": "greetingServices", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Prueba de contenido del Body\", function () {", + " pm.response.to.have.body(\"Lab Final DevOps-Fundamentos-v6 Greeting\");", + "});", + "", + "pm.test(\"Response time is less than 50ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(50);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8080/greeting", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "greeting" + ] + } + }, + "response": [] + } + ] +} From 6a208bf6de276792bd407a848aae52e7c95e3127 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 17:07:46 -0300 Subject: [PATCH 42/85] Delete Postman/sctips directory --- ...pruebas_Aceptacion.postman_collection.json | 90 ------------------- 1 file changed, 90 deletions(-) delete mode 100644 Postman/sctips/pruebas_Aceptacion.postman_collection.json diff --git a/Postman/sctips/pruebas_Aceptacion.postman_collection.json b/Postman/sctips/pruebas_Aceptacion.postman_collection.json deleted file mode 100644 index 46dacccaa..000000000 --- a/Postman/sctips/pruebas_Aceptacion.postman_collection.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "info": { - "_postman_id": "6b85cbae-208e-4cd5-b20c-6cff0dcf7709", - "name": "Pruebas de Aceptación", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "4933448" - }, - "item": [ - { - "name": "homeServices", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"Prueba de contenido del Body\", function () {", - " pm.response.to.have.body(\"Lab Final DevOps-Fundamentos-v6\");", - "});", - "", - "pm.test(\"Response time is less than 50ms\", function () {", - " pm.expect(pm.response.responseTime).to.be.below(50);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "http://localhost:8080/", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "8080", - "path": [ - "" - ] - } - }, - "response": [] - }, - { - "name": "greetingServices", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"Prueba de contenido del Body\", function () {", - " pm.response.to.have.body(\"Lab Final DevOps-Fundamentos-v6 Greeting\");", - "});", - "", - "pm.test(\"Response time is less than 50ms\", function () {", - " pm.expect(pm.response.responseTime).to.be.below(50);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "http://localhost:8080/greeting", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "8080", - "path": [ - "greeting" - ] - } - }, - "response": [] - } - ] -} From ccbe71400eb94668709d7e41991462489f3a55b7 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 17:08:34 -0300 Subject: [PATCH 43/85] Create pruebas_Aceptacion.postman_collection.json --- ...pruebas_Aceptacion.postman_collection.json | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Postman/scripts/pruebas_Aceptacion.postman_collection.json diff --git a/Postman/scripts/pruebas_Aceptacion.postman_collection.json b/Postman/scripts/pruebas_Aceptacion.postman_collection.json new file mode 100644 index 000000000..46dacccaa --- /dev/null +++ b/Postman/scripts/pruebas_Aceptacion.postman_collection.json @@ -0,0 +1,90 @@ +{ + "info": { + "_postman_id": "6b85cbae-208e-4cd5-b20c-6cff0dcf7709", + "name": "Pruebas de Aceptación", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "4933448" + }, + "item": [ + { + "name": "homeServices", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Prueba de contenido del Body\", function () {", + " pm.response.to.have.body(\"Lab Final DevOps-Fundamentos-v6\");", + "});", + "", + "pm.test(\"Response time is less than 50ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(50);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8080/", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "" + ] + } + }, + "response": [] + }, + { + "name": "greetingServices", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Prueba de contenido del Body\", function () {", + " pm.response.to.have.body(\"Lab Final DevOps-Fundamentos-v6 Greeting\");", + "});", + "", + "pm.test(\"Response time is less than 50ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(50);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:8080/greeting", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "greeting" + ] + } + }, + "response": [] + } + ] +} From f6b2bbbaae186f592047e3dece6f008e91fa6b33 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 17:09:08 -0300 Subject: [PATCH 44/85] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 30b7427be..f286c6ca7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,7 +55,7 @@ jobs: - name: Analyze SonarCloud run: | chmod +x gradlew - ./gradlew jacocoTestReport sonar -Dsonar.login=${{ secrets.TOKEN_SONARCLOUD }} --info --stacktrace + #./gradlew jacocoTestReport sonar -Dsonar.login=${{ secrets.TOKEN_SONARCLOUD }} --info --stacktrace jmeter: name: Execute Jmeter @@ -101,7 +101,7 @@ jobs: java -jar testing-web-0.0.1-SNAPSHOT.jar > /dev/null 2>&1 & curl -I http://localhost:8080/ kill -SIGTERM $(ps aux | grep "java -jar testing-w" | awk '{print $2}') - # newman run Postman/scripts/postman-collection.json + # newman run Postman/scripts/pruebas_Aceptacion.postman_collection.json dockerbuild: name: Docker build From f6f37e5ea1306af95504d5677e3804ef6283c823 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 17:11:16 -0300 Subject: [PATCH 45/85] Update main.yml --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f286c6ca7..bb1731fdc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -98,6 +98,7 @@ jobs: - name: Run Postman tests run: | chmod 755 testing-web-0.0.1-SNAPSHOT.jar + ls -lah java -jar testing-web-0.0.1-SNAPSHOT.jar > /dev/null 2>&1 & curl -I http://localhost:8080/ kill -SIGTERM $(ps aux | grep "java -jar testing-w" | awk '{print $2}') From 05998dc36e4492fca34d94a5c8e63bf5f95ee74b Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 17:22:11 -0300 Subject: [PATCH 46/85] Create wait_application.sh --- bash/scripts/wait_application.sh | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 bash/scripts/wait_application.sh diff --git a/bash/scripts/wait_application.sh b/bash/scripts/wait_application.sh new file mode 100644 index 000000000..32c26aa78 --- /dev/null +++ b/bash/scripts/wait_application.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Script para esperar hasta que la aplicación esté lista + +# Ruta al archivo JAR de la aplicación +JAR_FILE="testing-web-0.0.1-SNAPSHOT.jar" +# Puerto al que se realizará la solicitud +PORT=8080 +# Número máximo de intentos +MAX_RETRIES=12 +# Tiempo de espera entre intentos (en segundos) +WAIT_TIME=5 + +# Función para realizar una solicitud HTTP +function make_request() { + curl -I http://localhost:$PORT/ +} + +# Iniciar la aplicación en segundo plano +chmod +x $JAR_FILE +java -jar $JAR_FILE > /dev/null 2>&1 & + +# Esperar hasta que la aplicación esté lista +for ((i=1; i<=$MAX_RETRIES; i++)); do + if make_request; then + echo "La aplicación está lista." + exit 0 + fi + echo "Intento $i: La aplicación no está lista, esperando $WAIT_TIME segundos..." + sleep $WAIT_TIME +done + +echo "Número máximo de intentos alcanzado. La aplicación no se inició correctamente." +exit 1 From 4fbeddd6d68db435a73f14d7136caa669caf043d Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 17:22:59 -0300 Subject: [PATCH 47/85] Update main.yml --- .github/workflows/main.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bb1731fdc..69f52bf74 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -97,9 +97,8 @@ jobs: - name: Run Postman tests run: | - chmod 755 testing-web-0.0.1-SNAPSHOT.jar - ls -lah - java -jar testing-web-0.0.1-SNAPSHOT.jar > /dev/null 2>&1 & + chmod +x bash/scripts/wait_application.sh + ./bash/scripts/wait_for_application.sh curl -I http://localhost:8080/ kill -SIGTERM $(ps aux | grep "java -jar testing-w" | awk '{print $2}') # newman run Postman/scripts/pruebas_Aceptacion.postman_collection.json From 71102aa0a1222a4e1a4ab036278b717e64dc8e81 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 17:25:07 -0300 Subject: [PATCH 48/85] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 69f52bf74..3fc44f8eb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -98,7 +98,7 @@ jobs: - name: Run Postman tests run: | chmod +x bash/scripts/wait_application.sh - ./bash/scripts/wait_for_application.sh + ./bash/scripts/wait_application.sh curl -I http://localhost:8080/ kill -SIGTERM $(ps aux | grep "java -jar testing-w" | awk '{print $2}') # newman run Postman/scripts/pruebas_Aceptacion.postman_collection.json From 3b83ed360dec5b6564d92259b38d3001fbad10c4 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 17:37:17 -0300 Subject: [PATCH 49/85] =?UTF-8?q?Creaci=C3=B3n=20de=20test=20de=20postman?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3fc44f8eb..11a0304ae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -66,6 +66,18 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Download artifact java app + uses: actions/download-artifact@v3 + with: + name: java-app + path: . + + - name: Run java app por test + run: | + chmod +x bash/scripts/wait_application.sh + ./bash/scripts/wait_application.sh + curl -I http://localhost:8080/ + - name: Download Apache JMeter run: | curl -LJO https://downloads.apache.org/jmeter/binaries/apache-jmeter-5.6.2.tgz @@ -73,7 +85,12 @@ jobs: #- name: Run JMeter tests # run: | - # ./path/to/apache-jmeter/bin/jmeter.sh -n -t Jmeter/scripts/testscript.jmx -l Jmeter/resultados/testresult.jtl + # chmod -x apache-jmeter/bin/jmeter.sh + # ./apache-jmeter/bin/jmeter.sh -n -t Jmeter/scripts/testscript.jmx -l Jmeter/resultados/testresult.jtl + + - name: Close java app por test + run: | + kill -SIGTERM $(ps aux | grep "java -jar testing-w" | awk '{print $2}') postman: name: Execute Postman @@ -95,13 +112,19 @@ jobs: sudo apt-get install -y nodejs npm install -g newman - - name: Run Postman tests + - name: Run java app por test run: | chmod +x bash/scripts/wait_application.sh ./bash/scripts/wait_application.sh curl -I http://localhost:8080/ + + - name: Run Postman tests + run: | + newman run Postman/scripts/pruebas_Aceptacion.postman_collection.json + + - name: Close java app por test + run: | kill -SIGTERM $(ps aux | grep "java -jar testing-w" | awk '{print $2}') - # newman run Postman/scripts/pruebas_Aceptacion.postman_collection.json dockerbuild: name: Docker build From 1ba97b252ff067c273111902adb11facd143eadd Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 18:03:39 -0300 Subject: [PATCH 50/85] Update main.yml --- .github/workflows/main.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 11a0304ae..de757b219 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -174,3 +174,29 @@ jobs: - name: Deploy to Minikube run: | kubectl apply -f deployment.yml + + performance_test: + runs-on: ubuntu-latest + needs: deploy + if: success() + services: + docker: + image: lobozoldick/microservicio-java:latest + ports: + - 8080:8080 + options: --entrypoint "bash" # Inicia el contenedor con un shell para ejecutar comandos adicionales + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Download Node.js and Newman + run: | + sudo apt-get install -y nodejs + npm install -g newman + + - name: Run Postman tests + run: | + newman run Postman/scripts/postman-collection.json -e Postman/environments/your-environment.json --insecure + + From c7150d8774b97b55bf78d02503736437ecb94faf Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 18:09:51 -0300 Subject: [PATCH 51/85] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index de757b219..5659a6332 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -197,6 +197,6 @@ jobs: - name: Run Postman tests run: | - newman run Postman/scripts/postman-collection.json -e Postman/environments/your-environment.json --insecure + newman run Postman/scripts/pruebas_Aceptacion.postman_collection.json From 720fe8bfb4a8194c189a1060a704484b0b64bf7a Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 18:25:24 -0300 Subject: [PATCH 52/85] Create consultingLocalhost.sh --- bash/scripts/consultingLocalhost.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 bash/scripts/consultingLocalhost.sh diff --git a/bash/scripts/consultingLocalhost.sh b/bash/scripts/consultingLocalhost.sh new file mode 100644 index 000000000..6f0f6911f --- /dev/null +++ b/bash/scripts/consultingLocalhost.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Puerto al que se realizará la solicitud +PORT=8080 +# Número máximo de intentos +MAX_RETRIES=12 +# Tiempo de espera entre intentos (en segundos) +WAIT_TIME=5 + +# Función para realizar una solicitud HTTP +function make_request() { + curl -I http://localhost:$PORT/ +} + +# Esperar hasta que la aplicación esté lista +for ((i=1; i<=$MAX_RETRIES; i++)); do + if make_request; then + echo "La aplicación está lista." + exit 0 + fi + echo "Intento $i: La aplicación no está lista, esperando $WAIT_TIME segundos..." + sleep $WAIT_TIME +done + +echo "Número máximo de intentos alcanzado. La aplicación no se inició correctamente." +exit 1 From e360fb59482b0e4c85cc15205dd0a385d5be2085 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 18:26:42 -0300 Subject: [PATCH 53/85] Update main.yml --- .github/workflows/main.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5659a6332..4eaf9b01e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -188,7 +188,13 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 + + - name: Run java app por test + run: | + chmod +x bash/scripts/consultingLocalhost.sh + ./bash/scripts/consultingLocalhost.sh + curl -I http://localhost:8080/ - name: Download Node.js and Newman run: | From d46235b137970164836d7f26381993c832f75e39 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 18:34:58 -0300 Subject: [PATCH 54/85] Update main.yml --- .github/workflows/main.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4eaf9b01e..2f478f328 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -189,6 +189,11 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 + + - name: Check Docker logs + run: | + CONTAINER_ID=$(docker ps -q) + docker logs $CONTAINER_ID - name: Run java app por test run: | From 4f419e8f4ba872723937e3939115464e74d2bc37 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 18:36:19 -0300 Subject: [PATCH 55/85] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b31688907..01fcad4e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM openjdk:11-jre -EXPOSE 8085 +EXPOSE 8080 ADD testing-web-0.0.1-SNAPSHOT.jar /app/testing-web-0.0.1-SNAPSHOT.jar From 0d71296cd7e4c696e9a68584c6866652226d15ae Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 19:23:28 -0300 Subject: [PATCH 56/85] Update main.yml --- .github/workflows/main.yml | 157 ++++--------------------------------- 1 file changed, 15 insertions(+), 142 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2f478f328..9865a5922 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,105 +33,11 @@ jobs: with: name: java-app path: build/libs/testing-web-0.0.1-SNAPSHOT.jar - - sonarcloud: - name: Analyze SonarCloud - runs-on: ubuntu-latest - needs: build - if: success() - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Cache SonarCloud packages - uses: actions/cache@v3 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - - name: Analyze SonarCloud - run: | - chmod +x gradlew - #./gradlew jacocoTestReport sonar -Dsonar.login=${{ secrets.TOKEN_SONARCLOUD }} --info --stacktrace - - jmeter: - name: Execute Jmeter - runs-on: ubuntu-latest - needs: sonarcloud - if: success() - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Download artifact java app - uses: actions/download-artifact@v3 - with: - name: java-app - path: . - - - name: Run java app por test - run: | - chmod +x bash/scripts/wait_application.sh - ./bash/scripts/wait_application.sh - curl -I http://localhost:8080/ - - - name: Download Apache JMeter - run: | - curl -LJO https://downloads.apache.org/jmeter/binaries/apache-jmeter-5.6.2.tgz - tar -xvzf apache-jmeter-5.6.2.tgz - - #- name: Run JMeter tests - # run: | - # chmod -x apache-jmeter/bin/jmeter.sh - # ./apache-jmeter/bin/jmeter.sh -n -t Jmeter/scripts/testscript.jmx -l Jmeter/resultados/testresult.jtl - - - name: Close java app por test - run: | - kill -SIGTERM $(ps aux | grep "java -jar testing-w" | awk '{print $2}') - - postman: - name: Execute Postman - runs-on: ubuntu-latest - needs: sonarcloud - if: success() - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Download artifact java app - uses: actions/download-artifact@v3 - with: - name: java-app - path: . - - - name: Download Node.js And Newman - run: | - sudo apt-get install -y nodejs - npm install -g newman - - - name: Run java app por test - run: | - chmod +x bash/scripts/wait_application.sh - ./bash/scripts/wait_application.sh - curl -I http://localhost:8080/ - - - name: Run Postman tests - run: | - newman run Postman/scripts/pruebas_Aceptacion.postman_collection.json - - - name: Close java app por test - run: | - kill -SIGTERM $(ps aux | grep "java -jar testing-w" | awk '{print $2}') dockerbuild: name: Docker build runs-on: ubuntu-latest - needs: - - postman - - jmeter + needs: build if: success() steps: - name: Checkout code @@ -161,53 +67,20 @@ jobs: - name: Docker push run: | docker push lobozoldick/microservicio-java - - deploy: - name: Docker Deployment - runs-on: self-hosted - needs: dockerbuild - if: success() - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Deploy to Minikube - run: | - kubectl apply -f deployment.yml - - performance_test: - runs-on: ubuntu-latest - needs: deploy - if: success() - services: - docker: - image: lobozoldick/microservicio-java:latest - ports: - - 8080:8080 - options: --entrypoint "bash" # Inicia el contenedor con un shell para ejecutar comandos adicionales - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Check Docker logs - run: | - CONTAINER_ID=$(docker ps -q) - docker logs $CONTAINER_ID - - - name: Run java app por test - run: | - chmod +x bash/scripts/consultingLocalhost.sh - ./bash/scripts/consultingLocalhost.sh - curl -I http://localhost:8080/ - - - name: Download Node.js and Newman - run: | - sudo apt-get install -y nodejs - npm install -g newman + - name: Set up Google Cloud SDK + uses: google-github-actions/setup-gcloud@master + with: + project_id: ${{ secrets.GCLOUD_PROJECT_ID }} + service_account_key: ${{ secrets.GCLOUD_SA_KEY }} + export_default_credentials: true - - name: Run Postman tests - run: | - newman run Postman/scripts/pruebas_Aceptacion.postman_collection.json - + - name: Deploy to Google Cloud Run + run: | + gcloud run deploy microservicio-java \ + --image gcr.io/devops-v6-microservicio-java/lobozoldick/microservicio-java:latest \ + --platform managed \ + --region us-central1 + env: + GCLOUD_PROJECT_ID: ${{ secrets.GCLOUD_PROJECT_ID }} From a913b1d75722f436f7cb9761fa18fe47d9ded565 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 19:26:08 -0300 Subject: [PATCH 57/85] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9865a5922..e2648e74d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -69,7 +69,7 @@ jobs: docker push lobozoldick/microservicio-java - name: Set up Google Cloud SDK - uses: google-github-actions/setup-gcloud@master + uses: google-github-actions/auth@v0.8.3 with: project_id: ${{ secrets.GCLOUD_PROJECT_ID }} service_account_key: ${{ secrets.GCLOUD_SA_KEY }} From f62add4388950f7f9576450adb54d111d30d34c4 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 19:31:49 -0300 Subject: [PATCH 58/85] Update main.yml From 534bd11d10bf43b60d0fa63fe98abd65dad52a76 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 19:43:17 -0300 Subject: [PATCH 59/85] Update main.yml --- .github/workflows/main.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e2648e74d..5cc270a0b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -68,19 +68,20 @@ jobs: run: | docker push lobozoldick/microservicio-java - - name: Set up Google Cloud SDK - uses: google-github-actions/auth@v0.8.3 + - name: Google Auth + id: auth + uses: 'google-github-actions/auth@v0' with: - project_id: ${{ secrets.GCLOUD_PROJECT_ID }} - service_account_key: ${{ secrets.GCLOUD_SA_KEY }} - export_default_credentials: true + credentials_json: '${{ secrets.GCP_CREDENTIALS }}' - - name: Deploy to Google Cloud Run - run: | - gcloud run deploy microservicio-java \ - --image gcr.io/devops-v6-microservicio-java/lobozoldick/microservicio-java:latest \ - --platform managed \ - --region us-central1 - env: - GCLOUD_PROJECT_ID: ${{ secrets.GCLOUD_PROJECT_ID }} + - name: Deploy to Cloud Run + id: deploy + uses: google-github-actions/deploy-cloudrun@v0 + with: + service: microservicio-java + region: us-central1 + source: ./ + + - name: Show Output + run: echo ${{ steps.deploy.outputs.url }} From 896eb91b4b274b1e447f64288e5243b350aeee9c Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 19:45:25 -0300 Subject: [PATCH 60/85] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5cc270a0b..978cb8a46 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -70,13 +70,13 @@ jobs: - name: Google Auth id: auth - uses: 'google-github-actions/auth@v0' + uses: 'google-github-actions/auth@v0.8.3' with: credentials_json: '${{ secrets.GCP_CREDENTIALS }}' - name: Deploy to Cloud Run id: deploy - uses: google-github-actions/deploy-cloudrun@v0 + uses: google-github-actions/deploy-cloudrun@v0.8.3 with: service: microservicio-java region: us-central1 From 2de14fdffb71bb42098c438460838f24aa2f326e Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 19:47:13 -0300 Subject: [PATCH 61/85] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 978cb8a46..3c46d97b0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -76,7 +76,7 @@ jobs: - name: Deploy to Cloud Run id: deploy - uses: google-github-actions/deploy-cloudrun@v0.8.3 + uses: google-github-actions/deploy-cloudrun@v2 with: service: microservicio-java region: us-central1 From 509ca9f616e51bbde23e860eb9afc709e3b3f80f Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Thu, 21 Dec 2023 19:50:58 -0300 Subject: [PATCH 62/85] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3c46d97b0..4515b8e2e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -70,7 +70,7 @@ jobs: - name: Google Auth id: auth - uses: 'google-github-actions/auth@v0.8.3' + uses: 'google-github-actions/auth@v2' with: credentials_json: '${{ secrets.GCP_CREDENTIALS }}' From f59555dfc85f96543c8068d1f67b86460fbfdae5 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 02:49:31 -0300 Subject: [PATCH 63/85] Update pruebas_Aceptacion.postman_collection.json --- ...pruebas_Aceptacion.postman_collection.json | 43 ++++++++++++++----- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/Postman/scripts/pruebas_Aceptacion.postman_collection.json b/Postman/scripts/pruebas_Aceptacion.postman_collection.json index 46dacccaa..430445d6b 100644 --- a/Postman/scripts/pruebas_Aceptacion.postman_collection.json +++ b/Postman/scripts/pruebas_Aceptacion.postman_collection.json @@ -30,17 +30,26 @@ } ], "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{GCP_TOKEN}}", + "type": "string" + } + ] + }, "method": "GET", "header": [], "url": { - "raw": "http://localhost:8080/", - "protocol": "http", + "raw": "https://microservicio-java-ss7gplbrpq-uc.a.run.app", + "protocol": "https", "host": [ - "localhost" - ], - "port": "8080", - "path": [ - "" + "microservicio-java-ss7gplbrpq-uc", + "a", + "run", + "app" ] } }, @@ -70,15 +79,27 @@ } ], "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{GCP_TOKEN}}", + "type": "string" + } + ] + }, "method": "GET", "header": [], "url": { - "raw": "http://localhost:8080/greeting", - "protocol": "http", + "raw": "https://microservicio-java-ss7gplbrpq-uc.a.run.app/greeting", + "protocol": "https", "host": [ - "localhost" + "microservicio-java-ss7gplbrpq-uc", + "a", + "run", + "app" ], - "port": "8080", "path": [ "greeting" ] From 80ed88a9bca7c9a43a72f8fac395be597ec4cb56 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 02:50:39 -0300 Subject: [PATCH 64/85] Update main.yml --- .github/workflows/main.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4515b8e2e..d4871622c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -84,4 +84,21 @@ jobs: - name: Show Output run: echo ${{ steps.deploy.outputs.url }} + + - name: Get Cloud Run authentication token + id: get-auth-token + uses: google-github-actions/auth@v2 + with: + scopes: "https://www.googleapis.com/auth/cloud-platform" + env: + GCP_REGION: "us-central1" + + - name: Save token to file + run: echo "${{ steps.get-auth-token.outputs.token }}" > gcp_token.txt + + - name: Execute Postman tests + run: | + npm install -g newman + export GCP_TOKEN=$(cat gcp_token.txt) + newman run Postman/scripts/pruebas_Aceptacion.postman_collection.json --env-var GCP_TOKEN=$GCP_TOKEN From c5608053321f6380b71bd0b279c20ec3b7fc4d64 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 02:55:59 -0300 Subject: [PATCH 65/85] Update main.yml --- .github/workflows/main.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d4871622c..46829416c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -85,14 +85,6 @@ jobs: - name: Show Output run: echo ${{ steps.deploy.outputs.url }} - - name: Get Cloud Run authentication token - id: get-auth-token - uses: google-github-actions/auth@v2 - with: - scopes: "https://www.googleapis.com/auth/cloud-platform" - env: - GCP_REGION: "us-central1" - - name: Save token to file run: echo "${{ steps.get-auth-token.outputs.token }}" > gcp_token.txt From d568444597025a8771cf9e1094d8dc8257468a93 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 03:01:29 -0300 Subject: [PATCH 66/85] Update main.yml --- .github/workflows/main.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 46829416c..b405316ab 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -85,6 +85,15 @@ jobs: - name: Show Output run: echo ${{ steps.deploy.outputs.url }} + - name: Get Cloud Run authentication token + id: get-auth-token + uses: google-github-actions/auth@v2 + with: + credentials_json: '${{ secrets.GCP_CREDENTIALS }}' + scopes: "https://www.googleapis.com/auth/cloud-platform" + env: + GCP_REGION: "us-central1" + - name: Save token to file run: echo "${{ steps.get-auth-token.outputs.token }}" > gcp_token.txt From 8cdc76073e23c5ea8745892ea425bfbed6a9e135 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 03:09:39 -0300 Subject: [PATCH 67/85] Update main.yml --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b405316ab..08320000b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -95,7 +95,9 @@ jobs: GCP_REGION: "us-central1" - name: Save token to file - run: echo "${{ steps.get-auth-token.outputs.token }}" > gcp_token.txt + run: | + gcloud auth print-identity-token + gcloud auth print-identity-token > gcp_token.txt - name: Execute Postman tests run: | From 71a243ce88b540cd364be69c548e31041b40d20c Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 03:13:36 -0300 Subject: [PATCH 68/85] Update pruebas_Aceptacion.postman_collection.json --- .../scripts/pruebas_Aceptacion.postman_collection.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Postman/scripts/pruebas_Aceptacion.postman_collection.json b/Postman/scripts/pruebas_Aceptacion.postman_collection.json index 430445d6b..08d64de8e 100644 --- a/Postman/scripts/pruebas_Aceptacion.postman_collection.json +++ b/Postman/scripts/pruebas_Aceptacion.postman_collection.json @@ -21,8 +21,8 @@ " pm.response.to.have.body(\"Lab Final DevOps-Fundamentos-v6\");", "});", "", - "pm.test(\"Response time is less than 50ms\", function () {", - " pm.expect(pm.response.responseTime).to.be.below(50);", + "pm.test(\"Response time is less than 200ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(200);", "});" ], "type": "text/javascript" @@ -70,8 +70,8 @@ " pm.response.to.have.body(\"Lab Final DevOps-Fundamentos-v6 Greeting\");", "});", "", - "pm.test(\"Response time is less than 50ms\", function () {", - " pm.expect(pm.response.responseTime).to.be.below(50);", + "pm.test(\"Response time is less than 200ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(200);", "});" ], "type": "text/javascript" From 78ecb19fb89cb392b9e0b20b13c3fb53ed20cad8 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 03:13:41 -0300 Subject: [PATCH 69/85] Update main.yml --- .github/workflows/main.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 08320000b..c601da0ae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -85,15 +85,6 @@ jobs: - name: Show Output run: echo ${{ steps.deploy.outputs.url }} - - name: Get Cloud Run authentication token - id: get-auth-token - uses: google-github-actions/auth@v2 - with: - credentials_json: '${{ secrets.GCP_CREDENTIALS }}' - scopes: "https://www.googleapis.com/auth/cloud-platform" - env: - GCP_REGION: "us-central1" - - name: Save token to file run: | gcloud auth print-identity-token From 6daae0c45015e3d8f73c149ff4dc82dc48938020 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 03:17:49 -0300 Subject: [PATCH 70/85] Update pruebas_Aceptacion.postman_collection.json --- .../scripts/pruebas_Aceptacion.postman_collection.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Postman/scripts/pruebas_Aceptacion.postman_collection.json b/Postman/scripts/pruebas_Aceptacion.postman_collection.json index 08d64de8e..c0228c10b 100644 --- a/Postman/scripts/pruebas_Aceptacion.postman_collection.json +++ b/Postman/scripts/pruebas_Aceptacion.postman_collection.json @@ -21,8 +21,8 @@ " pm.response.to.have.body(\"Lab Final DevOps-Fundamentos-v6\");", "});", "", - "pm.test(\"Response time is less than 200ms\", function () {", - " pm.expect(pm.response.responseTime).to.be.below(200);", + "pm.test(\"Response time is less than 500ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(500);", "});" ], "type": "text/javascript" @@ -70,8 +70,8 @@ " pm.response.to.have.body(\"Lab Final DevOps-Fundamentos-v6 Greeting\");", "});", "", - "pm.test(\"Response time is less than 200ms\", function () {", - " pm.expect(pm.response.responseTime).to.be.below(200);", + "pm.test(\"Response time is less than 500ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(500);", "});" ], "type": "text/javascript" From 37edea2cb775ebaf120cfaa2289fb01d6cd1dfa0 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 03:37:13 -0300 Subject: [PATCH 71/85] Update pruebas_Aceptacion.postman_collection.json --- .../pruebas_Aceptacion.postman_collection.json | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Postman/scripts/pruebas_Aceptacion.postman_collection.json b/Postman/scripts/pruebas_Aceptacion.postman_collection.json index c0228c10b..e6d474ddf 100644 --- a/Postman/scripts/pruebas_Aceptacion.postman_collection.json +++ b/Postman/scripts/pruebas_Aceptacion.postman_collection.json @@ -43,13 +43,9 @@ "method": "GET", "header": [], "url": { - "raw": "https://microservicio-java-ss7gplbrpq-uc.a.run.app", - "protocol": "https", + "raw": "{{URL}}", "host": [ - "microservicio-java-ss7gplbrpq-uc", - "a", - "run", - "app" + "{{URL}}" ] } }, @@ -92,13 +88,9 @@ "method": "GET", "header": [], "url": { - "raw": "https://microservicio-java-ss7gplbrpq-uc.a.run.app/greeting", - "protocol": "https", + "raw": "{{URL}}/greeting", "host": [ - "microservicio-java-ss7gplbrpq-uc", - "a", - "run", - "app" + "{{URL}}" ], "path": [ "greeting" From 0ff823b021f7b2ea3299d330960bcc3c72b0d8c9 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 03:41:35 -0300 Subject: [PATCH 72/85] Update main.yml --- .github/workflows/main.yml | 68 ++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c601da0ae..55e8a87c0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,7 +67,16 @@ jobs: - name: Docker push run: | docker push lobozoldick/microservicio-java - + + deploy: + name: Deployment Google Cloud Run + runs-on: ubuntu-latest + needs: dockerbuild + if: success() + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Google Auth id: auth uses: 'google-github-actions/auth@v2' @@ -82,17 +91,62 @@ jobs: region: us-central1 source: ./ - - name: Show Output - run: echo ${{ steps.deploy.outputs.url }} - - name: Save token to file + - name: Save token and url to file run: | - gcloud auth print-identity-token + echo ${{ steps.deploy.outputs.url }} > url_cloud.txt gcloud auth print-identity-token > gcp_token.txt - - name: Execute Postman tests + - name: Archive artifact url + if: success() + uses: actions/upload-artifact@v3 + with: + name: url-cloud + path: url_cloud.txt + + - name: Archive artifact token + if: success() + uses: actions/upload-artifact@v3 + with: + name: gcp-token + path: gcp_token.txt + + postman: + name: Execute Postman + runs-on: ubuntu-latest + needs: deploy + if: success() + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download artifact url + uses: actions/download-artifact@v3 + with: + name: url-cloud + path: . + + - name: Download artifact token + uses: actions/download-artifact@v3 + with: + name: gcp-token + path: . + + - name: Download Node.js And Newman run: | + sudo apt-get install -y nodejs npm install -g newman + + - name: Run Postman tests + run: | export GCP_TOKEN=$(cat gcp_token.txt) - newman run Postman/scripts/pruebas_Aceptacion.postman_collection.json --env-var GCP_TOKEN=$GCP_TOKEN + export URL=$(cat url_cloud.txt) + newman run Postman/scripts/pruebas_Aceptacion.postman_collection.json --env-var GCP_TOKEN=$GCP_TOKEN --env-var URL=$URL + + #- name: Execute Postman tests + # run: | + # npm install -g newman + # export GCP_TOKEN=$(cat gcp_token.txt) + # export URL=$(cat url_cloud.txt) + # newman run Postman/scripts/pruebas_Aceptacion.postman_collection.json --env-var GCP_TOKEN=$GCP_TOKEN --env-var URL=$URL From 2265c28f731aea76a514d2feb39eb6d0f65bdc37 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 03:50:43 -0300 Subject: [PATCH 73/85] Update main.yml --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 55e8a87c0..127333344 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -79,7 +79,7 @@ jobs: - name: Google Auth id: auth - uses: 'google-github-actions/auth@v2' + uses: google-github-actions/auth@v2 with: credentials_json: '${{ secrets.GCP_CREDENTIALS }}' @@ -91,7 +91,6 @@ jobs: region: us-central1 source: ./ - - name: Save token and url to file run: | echo ${{ steps.deploy.outputs.url }} > url_cloud.txt From 0e1fd3ca7e4b2bce80c3180d545eaa71fa4f5ffa Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 03:56:12 -0300 Subject: [PATCH 74/85] Update main.yml --- .github/workflows/main.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 127333344..72bca7c60 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,13 +67,7 @@ jobs: - name: Docker push run: | docker push lobozoldick/microservicio-java - - deploy: - name: Deployment Google Cloud Run - runs-on: ubuntu-latest - needs: dockerbuild - if: success() - steps: + - name: Checkout code uses: actions/checkout@v3 @@ -113,7 +107,7 @@ jobs: postman: name: Execute Postman runs-on: ubuntu-latest - needs: deploy + needs: dockerbuild if: success() steps: - name: Checkout code From ec7fdb43f9e0e4a032ab80992a7c7c4c2d69ed1d Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 04:04:22 -0300 Subject: [PATCH 75/85] Update main.yml --- .github/workflows/main.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 72bca7c60..9869dcde5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,9 +67,6 @@ jobs: - name: Docker push run: | docker push lobozoldick/microservicio-java - - - name: Checkout code - uses: actions/checkout@v3 - name: Google Auth id: auth From 2a78f0063cdd9301892eae015394c51174db4cbd Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 04:20:36 -0300 Subject: [PATCH 76/85] Update main.yml --- .github/workflows/main.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9869dcde5..31969a659 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,7 +67,13 @@ jobs: - name: Docker push run: | docker push lobozoldick/microservicio-java - + + deploy: + name: Deployment Google Cloud Run + runs-on: ubuntu-latest + needs: dockerbuild + if: success() + steps: - name: Google Auth id: auth uses: google-github-actions/auth@v2 From 5227b986a9613cfbe0774117e7f7c791181ca200 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 04:28:54 -0300 Subject: [PATCH 77/85] Update main.yml --- .github/workflows/main.yml | 39 +++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 31969a659..55e4c5cd4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ on: jobs: build: - name: Build + name: Build App runs-on: ubuntu-latest steps: - name: Checkout code @@ -33,12 +33,35 @@ jobs: with: name: java-app path: build/libs/testing-web-0.0.1-SNAPSHOT.jar - - dockerbuild: - name: Docker build + + sonarcloud: + name: Analyze SonarCloud runs-on: ubuntu-latest needs: build if: success() + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Cache SonarCloud packages + uses: actions/cache@v3 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Analyze SonarCloud + run: | + chmod +x gradlew + #./gradlew jacocoTestReport sonar -Dsonar.login=${{ secrets.TOKEN_SONARCLOUD }} --info --stacktrace + + deploy: + name: Deployment Docker and Cloud Run + runs-on: ubuntu-latest + needs: sonarcloud + if: success() steps: - name: Checkout code uses: actions/checkout@v3 @@ -68,12 +91,6 @@ jobs: run: | docker push lobozoldick/microservicio-java - deploy: - name: Deployment Google Cloud Run - runs-on: ubuntu-latest - needs: dockerbuild - if: success() - steps: - name: Google Auth id: auth uses: google-github-actions/auth@v2 @@ -110,7 +127,7 @@ jobs: postman: name: Execute Postman runs-on: ubuntu-latest - needs: dockerbuild + needs: deploy if: success() steps: - name: Checkout code From 35a3e049f9d0ee2bed7af4972cdde4b894046d4f Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 15:46:30 -0300 Subject: [PATCH 78/85] Create LoadTest.jmx --- Jmeter/scripts/LoadTest.jmx | 175 ++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 Jmeter/scripts/LoadTest.jmx diff --git a/Jmeter/scripts/LoadTest.jmx b/Jmeter/scripts/LoadTest.jmx new file mode 100644 index 000000000..afafd6d1b --- /dev/null +++ b/Jmeter/scripts/LoadTest.jmx @@ -0,0 +1,175 @@ + + + + + false + false + false + + + + + + + continue + + 1 + false + + 1 + 1 + false + false + + + true + + + + + + Authorization + Bearer ${__FileToString(./gcp_token.txt,,TOKEN)} + + + + + + false + + + + false + = + true + + + + ${HOST} + ${PROTOCOLO} + / + GET + true + false + true + false + false + false + false + 6 + false + 0 + + + + beanshell + + + true + ${__FileToString(./url_cloud.txt,,URL)}; + +String[] datosURL = vars.get("URL").replaceAll("\n", "").split("://"); + +log.info("PROTOCOLO Variable: " + datosURL[0]); +log.info("HOST Variable: " + datosURL[1]); + +vars.put("PROTOCOLO", datosURL[0]); +vars.put("HOST", datosURL[1]); + +log.info("PROTOCOLO Variable: " + vars.get("PROTOCOLO")); +log.info("HOST Variable: " + vars.get("HOST")); + + +; +//log.info("BEARER_TOKEN Variable: " + vars.get("TOKEN")); + +//String token = vars.get("TOKEN").replaceAll("\n", ""); + +//vars.put("BEARER_TOKEN", "Bearer " + token); +//log.info("BEARER_TOKEN Variable: " + vars.get("BEARER_TOKEN")); + + + + + Lab Final DevOps-Fundamentos-v6 + + + Assertion.response_data + false + 8 + + + + + false + + + + ${HOST} + ${PROTOCOLO} + /greeting + GET + true + false + true + false + false + false + false + 6 + false + 0 + + + + + Lab Final DevOps-Fundamentos-v6 Greeting + + + Assertion.response_data + false + 8 + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + From 49b0812a0491285b6bc24f939a40cb8b68656f32 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 15:47:01 -0300 Subject: [PATCH 79/85] Update main.yml --- .github/workflows/main.yml | 55 +++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 55e4c5cd4..18d161cef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -116,6 +116,7 @@ jobs: with: name: url-cloud path: url_cloud.txt + if-no-files-found: error - name: Archive artifact token if: success() @@ -123,6 +124,7 @@ jobs: with: name: gcp-token path: gcp_token.txt + if-no-files-found: error postman: name: Execute Postman @@ -138,12 +140,14 @@ jobs: with: name: url-cloud path: . + if-no-files-found: error - name: Download artifact token uses: actions/download-artifact@v3 with: name: gcp-token path: . + if-no-files-found: error - name: Download Node.js And Newman run: | @@ -155,11 +159,50 @@ jobs: export GCP_TOKEN=$(cat gcp_token.txt) export URL=$(cat url_cloud.txt) newman run Postman/scripts/pruebas_Aceptacion.postman_collection.json --env-var GCP_TOKEN=$GCP_TOKEN --env-var URL=$URL + + jmeter: + name: Execute Jmeter + runs-on: ubuntu-latest + needs: deploy + if: success() + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download Apache JMeter + run: | + curl -LJO https://downloads.apache.org/jmeter/binaries/apache-jmeter-5.6.2.tgz + tar -xvzf apache-jmeter-5.6.2.tgz + + - name: Download artifact url + uses: actions/download-artifact@v3 + with: + name: url-cloud + path: apache-jmeter-5.6.2/ + if-no-files-found: error + + - name: Download artifact token + uses: actions/download-artifact@v3 + with: + name: gcp-token + path: apache-jmeter-5.6.2/ + if-no-files-found: error + + - name: Run JMeter tests + run: | + chmod -x apache-jmeter/bin/jmeter.sh + cd apache-jmeter-5.6.2 + mkdir reportHtml + ./bin/jmeter.sh -n -t Jmeter/scripts/LoadTest.jmx -e -o ./reportHtml -l testresult.jtl + + - name: Archive artifact jmeter-html-reports + if: success() + uses: actions/upload-artifact@v3 + with: + name: jmeter-html-reports + path: apache-jmeter-5.6.2/reportHtml + if-no-files-found: error + - #- name: Execute Postman tests - # run: | - # npm install -g newman - # export GCP_TOKEN=$(cat gcp_token.txt) - # export URL=$(cat url_cloud.txt) - # newman run Postman/scripts/pruebas_Aceptacion.postman_collection.json --env-var GCP_TOKEN=$GCP_TOKEN --env-var URL=$URL + From 59f9ac638f515182f37211d30515ea98b3442a66 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 15:54:05 -0300 Subject: [PATCH 80/85] Update main.yml --- .github/workflows/main.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 18d161cef..819edf5a3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -140,14 +140,12 @@ jobs: with: name: url-cloud path: . - if-no-files-found: error - name: Download artifact token uses: actions/download-artifact@v3 with: name: gcp-token path: . - if-no-files-found: error - name: Download Node.js And Newman run: | @@ -173,24 +171,25 @@ jobs: run: | curl -LJO https://downloads.apache.org/jmeter/binaries/apache-jmeter-5.6.2.tgz tar -xvzf apache-jmeter-5.6.2.tgz + ls -lash - name: Download artifact url uses: actions/download-artifact@v3 with: name: url-cloud path: apache-jmeter-5.6.2/ - if-no-files-found: error - name: Download artifact token uses: actions/download-artifact@v3 with: name: gcp-token path: apache-jmeter-5.6.2/ - if-no-files-found: error - name: Run JMeter tests + if: success() run: | - chmod -x apache-jmeter/bin/jmeter.sh + ls -lah + chmod -x apache-jmeter-5.6.2/bin/jmeter.sh cd apache-jmeter-5.6.2 mkdir reportHtml ./bin/jmeter.sh -n -t Jmeter/scripts/LoadTest.jmx -e -o ./reportHtml -l testresult.jtl From c3634de8a62049ad8ef62a4a4682634f5907337e Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 16:38:24 -0300 Subject: [PATCH 81/85] =?UTF-8?q?Finalizaci=C3=B3n=20de=20las=20pruebas=20?= =?UTF-8?q?de=20aceptaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 819edf5a3..0036373f0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -151,12 +151,21 @@ jobs: run: | sudo apt-get install -y nodejs npm install -g newman + npm install -g newman-reporter-htmlextra - name: Run Postman tests run: | export GCP_TOKEN=$(cat gcp_token.txt) export URL=$(cat url_cloud.txt) - newman run Postman/scripts/pruebas_Aceptacion.postman_collection.json --env-var GCP_TOKEN=$GCP_TOKEN --env-var URL=$URL + newman run Postman/scripts/pruebas_Aceptacion.postman_collection.json --env-var GCP_TOKEN=$GCP_TOKEN --env-var URL=$URL -r cli,htmlextra --reporter-htmlextra-export resultadoPostman.html + + - name: Archive result HTML Postman + if: success() + uses: actions/upload-artifact@v3 + with: + name: rwsultado-postman-html + path: resultadoPostman.html + if-no-files-found: error jmeter: name: Execute Jmeter From 28ceaf4addd11d20b91a29e0f32bc51b2a08eb75 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 16:44:29 -0300 Subject: [PATCH 82/85] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0036373f0..d2568a397 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -198,8 +198,8 @@ jobs: if: success() run: | ls -lah - chmod -x apache-jmeter-5.6.2/bin/jmeter.sh cd apache-jmeter-5.6.2 + chmod 755 bin/jmeter.sh mkdir reportHtml ./bin/jmeter.sh -n -t Jmeter/scripts/LoadTest.jmx -e -o ./reportHtml -l testresult.jtl From 651baf7ddfb31faa5660c336d059bc391e69b7e5 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 16:58:39 -0300 Subject: [PATCH 83/85] Update main.yml --- .github/workflows/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d2568a397..7d04675e7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -163,7 +163,7 @@ jobs: if: success() uses: actions/upload-artifact@v3 with: - name: rwsultado-postman-html + name: resultado-postman-html path: resultadoPostman.html if-no-files-found: error @@ -199,9 +199,10 @@ jobs: run: | ls -lah cd apache-jmeter-5.6.2 + ls -lah chmod 755 bin/jmeter.sh mkdir reportHtml - ./bin/jmeter.sh -n -t Jmeter/scripts/LoadTest.jmx -e -o ./reportHtml -l testresult.jtl + ./bin/jmeter.sh -n -t $GITHUB_WORKSPACE/Jmeter/scripts/LoadTest.jmx -e -o ./reportHtml -l testresult.jtl - name: Archive artifact jmeter-html-reports if: success() From 10e4300480af4f2adfc1aeb8fec1de80fdd13402 Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Fri, 22 Dec 2023 17:03:00 -0300 Subject: [PATCH 84/85] =?UTF-8?q?Finalizaci=C3=B3n=20del=20pipeline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7d04675e7..f53f32e7a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,7 +55,7 @@ jobs: - name: Analyze SonarCloud run: | chmod +x gradlew - #./gradlew jacocoTestReport sonar -Dsonar.login=${{ secrets.TOKEN_SONARCLOUD }} --info --stacktrace + ./gradlew jacocoTestReport sonar -Dsonar.login=${{ secrets.TOKEN_SONARCLOUD }} --info --stacktrace deploy: name: Deployment Docker and Cloud Run From 842135497236e3be109090caa3a367c665ce737f Mon Sep 17 00:00:00 2001 From: lobozoldick Date: Wed, 22 May 2024 15:48:06 -0400 Subject: [PATCH 85/85] Prueba DUOC --- .../java/com/example/testingweb/SmokeTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/java/com/example/testingweb/SmokeTest.java b/src/test/java/com/example/testingweb/SmokeTest.java index 5b69622bb..46616323c 100644 --- a/src/test/java/com/example/testingweb/SmokeTest.java +++ b/src/test/java/com/example/testingweb/SmokeTest.java @@ -17,4 +17,19 @@ public class SmokeTest { public void contextLoads() throws Exception { assertThat(controller).isNotNull(); } + + @Test + public void contextLoads1() throws Exception { + assertThat(controller).isNotNull(); + } + + @Test + public void contextLoads2() throws Exception { + assertThat(controller).isNotNull(); + } + + @Test + public void contextLoads3() throws Exception { + assertThat(controller).isNotNull(); + } }