mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-16 05:16:08 +02:00
parent
3ba7a8dfa4
commit
e5f2f1414e
97
.github/workflows/integration-tests-pr.yaml
vendored
97
.github/workflows/integration-tests-pr.yaml
vendored
@ -1,97 +0,0 @@
|
||||
name: Integration Tests (Pull Request)
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
|
||||
consumer-tests:
|
||||
name: Consumer Tests
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.comment.body == '/it' && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER')
|
||||
|
||||
steps:
|
||||
- name: get pull request url
|
||||
id: pullrequest
|
||||
run: echo "::set-output name=pullrequest::$(curl ${{ github.event.comment.issue_url }} | jq '.pull_request.url' | sed 's/\"//g')"
|
||||
- name: get branch name
|
||||
id: branchname
|
||||
run: echo "::set-output name=branchname::$(curl ${{ steps.pullrequest.outputs.pullrequest }} | jq '.head.ref' | sed 's/\"//g')"
|
||||
- name: get repository
|
||||
id: repository
|
||||
run: echo "::set-output name=repository::$(curl ${{ steps.pullrequest.outputs.pullrequest }} | jq '.head.repo.full_name' | sed 's/\"//g')"
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: ${{ steps.repository.outputs.repository }}
|
||||
ref: ${{ steps.branchname.outputs.branchname }}
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: '11'
|
||||
- name: install groovy
|
||||
run: sudo apt-get update && sudo apt-get install groovy -y
|
||||
- name: setup git
|
||||
run: git config --global user.email "piper-testing-bot@example.com" && git config --global user.name "piper-testing-bot"
|
||||
- name: run consumer tests
|
||||
run: cd consumer-test && groovy consumerTestController.groovy
|
||||
env:
|
||||
REPOSITORY_UNDER_TEST: ${{ steps.repository.outputs.repository }}
|
||||
BRANCH_NAME: ${{ steps.branchname.outputs.branchname }}
|
||||
BUILD_WEB_URL: https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}
|
||||
INTEGRATION_TEST_VOTING_TOKEN: ${{ secrets.INTEGRATION_TEST_VOTING_TOKEN }}
|
||||
CX_INFRA_IT_CF_USERNAME: ${{ secrets.CX_INFRA_IT_CF_USERNAME }}
|
||||
CX_INFRA_IT_CF_PASSWORD: ${{ secrets.CX_INFRA_IT_CF_PASSWORD }}
|
||||
NEO_DEPLOY_USERNAME: ${{ secrets.NEO_DEPLOY_USERNAME }}
|
||||
NEO_DEPLOY_PASSWORD: ${{ secrets.NEO_DEPLOY_PASSWORD }}
|
||||
CX_INFRA_IT_TMS_UPLOAD: ${{ secrets.CX_INFRA_IT_TMS_UPLOAD }}
|
||||
|
||||
go-integration-tests:
|
||||
name: Go Integration Tests
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
if: (github.event.comment.body == '/it' || github.event.comment.body == '/it-go') && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER')
|
||||
|
||||
steps:
|
||||
- name: get pull request url
|
||||
id: pullrequest
|
||||
run: echo "::set-output name=pullrequest::$(curl ${{ github.event.comment.issue_url }} | jq '.pull_request.url' | sed 's/\"//g')"
|
||||
- name: get branch name
|
||||
id: branchname
|
||||
run: echo "::set-output name=branchname::$(curl ${{ steps.pullrequest.outputs.pullrequest }} | jq '.head.ref' | sed 's/\"//g')"
|
||||
- name: get repository
|
||||
id: repository
|
||||
run: echo "::set-output name=repository::$(curl ${{ steps.pullrequest.outputs.pullrequest }} | jq '.head.repo.full_name' | sed 's/\"//g')"
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: ${{ steps.repository.outputs.repository }}
|
||||
ref: ${{ steps.branchname.outputs.branchname }}
|
||||
- name: get commit id
|
||||
id: commitId
|
||||
run: echo "::set-output name=commitId::$(git log --format=%H -n 1)"
|
||||
- name: update status
|
||||
run: |
|
||||
curl --location --request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ steps.commitId.outputs.commitId }}' -H 'Content-Type: application/json' --data '{"state": "pending", "context": "Go / integration-tests", "target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}' -H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}'
|
||||
- uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '1.18.x'
|
||||
- name: build
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
# with `-tags release` we ensure that shared test utilities won't end up in the binary
|
||||
run: go build -o piper -tags release
|
||||
- name: test
|
||||
env:
|
||||
PIPER_INTEGRATION_GITHUB_TOKEN: ${{secrets.PIPER_INTEGRATION_GITHUB_TOKEN}}
|
||||
PIPER_INTEGRATION_SONAR_TOKEN: ${{secrets.PIPER_INTEGRATION_SONAR_TOKEN}}
|
||||
run: go test -tags=integration -timeout 25m ./integration/...
|
||||
- name: update status
|
||||
if: success()
|
||||
run: |
|
||||
curl --location --request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ steps.commitId.outputs.commitId }}' -H 'Content-Type: application/json' --data '{"state": "success", "context": "Go / integration-tests", "target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}' -H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}'
|
||||
- name: update status
|
||||
if: cancelled() || failure()
|
||||
run: |
|
||||
curl --location --request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ steps.commitId.outputs.commitId }}' -H 'Content-Type: application/json' --data '{"state": "failure", "context": "Go / integration-tests", "target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}' -H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}'
|
76
.github/workflows/integration-tests.yaml
vendored
76
.github/workflows/integration-tests.yaml
vendored
@ -1,76 +0,0 @@
|
||||
name: Integration Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- it/**
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
consumer-tests:
|
||||
name: Consumer Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: '11'
|
||||
- name: install groovy
|
||||
run: sudo apt-get update && sudo apt-get install groovy -y
|
||||
- name: setup git
|
||||
run: git config --global user.email "piper-testing-bot@example.com" && git config --global user.name "piper-testing-bot"
|
||||
- name: get branch name
|
||||
id: branchname
|
||||
run: echo "::set-output name=branchname::$(echo ${GITHUB_REF#refs/heads/})"
|
||||
- name: run consumer tests
|
||||
run: cd consumer-test && groovy consumerTestController.groovy
|
||||
env:
|
||||
REPOSITORY_UNDER_TEST: ${{ github.repository }}
|
||||
BRANCH_NAME: ${{ steps.branchname.outputs.branchname }}
|
||||
BUILD_WEB_URL: https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}
|
||||
INTEGRATION_TEST_VOTING_TOKEN: ${{ secrets.INTEGRATION_TEST_VOTING_TOKEN }}
|
||||
CX_INFRA_IT_CF_USERNAME: ${{ secrets.CX_INFRA_IT_CF_USERNAME }}
|
||||
CX_INFRA_IT_CF_PASSWORD: ${{ secrets.CX_INFRA_IT_CF_PASSWORD }}
|
||||
NEO_DEPLOY_USERNAME: ${{ secrets.NEO_DEPLOY_USERNAME }}
|
||||
NEO_DEPLOY_PASSWORD: ${{ secrets.NEO_DEPLOY_PASSWORD }}
|
||||
CX_INFRA_IT_TMS_UPLOAD: ${{ secrets.CX_INFRA_IT_TMS_UPLOAD }}
|
||||
|
||||
go-integration-tests:
|
||||
name: Go Integration Tests
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: get commit id
|
||||
id: commitId
|
||||
run: echo "::set-output name=commitId::$(git log --format=%H -n 1)"
|
||||
- name: update status
|
||||
run: |
|
||||
curl --location --request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ steps.commitId.outputs.commitId }}' -H 'Content-Type: application/json' --data '{"state": "pending", "context": "Go / integration-tests", "target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}' -H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}'
|
||||
- uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '1.18.x'
|
||||
- name: build
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
# with `-tags release` we ensure that shared test utilities won't end up in the binary
|
||||
run: go build -o piper -tags release
|
||||
- name: test
|
||||
env:
|
||||
PIPER_INTEGRATION_GITHUB_TOKEN: ${{secrets.PIPER_INTEGRATION_GITHUB_TOKEN}}
|
||||
PIPER_INTEGRATION_SONAR_TOKEN: ${{secrets.PIPER_INTEGRATION_SONAR_TOKEN}}
|
||||
run: go test -tags=integration -timeout 25m ./integration/...
|
||||
- name: update status
|
||||
if: success()
|
||||
run: |
|
||||
curl --location --request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ steps.commitId.outputs.commitId }}' -H 'Content-Type: application/json' --data '{"state": "success", "context": "Go / integration-tests", "target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}' -H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}'
|
||||
- name: update status
|
||||
if: cancelled() || failure()
|
||||
run: |
|
||||
curl --location --request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ steps.commitId.outputs.commitId }}' -H 'Content-Type: application/json' --data '{"state": "failure", "context": "Go / integration-tests", "target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}' -H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}'
|
204
.github/workflows/integration-tests.yml
vendored
Normal file
204
.github/workflows/integration-tests.yml
vendored
Normal file
@ -0,0 +1,204 @@
|
||||
name: Integration tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- it/**
|
||||
issue_comment:
|
||||
types:
|
||||
- created
|
||||
|
||||
env:
|
||||
GHA_UBUNTU_VERSION: ubuntu-latest
|
||||
|
||||
GHA_CHECKOUT_VERSION: actions/checkout@v3
|
||||
GHA_SETUP_GO_VERSION: actions/setup-go@v3
|
||||
GHA_SETUP_JAVA_VERSION: actions/setup-java@v3
|
||||
GHA_UPLOAD_ARTIFACT_VERSION: actions/upload-artifact@v3
|
||||
GHA_DOWNLOAD_ARTIFACT_VERSION: actions/download-artifact@v3
|
||||
|
||||
JAVA_VERSION: '11'
|
||||
|
||||
CGO_ENABLED: 0
|
||||
GHA_GO_VERSION: '1.18.x'
|
||||
TIMEOUT: '10m'
|
||||
|
||||
PIPER_INTEGRATION_GITHUB_TOKEN: ${{secrets.PIPER_INTEGRATION_GITHUB_TOKEN}}
|
||||
PIPER_INTEGRATION_SONAR_TOKEN: ${{secrets.PIPER_INTEGRATION_SONAR_TOKEN}}
|
||||
|
||||
jobs:
|
||||
start:
|
||||
name: Start
|
||||
runs-on: ${{ env.GHA_UBUNTU_VERSION }}
|
||||
if: |
|
||||
github.event.comment.body == '/it' &&
|
||||
(
|
||||
github.event.comment.author_association == 'COLLABORATOR' ||
|
||||
github.event.comment.author_association == 'OWNER' ||
|
||||
github.event.comment.author_association == 'MEMBER'
|
||||
)
|
||||
steps:
|
||||
- name: Get PR's URL
|
||||
id: pull_request
|
||||
run: |
|
||||
echo "::set-output name=pull_request::$(curl ${{ github.event.comment.issue_url }} | jq '.pull_request.url' | sed 's/\"//g')"
|
||||
- name: Get branch name
|
||||
id: branch_name
|
||||
run: |
|
||||
echo "::set-output name=branch_name::$(curl ${{ steps.pull_request.outputs.pull_request }} | jq '.head.ref' | sed 's/\"//g')"
|
||||
- name: Get repository
|
||||
id: repository
|
||||
run: |
|
||||
echo "::set-output name=repository::$(curl ${{ steps.pull_request.outputs.pull_request }} | jq '.head.repo.full_name' | sed 's/\"//g')"
|
||||
- name: Get commit id
|
||||
id: commit_it
|
||||
run: |
|
||||
echo "::set-output name=commit_it::$(git log --format=%H -n 1)"
|
||||
- name: Update status
|
||||
run: |
|
||||
curl
|
||||
--location
|
||||
--request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ steps.commit_id.outputs.commit_id }}'
|
||||
-H 'Content-Type: application/json'
|
||||
--data '{"state": "pending",
|
||||
"context": "Go / integration-tests",
|
||||
"target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}'
|
||||
-H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}'
|
||||
outputs:
|
||||
branch_name: ${{ steps.branch_name.outputs.branch_name }}
|
||||
repository: ${{ steps.repository.outputs.repository }}
|
||||
commit_id: ${{ steps.commit_id.outputs.commit_id }}
|
||||
|
||||
consumer_tests:
|
||||
name: Consumer tests
|
||||
needs:
|
||||
- start
|
||||
runs-on: ${{ env.GHA_UBUNTU_VERSION }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: ${{ env.GHA_CHECKOUT_VERSION }}
|
||||
with:
|
||||
repository: ${{ needs.start.outputs.repository }}
|
||||
ref: ${{ needs.start.outputs.branch_name }}
|
||||
- uses: ${{ env.GHA_SETUP_JAVA_VERSION }}
|
||||
with:
|
||||
java-version: ${{ env.JAVA_VERSION }}
|
||||
- name: Install Groovy
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install groovy -y
|
||||
- name: Setup Git
|
||||
run: |
|
||||
git config --global user.email "piper-testing-bot@example.com" && git config --global user.name "piper-testing-bot"
|
||||
- name: Run tests
|
||||
env:
|
||||
REPOSITORY_UNDER_TEST: ${{ needs.start.outputs.repository }}
|
||||
BRANCH_NAME: ${{ needs.start.outputs.branch_name }}
|
||||
BUILD_WEB_URL: https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}
|
||||
INTEGRATION_TEST_VOTING_TOKEN: ${{ secrets.INTEGRATION_TEST_VOTING_TOKEN }}
|
||||
CX_INFRA_IT_CF_USERNAME: ${{ secrets.CX_INFRA_IT_CF_USERNAME }}
|
||||
CX_INFRA_IT_CF_PASSWORD: ${{ secrets.CX_INFRA_IT_CF_PASSWORD }}
|
||||
NEO_DEPLOY_USERNAME: ${{ secrets.NEO_DEPLOY_USERNAME }}
|
||||
NEO_DEPLOY_PASSWORD: ${{ secrets.NEO_DEPLOY_PASSWORD }}
|
||||
CX_INFRA_IT_TMS_UPLOAD: ${{ secrets.CX_INFRA_IT_TMS_UPLOAD }}
|
||||
run: |
|
||||
cd consumer-test && groovy consumerTestController.groovy
|
||||
|
||||
build_piper:
|
||||
name: Build Piper
|
||||
needs:
|
||||
- start
|
||||
runs-on: ${{ env.GHA_UBUNTU_VERSION }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: ${{ env.GHA_CHECKOUT_VERSION }}
|
||||
with:
|
||||
repository: ${{ needs.start.outputs.repository }}
|
||||
ref: ${{ needs.start.outputs.branch_name }}
|
||||
- uses: ${{ env.GHA_SETUP_GO_VERSION }}
|
||||
with:
|
||||
go-version: ${{ env.GHA_GO_VERSION }}
|
||||
- name: Build
|
||||
# with `-tags release` we ensure that shared test utilities won't end up in the binary
|
||||
run: go build -o piper -tags release
|
||||
- name: Upload Piper binary
|
||||
if: success()
|
||||
uses: ${{ env.GHA_UPLOAD_ARTIFACT_VERSION }}
|
||||
with:
|
||||
path: piper
|
||||
|
||||
integration_tests:
|
||||
name: Integration tests
|
||||
needs:
|
||||
- build_piper
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
os:
|
||||
- ${{ env.GHA_UBUNTU_VERSION }}
|
||||
version:
|
||||
- 'TestCNBIntegration'
|
||||
- 'TestGaugeIntegration'
|
||||
- 'TestGCSIntegration'
|
||||
- 'TestGitHubIntegration'
|
||||
- 'TestGitOpsIntegration'
|
||||
- 'TestGolangIntegration'
|
||||
- 'TestGradleIntegration'
|
||||
- 'TestInfluxIntegration'
|
||||
# - 'TestJenkinsIntegration'
|
||||
- 'TestKarmaIntegration'
|
||||
- 'TestMavenIntegration'
|
||||
- 'TestMTAIntegration'
|
||||
- 'TestNexusIntegration'
|
||||
- 'TestNPMIntegration'
|
||||
- 'TestPiperIntegration'
|
||||
- 'TestPythonIntegration'
|
||||
- 'TestSonarIntegration'
|
||||
- 'TestVaultIntegration'
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: ${{ env.GHA_CHECKOUT_VERSION }}
|
||||
with:
|
||||
repository: ${{ needs.start.outputs.repository }}
|
||||
ref: ${{ needs.start.outputs.branch_name }}
|
||||
- uses: ${{ env.GHA_SETUP_GO_VERSION }}
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
- name: Download Piper binary
|
||||
uses: ${{ env.GHA_DOWNLOAD_ARTIFACT_VERSION }}
|
||||
with:
|
||||
name: piper
|
||||
- name: Run test
|
||||
run: go test -v -tags integration -timeout ${ env.TIMEOUT }} -run ${{ matrix.version }} ./integration/...
|
||||
|
||||
Finis:
|
||||
name: Finis
|
||||
if: always()
|
||||
needs:
|
||||
- build_piper
|
||||
- integration_tests
|
||||
runs-on: ${{ env.GHA_UBUNTU_VERSION }}
|
||||
steps:
|
||||
- name: Update status
|
||||
run: |
|
||||
if [[ ${{ contains(jobs.IntegrationTests.result, "success") }} ]]
|
||||
then
|
||||
curl
|
||||
--location
|
||||
--request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ needs.start.outputs.commit_id }}'
|
||||
-H 'Content-Type: application/json'
|
||||
--data '{"state": "success",
|
||||
"context": "Go / integration-tests",
|
||||
"target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}'
|
||||
-H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}'
|
||||
else
|
||||
curl
|
||||
--location
|
||||
--request POST 'https://api.github.com/repos/SAP/jenkins-library/statuses/${{ needs.start.outputs.commit_id }}'
|
||||
-H 'Content-Type: application/json'
|
||||
--data '{"state": "failure",
|
||||
"context": "Go / integration-tests",
|
||||
"target_url": "https://github.com/SAP/jenkins-library/actions/runs/${{ github.run_id }}"}'
|
||||
-H 'Authorization: token ${{secrets.INTEGRATION_TEST_VOTING_TOKEN}}'
|
||||
fi
|
@ -5,6 +5,7 @@ package main
|
||||
|
||||
import (
|
||||
"archive/tar"
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
@ -62,6 +63,7 @@ type IntegrationTestDockerExecRunner struct {
|
||||
}
|
||||
|
||||
func givenThisContainer(t *testing.T, bundle IntegrationTestDockerExecRunnerBundle) IntegrationTestDockerExecRunner {
|
||||
|
||||
runner := command.Command{}
|
||||
containerName := generateContainerName()
|
||||
|
||||
@ -134,11 +136,11 @@ func givenThisContainer(t *testing.T, bundle IntegrationTestDockerExecRunnerBund
|
||||
}
|
||||
}
|
||||
|
||||
for _, scriptLine := range testRunner.Setup {
|
||||
err := testRunner.Runner.RunExecutable("docker", "exec", testRunner.ContainerName, "/bin/sh", "-c", scriptLine)
|
||||
if err != nil {
|
||||
t.Fatalf("Running setup script in test container has failed %s", err)
|
||||
}
|
||||
if err = testRunner.Runner.RunExecutable(
|
||||
"docker", "exec", testRunner.ContainerName, "sh", "-c",
|
||||
strings.Join(testRunner.Setup, "\n"),
|
||||
); err != nil {
|
||||
t.Fatalf("Running setup script in test container has failed %s", err)
|
||||
}
|
||||
|
||||
setupPiperBinary(t, testRunner, localPiper)
|
||||
@ -146,7 +148,7 @@ func givenThisContainer(t *testing.T, bundle IntegrationTestDockerExecRunnerBund
|
||||
return testRunner
|
||||
}
|
||||
|
||||
// generateContainerName creates a name with a common prefix and a random number so we can start a new container for each test method
|
||||
// generateContainerName creates a name with a common prefix and a random number, so we can start a new container for each test method
|
||||
// We don't rely on docker's random name generator for two reasons
|
||||
// First, it is easier to save the name here compared to getting it from stdout
|
||||
// Second, the common prefix allows batch stopping/deleting of containers if so desired
|
||||
@ -184,8 +186,7 @@ func (d *IntegrationTestDockerExecRunner) whenRunningPiperCommand(command string
|
||||
}
|
||||
|
||||
args = append(args, "/piper-wrapper", "/piper", command)
|
||||
args = append(args, parameters...)
|
||||
err := d.Runner.RunExecutable("docker", args...)
|
||||
err := d.Runner.RunExecutable("docker", append(args, parameters...)...)
|
||||
if err != nil {
|
||||
stdOut, err := d.getPiperOutput()
|
||||
return errors.Wrapf(err, "piper output: \n%s", stdOut.String())
|
||||
@ -204,26 +205,43 @@ func (d *IntegrationTestDockerExecRunner) runScriptInsideContainer(script string
|
||||
return d.Runner.RunExecutable("docker", args...)
|
||||
}
|
||||
|
||||
func (d *IntegrationTestDockerExecRunner) assertHasNoOutput(t *testing.T, want string) {
|
||||
func (d *IntegrationTestDockerExecRunner) assertHasNoOutput(t *testing.T, inconsistencies ...string) {
|
||||
count := len(inconsistencies)
|
||||
buffer, err := d.getPiperOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get log output of container %s", d.ContainerName)
|
||||
}
|
||||
|
||||
if strings.Contains(buffer.String(), want) {
|
||||
assert.Equal(t, buffer.String(), want, "Unexpected command output")
|
||||
scanner := bufio.NewScanner(buffer)
|
||||
for scanner.Scan() && (len(inconsistencies) != 0) {
|
||||
for i, str := range inconsistencies {
|
||||
if strings.Contains(scanner.Text(), str) {
|
||||
inconsistencies = append(inconsistencies[:i], inconsistencies[i+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
assert.Equal(t, len(inconsistencies), count, fmt.Sprintf(
|
||||
"[assertHasNoOutput] Unexpected command output:\n%s\n%s\n", buffer.String(), strings.Join(inconsistencies, "\n")),
|
||||
)
|
||||
}
|
||||
|
||||
func (d *IntegrationTestDockerExecRunner) assertHasOutput(t *testing.T, want string) {
|
||||
func (d *IntegrationTestDockerExecRunner) assertHasOutput(t *testing.T, consistencies ...string) {
|
||||
buffer, err := d.getPiperOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get log output of container %s", d.ContainerName)
|
||||
}
|
||||
|
||||
if !strings.Contains(buffer.String(), want) {
|
||||
assert.Equal(t, buffer.String(), want, "Unexpected command output")
|
||||
scanner := bufio.NewScanner(buffer)
|
||||
for scanner.Scan() && (len(consistencies) != 0) {
|
||||
for i, str := range consistencies {
|
||||
if strings.Contains(scanner.Text(), str) {
|
||||
consistencies = append(consistencies[:i], consistencies[i+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
assert.Equal(t, len(consistencies), 0, fmt.Sprintf(
|
||||
"[assertHasOutput] Unexpected command output:\n%s\n%s\n", buffer.String(), strings.Join(consistencies, "\n")),
|
||||
)
|
||||
}
|
||||
|
||||
func (d *IntegrationTestDockerExecRunner) getPiperOutput() (*bytes.Buffer, error) {
|
||||
@ -234,15 +252,19 @@ func (d *IntegrationTestDockerExecRunner) getPiperOutput() (*bytes.Buffer, error
|
||||
return buffer, err
|
||||
}
|
||||
|
||||
func (d *IntegrationTestDockerExecRunner) assertHasFile(t *testing.T, want string) {
|
||||
err := d.Runner.RunExecutable("docker", "exec", d.ContainerName, "stat", want)
|
||||
if err != nil {
|
||||
t.Fatalf("Assertion has failed. Expected file %s to exist in container. %s", want, err)
|
||||
func (d *IntegrationTestDockerExecRunner) assertHasFiles(t *testing.T, consistencies ...string) {
|
||||
buffer := new(bytes.Buffer)
|
||||
d.Runner.Stderr(buffer)
|
||||
if d.Runner.RunExecutable(
|
||||
"docker",
|
||||
append(append(make([]string, 0), "exec", d.ContainerName, "stat"), consistencies...)...,
|
||||
) != nil {
|
||||
t.Fatalf("[assertHasFiles] Assertion has failed: %v", errors.New(buffer.String()))
|
||||
}
|
||||
}
|
||||
|
||||
func (d *IntegrationTestDockerExecRunner) assertFileContentEquals(t *testing.T, fileWant string, contentWant string) {
|
||||
d.assertHasFile(t, fileWant)
|
||||
d.assertHasFiles(t, fileWant)
|
||||
|
||||
buffer := new(bytes.Buffer)
|
||||
d.Runner.Stdout(buffer)
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be executed with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestCNBIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -34,7 +35,7 @@ func setupDockerRegistry(t *testing.T, ctx context.Context) testcontainers.Conta
|
||||
return regContainer
|
||||
}
|
||||
|
||||
func TestNpmProject(t *testing.T) {
|
||||
func TestCNBIntegrationNPMProject(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
registryContainer := setupDockerRegistry(t, ctx)
|
||||
@ -46,6 +47,7 @@ func TestNpmProject(t *testing.T) {
|
||||
TestDir: []string{"testdata"},
|
||||
Network: fmt.Sprintf("container:%s", registryContainer.GetContainerID()),
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
container2 := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
||||
Image: baseBuilder,
|
||||
@ -53,6 +55,7 @@ func TestNpmProject(t *testing.T) {
|
||||
TestDir: []string{"testdata"},
|
||||
Network: fmt.Sprintf("container:%s", registryContainer.GetContainerID()),
|
||||
})
|
||||
defer container2.terminate(t)
|
||||
|
||||
err := container.whenRunningPiperCommand("cnbBuild", "--noTelemetry", "--verbose", "--path", "TestCnbIntegration/project", "--customConfig", "TestCnbIntegration/config.yml", "--containerImageName", "node", "--containerImageTag", "0.0.1", "--containerRegistryUrl", registryURL)
|
||||
assert.NoError(t, err)
|
||||
@ -75,7 +78,7 @@ func TestNpmProject(t *testing.T) {
|
||||
container2.terminate(t)
|
||||
}
|
||||
|
||||
func TestProjectDescriptor(t *testing.T) {
|
||||
func TestCNBIntegrationProjectDescriptor(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
registryContainer := setupDockerRegistry(t, ctx)
|
||||
@ -87,24 +90,25 @@ func TestProjectDescriptor(t *testing.T) {
|
||||
TestDir: []string{"testdata", "TestCnbIntegration", "project"},
|
||||
Network: fmt.Sprintf("container:%s", registryContainer.GetContainerID()),
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
container.whenRunningPiperCommand("cnbBuild", "--noTelemetry", "--verbose", "--containerImageName", "not-found", "--containerImageTag", "0.0.1", "--containerRegistryUrl", registryURL)
|
||||
|
||||
container.assertHasOutput(t, "running command: /cnb/lifecycle/creator")
|
||||
container.assertHasOutput(t, "Dockerfile doesn't match include pattern, ignoring")
|
||||
container.assertHasOutput(t, "srv/hello.js matches include pattern")
|
||||
container.assertHasOutput(t, "package.json matches include pattern")
|
||||
container.assertHasOutput(t, "Downloading buildpack")
|
||||
container.assertHasOutput(t, "Setting custom environment variables: 'map[BP_NODE_VERSION:16 TMPDIR:/tmp/cnbBuild-")
|
||||
container.assertHasOutput(t, "Selected Node Engine version (using BP_NODE_VERSION): 16")
|
||||
container.assertHasOutput(t, "Paketo NPM Start Buildpack")
|
||||
container.assertHasOutput(t, fmt.Sprintf("Saving %s/not-found:0.0.1", registryURL))
|
||||
container.assertHasOutput(t, "*** Images (sha256:")
|
||||
container.assertHasOutput(t, "SUCCESS")
|
||||
container.terminate(t)
|
||||
container.assertHasOutput(t, "running command: /cnb/lifecycle/creator",
|
||||
"Dockerfile doesn't match include pattern, ignoring",
|
||||
"srv/hello.js matches include pattern",
|
||||
"package.json matches include pattern",
|
||||
"Downloading buildpack",
|
||||
"Setting custom environment variables: 'map[BP_NODE_VERSION:16 TMPDIR:/tmp/cnbBuild-",
|
||||
"Selected Node Engine version (using BP_NODE_VERSION): 16",
|
||||
"Paketo NPM Start Buildpack",
|
||||
fmt.Sprintf("Saving %s/not-found:0.0.1", registryURL),
|
||||
"*** Images (sha256:",
|
||||
"SUCCESS",
|
||||
)
|
||||
}
|
||||
|
||||
func TestZipPath(t *testing.T) {
|
||||
func TestCNBIntegrationZipPath(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
registryContainer := setupDockerRegistry(t, ctx)
|
||||
@ -116,19 +120,21 @@ func TestZipPath(t *testing.T) {
|
||||
TestDir: []string{"testdata", "TestCnbIntegration", "zip"},
|
||||
Network: fmt.Sprintf("container:%s", registryContainer.GetContainerID()),
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
container.whenRunningPiperCommand("cnbBuild", "--noTelemetry", "--verbose", "--containerImageName", "not-found", "--containerImageTag", "0.0.1", "--containerRegistryUrl", registryURL, "--path", "go.zip")
|
||||
|
||||
container.assertHasOutput(t, "running command: /cnb/lifecycle/creator")
|
||||
container.assertHasOutput(t, "Installing Go")
|
||||
container.assertHasOutput(t, "Paketo Go Build Buildpack")
|
||||
container.assertHasOutput(t, fmt.Sprintf("Saving %s/not-found:0.0.1", registryURL))
|
||||
container.assertHasOutput(t, "*** Images (sha256:")
|
||||
container.assertHasOutput(t, "SUCCESS")
|
||||
container.terminate(t)
|
||||
container.assertHasOutput(t,
|
||||
"running command: /cnb/lifecycle/creator",
|
||||
"Installing Go",
|
||||
"Paketo Go Build Buildpack",
|
||||
fmt.Sprintf("Saving %s/not-found:0.0.1", registryURL),
|
||||
"*** Images (sha256:",
|
||||
"SUCCESS",
|
||||
)
|
||||
}
|
||||
|
||||
func TestNonZipPath(t *testing.T) {
|
||||
func TestCNBIntegrationNonZipPath(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
registryContainer := setupDockerRegistry(t, ctx)
|
||||
@ -140,14 +146,14 @@ func TestNonZipPath(t *testing.T) {
|
||||
TestDir: []string{"testdata", "TestMtaIntegration", "npm"},
|
||||
Network: fmt.Sprintf("container:%s", registryContainer.GetContainerID()),
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
container.whenRunningPiperCommand("cnbBuild", "--noTelemetry", "--verbose", "--containerImageName", "not-found", "--containerImageTag", "0.0.1", "--containerRegistryUrl", registryURL, "--path", "mta.yaml")
|
||||
|
||||
container.assertHasOutput(t, "Copying '/project/mta.yaml' into '/workspace' failed: application path must be a directory or zip")
|
||||
container.terminate(t)
|
||||
}
|
||||
|
||||
func TestNpmCustomBuildpacksFullProject(t *testing.T) {
|
||||
func TestCNBIntegrationNPMCustomBuildpacksFullProject(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
registryContainer := setupDockerRegistry(t, ctx)
|
||||
@ -159,20 +165,22 @@ func TestNpmCustomBuildpacksFullProject(t *testing.T) {
|
||||
TestDir: []string{"testdata", "TestMtaIntegration", "npm"},
|
||||
Network: fmt.Sprintf("container:%s", registryContainer.GetContainerID()),
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
container.whenRunningPiperCommand("cnbBuild", "--noTelemetry", "--verbose", "--buildpacks", "gcr.io/paketo-buildpacks/nodejs:0.19.0", "--containerImageName", "not-found", "--containerImageTag", "0.0.1", "--containerRegistryUrl", registryURL)
|
||||
|
||||
container.assertHasOutput(t, "Setting custom buildpacks: '[gcr.io/paketo-buildpacks/nodejs:0.19.0]'")
|
||||
container.assertHasOutput(t, "Downloading buildpack 'gcr.io/paketo-buildpacks/nodejs:0.19.0' to /tmp/buildpacks_cache/sha256:")
|
||||
container.assertHasOutput(t, "running command: /cnb/lifecycle/creator")
|
||||
container.assertHasOutput(t, "Paketo NPM Start Buildpack")
|
||||
container.assertHasOutput(t, fmt.Sprintf("Saving %s/not-found:0.0.1", registryURL))
|
||||
container.assertHasOutput(t, "*** Images (sha256:")
|
||||
container.assertHasOutput(t, "SUCCESS")
|
||||
container.terminate(t)
|
||||
container.assertHasOutput(t,
|
||||
"Setting custom buildpacks: '[gcr.io/paketo-buildpacks/nodejs:0.19.0]'",
|
||||
"Downloading buildpack 'gcr.io/paketo-buildpacks/nodejs:0.19.0' to /tmp/buildpacks_cache/sha256:",
|
||||
"running command: /cnb/lifecycle/creator",
|
||||
"Paketo NPM Start Buildpack",
|
||||
fmt.Sprintf("Saving %s/not-found:0.0.1", registryURL),
|
||||
"*** Images (sha256:",
|
||||
"SUCCESS",
|
||||
)
|
||||
}
|
||||
|
||||
func TestNpmCustomBuildpacksBuildpacklessProject(t *testing.T) {
|
||||
func TestCNBIntegrationNPMCustomBuildpacksBuildpacklessProject(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
registryContainer := setupDockerRegistry(t, ctx)
|
||||
@ -184,33 +192,34 @@ func TestNpmCustomBuildpacksBuildpacklessProject(t *testing.T) {
|
||||
TestDir: []string{"testdata", "TestMtaIntegration", "npm"},
|
||||
Network: fmt.Sprintf("container:%s", registryContainer.GetContainerID()),
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
container.whenRunningPiperCommand("cnbBuild", "--noTelemetry", "--verbose", "--buildpacks", "gcr.io/paketo-buildpacks/nodejs:0.19.0", "--containerImageName", "not-found", "--containerImageTag", "0.0.1", "--containerRegistryUrl", registryURL)
|
||||
|
||||
container.assertHasOutput(t, "Setting custom buildpacks: '[gcr.io/paketo-buildpacks/nodejs:0.19.0]'")
|
||||
container.assertHasOutput(t, "Downloading buildpack 'gcr.io/paketo-buildpacks/nodejs:0.19.0' to /tmp/buildpacks_cache/sha256:")
|
||||
container.assertHasOutput(t, "running command: /cnb/lifecycle/creator")
|
||||
container.assertHasOutput(t, "Paketo NPM Start Buildpack")
|
||||
container.assertHasOutput(t, fmt.Sprintf("Saving %s/not-found:0.0.1", registryURL))
|
||||
container.assertHasOutput(t, "*** Images (sha256:")
|
||||
container.assertHasOutput(t, "SUCCESS")
|
||||
container.terminate(t)
|
||||
container.assertHasOutput(t, "Setting custom buildpacks: '[gcr.io/paketo-buildpacks/nodejs:0.19.0]'",
|
||||
"Downloading buildpack 'gcr.io/paketo-buildpacks/nodejs:0.19.0' to /tmp/buildpacks_cache/sha256:",
|
||||
"running command: /cnb/lifecycle/creator",
|
||||
"Paketo NPM Start Buildpack",
|
||||
fmt.Sprintf("Saving %s/not-found:0.0.1", registryURL),
|
||||
"*** Images (sha256:",
|
||||
"SUCCESS",
|
||||
)
|
||||
}
|
||||
|
||||
func TestWrongBuilderProject(t *testing.T) {
|
||||
func TestCNBIntegrationWrongBuilderProject(t *testing.T) {
|
||||
t.Parallel()
|
||||
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
||||
Image: "nginx:latest",
|
||||
TestDir: []string{"testdata", "TestMtaIntegration", "npm"},
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
container.whenRunningPiperCommand("cnbBuild", "--noTelemetry", "--verbose", "--containerImageName", "not-found", "--containerImageTag", "0.0.1", "--containerRegistryUrl", "test")
|
||||
|
||||
container.assertHasOutput(t, "the provided dockerImage is not a valid builder")
|
||||
container.terminate(t)
|
||||
}
|
||||
|
||||
func TestBindings(t *testing.T) {
|
||||
func TestCNBIntegrationBindings(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
registryContainer := setupDockerRegistry(t, ctx)
|
||||
@ -222,16 +231,18 @@ func TestBindings(t *testing.T) {
|
||||
TestDir: []string{"testdata"},
|
||||
Network: fmt.Sprintf("container:%s", registryContainer.GetContainerID()),
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
container.whenRunningPiperCommand("cnbBuild", "--noTelemetry", "--verbose", "--customConfig", "TestCnbIntegration/config.yml", "--containerImageName", "not-found", "--containerImageTag", "0.0.1", "--containerRegistryUrl", registryURL, "--path", "TestMtaIntegration/maven")
|
||||
|
||||
container.assertHasOutput(t, "bindings/maven-settings/settings.xml: only whitespace content allowed before start tag")
|
||||
container.assertHasFile(t, "/tmp/platform/bindings/dummy-binding/type")
|
||||
container.assertHasFile(t, "/tmp/platform/bindings/dummy-binding/dummy.yml")
|
||||
container.terminate(t)
|
||||
container.assertHasFiles(t,
|
||||
"/tmp/platform/bindings/dummy-binding/type",
|
||||
"/tmp/platform/bindings/dummy-binding/dummy.yml",
|
||||
)
|
||||
}
|
||||
|
||||
func TestMultiImage(t *testing.T) {
|
||||
func TestCNBIntegrationMultiImage(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
registryContainer := setupDockerRegistry(t, ctx)
|
||||
@ -243,19 +254,21 @@ func TestMultiImage(t *testing.T) {
|
||||
TestDir: []string{"testdata", "TestCnbIntegration"},
|
||||
Network: fmt.Sprintf("container:%s", registryContainer.GetContainerID()),
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
container.whenRunningPiperCommand("cnbBuild", "--noTelemetry", "--verbose", "--customConfig", "config_multi_image.yml")
|
||||
|
||||
container.assertHasOutput(t, "Previous image with name \"localhost:5000/io-buildpacks-my-app:latest\" not found")
|
||||
container.assertHasOutput(t, "Saving localhost:5000/io-buildpacks-my-app:latest...")
|
||||
container.assertHasOutput(t, "Previous image with name \"localhost:5000/go-app:v1.0.0\" not found")
|
||||
container.assertHasOutput(t, "Saving localhost:5000/go-app:v1.0.0...")
|
||||
container.assertHasOutput(t, "Using cached buildpack")
|
||||
container.assertHasOutput(t, "Saving localhost:5000/my-app2:latest...")
|
||||
container.terminate(t)
|
||||
container.assertHasOutput(t,
|
||||
"Previous image with name \"localhost:5000/io-buildpacks-my-app:latest\" not found",
|
||||
"Saving localhost:5000/io-buildpacks-my-app:latest...",
|
||||
"Previous image with name \"localhost:5000/go-app:v1.0.0\" not found",
|
||||
"Saving localhost:5000/go-app:v1.0.0...",
|
||||
"Using cached buildpack",
|
||||
"Saving localhost:5000/my-app2:latest...",
|
||||
)
|
||||
}
|
||||
|
||||
func TestPreserveFiles(t *testing.T) {
|
||||
func TestCNBIntegrationPreserveFiles(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
registryContainer := setupDockerRegistry(t, ctx)
|
||||
@ -267,14 +280,13 @@ func TestPreserveFiles(t *testing.T) {
|
||||
TestDir: []string{"testdata", "TestCnbIntegration"},
|
||||
Network: fmt.Sprintf("container:%s", registryContainer.GetContainerID()),
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
container.whenRunningPiperCommand("cnbBuild", "--noTelemetry", "--verbose", "--customConfig", "config_preserve_files.yml")
|
||||
container.assertHasFile(t, "/project/project/node_modules/base/README.md")
|
||||
container.assertHasFile(t, "/project/project/package-lock.json")
|
||||
container.terminate(t)
|
||||
container.assertHasFiles(t, "/project/project/node_modules/base/README.md", "/project/project/package-lock.json")
|
||||
}
|
||||
|
||||
func TestPreserveFilesIgnored(t *testing.T) {
|
||||
func TestCNBIntegrationPreserveFilesIgnored(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
registryContainer := setupDockerRegistry(t, ctx)
|
||||
@ -286,8 +298,8 @@ func TestPreserveFilesIgnored(t *testing.T) {
|
||||
TestDir: []string{"testdata", "TestCnbIntegration"},
|
||||
Network: fmt.Sprintf("container:%s", registryContainer.GetContainerID()),
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
container.whenRunningPiperCommand("cnbBuild", "--noTelemetry", "--verbose", "--customConfig", "config_preserve_files.yml", "--path", "zip/go.zip", "--containerImageName", "go-zip")
|
||||
container.assertHasOutput(t, "skipping preserving files because the source")
|
||||
container.terminate(t)
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestAPICLIIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -15,8 +16,7 @@ import (
|
||||
"github.com/testcontainers/testcontainers-go"
|
||||
)
|
||||
|
||||
func TestDummy(t *testing.T) {
|
||||
|
||||
func TestDummyIntegration(t *testing.T) {
|
||||
t.Skip("Skipping testing - this is just to show how it can be done")
|
||||
ctx := context.Background()
|
||||
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestGaugeIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -80,12 +81,12 @@ cd /test
|
||||
assert.Contains(t, output, "info gaugeExecuteTests - SUCCESS")
|
||||
}
|
||||
|
||||
func TestGaugeJava(t *testing.T) {
|
||||
func TestGaugeIntegrationJava(t *testing.T) {
|
||||
t.Parallel()
|
||||
runTest(t, "java")
|
||||
}
|
||||
|
||||
func TestGaugeJS(t *testing.T) {
|
||||
func TestGaugeIntegrationJS(t *testing.T) {
|
||||
t.Parallel()
|
||||
runTest(t, "js")
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestGCSIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -25,7 +26,7 @@ import (
|
||||
"google.golang.org/api/option"
|
||||
)
|
||||
|
||||
func Test_gcsClient(t *testing.T) {
|
||||
func TestGCSIntegrationClient(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
testdataPath, err := filepath.Abs("testdata/TestGCSIntegration")
|
||||
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestGitHubIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -19,7 +20,7 @@ import (
|
||||
"github.com/SAP/jenkins-library/pkg/piperenv"
|
||||
)
|
||||
|
||||
func TestPiperGithubPublishRelease(t *testing.T) {
|
||||
func TestGitHubIntegrationPiperPublishRelease(t *testing.T) {
|
||||
t.Parallel()
|
||||
token := os.Getenv("PIPER_INTEGRATION_GITHUB_TOKEN")
|
||||
if len(token) == 0 {
|
||||
@ -94,7 +95,7 @@ func TestPiperGithubPublishRelease(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestGithubFetchCommitStatistics(t *testing.T) {
|
||||
func TestGitHubIntegrationFetchCommitStatistics(t *testing.T) {
|
||||
t.Parallel()
|
||||
// prepare
|
||||
token := os.Getenv("PIPER_INTEGRATION_GITHUB_TOKEN")
|
||||
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestGitOpsIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -9,7 +10,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGitopsUpdateDeploymentIT(t *testing.T) {
|
||||
func TestGitOpsIntegrationUpdateDeployment(t *testing.T) {
|
||||
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
||||
Image: "nekottyo/kustomize-kubeval:kustomizev4",
|
||||
TestDir: []string{"testdata", "TestGitopsUpdateIntegration", "kustomize", "workdir"},
|
||||
@ -27,8 +28,7 @@ func TestGitopsUpdateDeploymentIT(t *testing.T) {
|
||||
t.Fatalf("Cloing of bare repo failed")
|
||||
}
|
||||
|
||||
container.assertHasOutput(t, "SUCCESS")
|
||||
container.assertHasOutput(t, "[kustomize] updating")
|
||||
container.assertHasOutput(t, "SUCCESS", "[kustomize] updating")
|
||||
container.assertFileContentEquals(t, "/tmp/repo/kustomization.yaml", `images:
|
||||
- name: test-project
|
||||
newName: image
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestGolangIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -13,7 +14,7 @@ import (
|
||||
|
||||
// In this test the piper command golangBuild performs testing, BOM file creation and building a project with entry point in the cmd/server/server.go
|
||||
// The configuration for golangBuild can be found in testdata/TestGolangIntegration/golang-project1/.pipeline/config.yml
|
||||
func TestGolangBuild_Project1(t *testing.T) {
|
||||
func TestGolangIntegrationBuildProject1(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
||||
@ -21,29 +22,35 @@ func TestGolangBuild_Project1(t *testing.T) {
|
||||
TestDir: []string{"testdata", "TestGolangIntegration", "golang-project1"},
|
||||
ExecNoLogin: true,
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
err := container.whenRunningPiperCommand("golangBuild")
|
||||
assert.NoError(t, err)
|
||||
|
||||
container.assertHasOutput(t, "info golangBuild - running command: go install gotest.tools/gotestsum@latest")
|
||||
container.assertHasOutput(t, "info golangBuild - running command: go install github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest")
|
||||
container.assertHasOutput(t, "info golangBuild - running command: gotestsum --junitfile TEST-go.xml -- -coverprofile=cover.out ./...")
|
||||
container.assertHasOutput(t, "info golangBuild - DONE 8 tests")
|
||||
container.assertHasOutput(t, "info golangBuild - running command: go tool cover -html cover.out -o coverage.html")
|
||||
container.assertHasOutput(t, "info golangBuild - running command: gotestsum --junitfile TEST-integration.xml -- -tags=integration ./...")
|
||||
container.assertHasOutput(t, "info golangBuild - running command: cyclonedx-gomod mod -licenses -test -output bom-golang.xml")
|
||||
container.assertHasOutput(t, "info golangBuild - running command: go build -trimpath -o golang-app-linux.amd64 cmd/server/server.go")
|
||||
container.assertHasOutput(t, "info golangBuild - SUCCESS")
|
||||
container.assertHasOutput(t,
|
||||
"info golangBuild - running command: go install gotest.tools/gotestsum@latest",
|
||||
"info golangBuild - running command: go install github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest",
|
||||
"info golangBuild - running command: gotestsum --junitfile TEST-go.xml -- -coverprofile=cover.out ./...",
|
||||
"info golangBuild - DONE 8 tests",
|
||||
"info golangBuild - running command: go tool cover -html cover.out -o coverage.html",
|
||||
"info golangBuild - running command: gotestsum --junitfile TEST-integration.xml -- -tags=integration ./...",
|
||||
"info golangBuild - running command: cyclonedx-gomod mod -licenses -test -output bom-golang.xml",
|
||||
"info golangBuild - running command: go build -trimpath -o golang-app-linux.amd64 cmd/server/server.go",
|
||||
"info golangBuild - SUCCESS",
|
||||
)
|
||||
|
||||
container.assertHasFile(t, "/project/TEST-go.xml")
|
||||
container.assertHasFile(t, "/project/TEST-integration.xml")
|
||||
container.assertHasFile(t, "/project/bom-golang.xml")
|
||||
container.assertHasFile(t, "/project/cover.out")
|
||||
container.assertHasFile(t, "/project/coverage.html")
|
||||
container.assertHasFile(t, "/project/golang-app-linux.amd64")
|
||||
container.assertHasFiles(t,
|
||||
"/project/TEST-go.xml",
|
||||
"/project/TEST-integration.xml",
|
||||
"/project/bom-golang.xml",
|
||||
"/project/cover.out",
|
||||
"/project/coverage.html",
|
||||
"/project/golang-app-linux.amd64",
|
||||
)
|
||||
}
|
||||
|
||||
// This test extends TestGolangBuild_Project1 with multi-package build
|
||||
func TestGolangBuild_Project1_Multipackage(t *testing.T) {
|
||||
// This test extends TestGolangIntegrationBuildProject1 with multi-package build
|
||||
func TestGolangIntegrationBuildProject1MultiPackage(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
||||
@ -51,31 +58,36 @@ func TestGolangBuild_Project1_Multipackage(t *testing.T) {
|
||||
TestDir: []string{"testdata", "TestGolangIntegration", "golang-project1"},
|
||||
ExecNoLogin: true,
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
err := container.whenRunningPiperCommand("golangBuild", "--packages", "github.com/example/golang-app/cmd/server,github.com/example/golang-app/cmd/helper")
|
||||
assert.NoError(t, err)
|
||||
|
||||
container.assertHasOutput(t, "info golangBuild - running command: go install gotest.tools/gotestsum@latest")
|
||||
container.assertHasOutput(t, "info golangBuild - running command: go install github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest")
|
||||
container.assertHasOutput(t, "info golangBuild - running command: gotestsum --junitfile TEST-go.xml -- -coverprofile=cover.out ./...")
|
||||
container.assertHasOutput(t, "info golangBuild - DONE 8 tests")
|
||||
container.assertHasOutput(t, "info golangBuild - running command: go tool cover -html cover.out -o coverage.html")
|
||||
container.assertHasOutput(t, "info golangBuild - running command: gotestsum --junitfile TEST-integration.xml -- -tags=integration ./...")
|
||||
container.assertHasOutput(t, "info golangBuild - running command: cyclonedx-gomod mod -licenses -test -output bom-golang.xml")
|
||||
container.assertHasOutput(t, "info golangBuild - running command: go build -trimpath -o golang-app-linux-amd64/ github.com/example/golang-app/cmd/server github.com/example/golang-app/cmd/helper")
|
||||
container.assertHasOutput(t, "info golangBuild - SUCCESS")
|
||||
container.assertHasOutput(t, "info golangBuild - running command: go install gotest.tools/gotestsum@latest",
|
||||
"info golangBuild - running command: go install github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest",
|
||||
"info golangBuild - running command: gotestsum --junitfile TEST-go.xml -- -coverprofile=cover.out ./...",
|
||||
"info golangBuild - DONE 8 tests",
|
||||
"info golangBuild - running command: go tool cover -html cover.out -o coverage.html",
|
||||
"info golangBuild - running command: gotestsum --junitfile TEST-integration.xml -- -tags=integration ./...",
|
||||
"info golangBuild - running command: cyclonedx-gomod mod -licenses -test -output bom-golang.xml",
|
||||
"info golangBuild - running command: go build -trimpath -o golang-app-linux-amd64/ github.com/example/golang-app/cmd/server github.com/example/golang-app/cmd/helper",
|
||||
"info golangBuild - SUCCESS",
|
||||
)
|
||||
|
||||
container.assertHasFile(t, "/project/TEST-go.xml")
|
||||
container.assertHasFile(t, "/project/TEST-integration.xml")
|
||||
container.assertHasFile(t, "/project/bom-golang.xml")
|
||||
container.assertHasFile(t, "/project/cover.out")
|
||||
container.assertHasFile(t, "/project/coverage.html")
|
||||
container.assertHasFile(t, "/project/golang-app-linux-amd64/server")
|
||||
container.assertHasFile(t, "/project/golang-app-linux-amd64/helper")
|
||||
container.assertHasFiles(t,
|
||||
"/project/TEST-go.xml",
|
||||
"/project/TEST-integration.xml",
|
||||
"/project/bom-golang.xml",
|
||||
"/project/cover.out",
|
||||
"/project/coverage.html",
|
||||
"/project/golang-app-linux-amd64/server",
|
||||
"/project/golang-app-linux-amd64/helper",
|
||||
)
|
||||
}
|
||||
|
||||
// In this test, the piper golangBuild command only builds the project with the entry point at the project root.
|
||||
// The configuration for golangBuild can be found in testdata/TestGolangIntegration/golang-project2/.pipeline/config.yml
|
||||
func TestGolangBuild_Project2(t *testing.T) {
|
||||
func TestGolangIntegrationBuildProject2(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
||||
@ -83,15 +95,22 @@ func TestGolangBuild_Project2(t *testing.T) {
|
||||
TestDir: []string{"testdata", "TestGolangIntegration", "golang-project2"},
|
||||
ExecNoLogin: true,
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
err := container.whenRunningPiperCommand("golangBuild")
|
||||
assert.NoError(t, err)
|
||||
|
||||
container.assertHasNoOutput(t, "info golangBuild - running command: go install gotest.tools/gotestsum@latest")
|
||||
container.assertHasNoOutput(t, "info golangBuild - running command: go install github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest")
|
||||
container.assertHasNoOutput(t, "info golangBuild - running command: gotestsum --junitfile TEST-go.xml -- -coverprofile=cover.out ./...")
|
||||
container.assertHasNoOutput(t, "info golangBuild - running command: go tool cover -html cover.out -o coverage.html")
|
||||
container.assertHasNoOutput(t, "info golangBuild - running command: gotestsum --junitfile TEST-integration.xml -- -tags=integration ./...")
|
||||
container.assertHasNoOutput(t, "info golangBuild - running command: cyclonedx-gomod mod -licenses -test -output bom-golang.xml")
|
||||
container.assertHasOutput(t, "info golangBuild - running command: go build -trimpath -o golang-app-linux.amd64")
|
||||
container.assertHasOutput(t, "info golangBuild - SUCCESS")
|
||||
container.assertHasNoOutput(t,
|
||||
"info golangBuild - running command: go install gotest.tools/gotestsum@latest",
|
||||
"info golangBuild - running command: go install github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest",
|
||||
"info golangBuild - running command: gotestsum --junitfile TEST-go.xml -- -coverprofile=cover.out ./...",
|
||||
"info golangBuild - running command: go tool cover -html cover.out -o coverage.html",
|
||||
"info golangBuild - running command: gotestsum --junitfile TEST-integration.xml -- -tags=integration ./...",
|
||||
"info golangBuild - running command: cyclonedx-gomod mod -licenses -test -output bom-golang.xml",
|
||||
)
|
||||
|
||||
container.assertHasOutput(t,
|
||||
"info golangBuild - running command: go build -trimpath -o golang-app-linux.amd64",
|
||||
"info golangBuild - SUCCESS",
|
||||
)
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestGradleIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -17,7 +18,7 @@ import (
|
||||
"github.com/testcontainers/testcontainers-go"
|
||||
)
|
||||
|
||||
func TestGradleExecuteBuild_JavaProject_BOMCreation_UsingWrapper(t *testing.T) {
|
||||
func TestGradleIntegrationExecuteBuildJavaProjectBOMCreationUsingWrapper(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
||||
@ -89,7 +90,7 @@ ls -l ./build/reports/ >files-list.txt 2>&1
|
||||
assert.Contains(t, output, "bom-gradle.xml")
|
||||
}
|
||||
|
||||
func TestGradleExecuteBuild_JavaProjectWithBomPlugin(t *testing.T) {
|
||||
func TestGradleIntegrationExecuteBuildJavaProjectWithBomPlugin(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestInfluxIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -17,7 +18,7 @@ import (
|
||||
"github.com/testcontainers/testcontainers-go/wait"
|
||||
)
|
||||
|
||||
func TestWriteMetrics(t *testing.T) {
|
||||
func TestInfluxIntegrationWriteMetrics(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
const authToken = "influx-token"
|
||||
|
@ -1,4 +1,8 @@
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestJenkinsIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -14,7 +18,7 @@ import (
|
||||
"github.com/SAP/jenkins-library/pkg/jenkins"
|
||||
)
|
||||
|
||||
func TestTriggerJob(t *testing.T) {
|
||||
func TestJenkinsIntegrationTriggerJob(t *testing.T) {
|
||||
t.Skip("no Jenkins instance for testing available yet")
|
||||
//TODO: check if testcontainers can be used
|
||||
// init
|
||||
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestCLIIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -18,7 +19,6 @@ import (
|
||||
)
|
||||
|
||||
func TestKarmaIntegration(t *testing.T) {
|
||||
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestMavenIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -9,7 +10,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMavenBuildCloudSdkSpringProject(t *testing.T) {
|
||||
func TestMavenIntegrationBuildCloudSdkSpringProject(t *testing.T) {
|
||||
t.Parallel()
|
||||
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
||||
Image: "maven:3-openjdk-8-slim",
|
||||
@ -18,6 +19,7 @@ func TestMavenBuildCloudSdkSpringProject(t *testing.T) {
|
||||
Mounts: map[string]string{},
|
||||
Setup: []string{},
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
err := container.whenRunningPiperCommand("mavenBuild", "")
|
||||
if err != nil {
|
||||
@ -25,21 +27,25 @@ func TestMavenBuildCloudSdkSpringProject(t *testing.T) {
|
||||
}
|
||||
|
||||
container.assertHasOutput(t, "BUILD SUCCESS")
|
||||
container.assertHasFile(t, "/project/application/target/cloud-sdk-spring-archetype-application.jar")
|
||||
container.assertHasFile(t, "/tmp/.m2/repository")
|
||||
container.assertHasFiles(t,
|
||||
"/project/application/target/cloud-sdk-spring-archetype-application.jar",
|
||||
"/tmp/.m2/repository",
|
||||
)
|
||||
|
||||
err = container.whenRunningPiperCommand("mavenExecuteIntegration", "")
|
||||
if err != nil {
|
||||
t.Fatalf("Calling piper command failed %s", err)
|
||||
}
|
||||
|
||||
container.assertHasOutput(t, "INFO mydemo.HelloWorldControllerTest - Starting HelloWorldControllerTest")
|
||||
container.assertHasOutput(t, "Tests run: 1, Failures: 0, Errors: 0, Skipped: 0")
|
||||
container.assertHasOutput(t,
|
||||
"INFO mydemo.HelloWorldControllerTest - Starting HelloWorldControllerTest",
|
||||
"Tests run: 1, Failures: 0, Errors: 0, Skipped: 0",
|
||||
)
|
||||
|
||||
container.assertHasFile(t, "/project/integration-tests/target/coverage-reports/jacoco.exec")
|
||||
container.assertHasFiles(t, "/project/integration-tests/target/coverage-reports/jacoco.exec")
|
||||
}
|
||||
|
||||
func TestMavenBuildCloudSdkTomeeProject(t *testing.T) {
|
||||
func TestMavenIntegrationBuildCloudSdkTomeeProject(t *testing.T) {
|
||||
t.Parallel()
|
||||
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
||||
Image: "maven:3-openjdk-8-slim",
|
||||
@ -48,6 +54,7 @@ func TestMavenBuildCloudSdkTomeeProject(t *testing.T) {
|
||||
Mounts: map[string]string{},
|
||||
Setup: []string{},
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
err := container.whenRunningPiperCommand("mavenBuild", "")
|
||||
if err != nil {
|
||||
@ -55,17 +62,21 @@ func TestMavenBuildCloudSdkTomeeProject(t *testing.T) {
|
||||
}
|
||||
|
||||
container.assertHasOutput(t, "BUILD SUCCESS")
|
||||
container.assertHasFile(t, "/project/application/target/cloud-sdk-tomee-archetype-application-classes.jar")
|
||||
container.assertHasFile(t, "/project/application/target/cloud-sdk-tomee-archetype-application.war")
|
||||
container.assertHasFile(t, "/tmp/.m2/repository")
|
||||
container.assertHasFiles(t,
|
||||
"/project/application/target/cloud-sdk-tomee-archetype-application-classes.jar",
|
||||
"/project/application/target/cloud-sdk-tomee-archetype-application.war",
|
||||
"/tmp/.m2/repository",
|
||||
)
|
||||
|
||||
err = container.whenRunningPiperCommand("mavenExecuteIntegration", "")
|
||||
if err != nil {
|
||||
t.Fatalf("Calling piper command failed %s", err)
|
||||
}
|
||||
|
||||
container.assertHasOutput(t, "(prepare-agent) @ cloud-sdk-tomee-archetype-integration-tests")
|
||||
container.assertHasOutput(t, "Tests run: 1, Failures: 0, Errors: 0, Skipped: 0")
|
||||
container.assertHasOutput(t,
|
||||
"(prepare-agent) @ cloud-sdk-tomee-archetype-integration-tests",
|
||||
"Tests run: 1, Failures: 0, Errors: 0, Skipped: 0",
|
||||
)
|
||||
|
||||
container.assertHasFile(t, "/project/integration-tests/target/coverage-reports/jacoco.exec")
|
||||
container.assertHasFiles(t, "/project/integration-tests/target/coverage-reports/jacoco.exec")
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestMTAIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -9,32 +10,36 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMavenProject(t *testing.T) {
|
||||
func TestMTAIntegrationMavenProject(t *testing.T) {
|
||||
t.Parallel()
|
||||
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
||||
Image: "devxci/mbtci-java11-node14",
|
||||
User: "root",
|
||||
TestDir: []string{"testdata", "TestMtaIntegration", "maven"},
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
err := container.whenRunningPiperCommand("mtaBuild", "--installArtifacts", "--m2Path=mym2")
|
||||
if err != nil {
|
||||
t.Fatalf("Piper command failed %s", err)
|
||||
}
|
||||
|
||||
container.assertHasOutput(t, "Installing /project/.flattened-pom.xml to /project/mym2/mygroup/mymvn/1.0-SNAPSHOT/mymvn-1.0-SNAPSHOT.pom")
|
||||
container.assertHasOutput(t, "Installing /project/app/target/mymvn-app-1.0-SNAPSHOT.war to /project/mym2/mygroup/mymvn-app/1.0-SNAPSHOT/mymvn-app-1.0-SNAPSHOT.war")
|
||||
container.assertHasOutput(t, "Installing /project/app/target/mymvn-app-1.0-SNAPSHOT-classes.jar to /project/mym2/mygroup/mymvn-app/1.0-SNAPSHOT/mymvn-app-1.0-SNAPSHOT-classes.jar")
|
||||
container.assertHasOutput(t, "added 2 packages from 3 contributors and audited 2 packages in")
|
||||
container.assertHasOutput(t,
|
||||
"Installing /project/.flattened-pom.xml to /project/mym2/mygroup/mymvn/1.0-SNAPSHOT/mymvn-1.0-SNAPSHOT.pom",
|
||||
"Installing /project/app/target/mymvn-app-1.0-SNAPSHOT.war to /project/mym2/mygroup/mymvn-app/1.0-SNAPSHOT/mymvn-app-1.0-SNAPSHOT.war",
|
||||
"Installing /project/app/target/mymvn-app-1.0-SNAPSHOT-classes.jar to /project/mym2/mygroup/mymvn-app/1.0-SNAPSHOT/mymvn-app-1.0-SNAPSHOT-classes.jar",
|
||||
"added 2 packages from 3 contributors and audited 2 packages in",
|
||||
)
|
||||
}
|
||||
|
||||
func TestMavenSpringProject(t *testing.T) {
|
||||
func TestMTAIntegrationMavenSpringProject(t *testing.T) {
|
||||
t.Parallel()
|
||||
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
||||
Image: "devxci/mbtci-java11-node14",
|
||||
User: "root",
|
||||
TestDir: []string{"testdata", "TestMtaIntegration", "maven-spring"},
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
err := container.whenRunningPiperCommand("mtaBuild", "--installArtifacts", "--m2Path=mym2")
|
||||
if err != nil {
|
||||
@ -48,13 +53,14 @@ func TestMavenSpringProject(t *testing.T) {
|
||||
container.assertHasOutput(t, "Tests run: 1, Failures: 0, Errors: 0, Skipped: 0")
|
||||
}
|
||||
|
||||
func TestNPMProject(t *testing.T) {
|
||||
func TestMTAIntegrationNPMProject(t *testing.T) {
|
||||
t.Parallel()
|
||||
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
||||
Image: "devxci/mbtci-java11-node14",
|
||||
User: "root",
|
||||
TestDir: []string{"testdata", "TestMtaIntegration", "npm"},
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
err := container.whenRunningPiperCommand("mtaBuild", "")
|
||||
if err != nil {
|
||||
@ -64,13 +70,14 @@ func TestNPMProject(t *testing.T) {
|
||||
container.assertHasOutput(t, "INFO the MTA archive generated at: /project/test-mta-js.mtar")
|
||||
}
|
||||
|
||||
func TestNPMProjectInstallsDevDependencies(t *testing.T) {
|
||||
func TestMTAIntegrationNPMProjectInstallsDevDependencies(t *testing.T) {
|
||||
t.Parallel()
|
||||
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
||||
Image: "devxci/mbtci-java11-node14",
|
||||
User: "root",
|
||||
TestDir: []string{"testdata", "TestMtaIntegration", "npm-install-dev-dependencies"},
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
err := container.whenRunningPiperCommand("mtaBuild", "--installArtifacts")
|
||||
if err != nil {
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestNexusIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -25,10 +26,10 @@ func assertFileCanBeDownloaded(t *testing.T, container IntegrationTestDockerExec
|
||||
if err != nil {
|
||||
t.Fatalf("Attempting to download file %s failed: %s", url, err)
|
||||
}
|
||||
container.assertHasFile(t, "/project/"+path.Base(url))
|
||||
container.assertHasFiles(t, "/project/"+path.Base(url))
|
||||
}
|
||||
|
||||
func TestNexus3UploadMta(t *testing.T) {
|
||||
func TestNexusIntegrationV3UploadMta(t *testing.T) {
|
||||
t.Parallel()
|
||||
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
||||
Image: "sonatype/nexus3:3.25.1",
|
||||
@ -42,6 +43,7 @@ func TestNexus3UploadMta(t *testing.T) {
|
||||
"until curl --fail --silent http://localhost:8081/service/rest/v1/status; do sleep 5; done",
|
||||
},
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
err := container.whenRunningPiperCommand("nexusUpload", "--groupId=mygroup", "--artifactId=mymta",
|
||||
"--username=admin", "--password=admin123", "--mavenRepository=maven-releases", "--url=http://localhost:8081")
|
||||
@ -54,7 +56,7 @@ func TestNexus3UploadMta(t *testing.T) {
|
||||
assertFileCanBeDownloaded(t, container, "http://localhost:8081/repository/maven-releases/mygroup/mymta/0.3.0/mymta-0.3.0.yaml")
|
||||
}
|
||||
|
||||
func TestNexus3UploadMaven(t *testing.T) {
|
||||
func TestNexusIntegrationV3UploadMaven(t *testing.T) {
|
||||
t.Parallel()
|
||||
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
||||
Image: "sonatype/nexus3:3.25.1",
|
||||
@ -68,6 +70,7 @@ func TestNexus3UploadMaven(t *testing.T) {
|
||||
"until curl --fail --silent http://localhost:8081/service/rest/v1/status; do sleep 5; done",
|
||||
},
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
err := container.whenRunningPiperCommand("nexusUpload", "--username=admin", "--password=admin123",
|
||||
"--mavenRepository=maven-releases", "--url=http://localhost:8081")
|
||||
@ -80,7 +83,7 @@ func TestNexus3UploadMaven(t *testing.T) {
|
||||
assertFileCanBeDownloaded(t, container, "http://localhost:8081/repository/maven-releases/com/mycompany/app/my-app/1.0/my-app-1.0.jar")
|
||||
}
|
||||
|
||||
func TestNexus3UploadNpm(t *testing.T) {
|
||||
func TestNexusIntegrationV3UploadNpm(t *testing.T) {
|
||||
t.Parallel()
|
||||
container := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
||||
Image: "sonatype/nexus3:3.25.1",
|
||||
@ -96,6 +99,7 @@ func TestNexus3UploadNpm(t *testing.T) {
|
||||
"curl -u admin:admin123 -d '{\"name\": \"npm-repo\", \"online\": true, \"storage\": {\"blobStoreName\": \"default\", \"strictContentTypeValidation\": true, \"writePolicy\": \"ALLOW_ONCE\"}}' --header \"Content-Type: application/json\" -X POST http://localhost:8081/service/rest/beta/repositories/npm/hosted",
|
||||
},
|
||||
})
|
||||
defer container.terminate(t)
|
||||
|
||||
err := container.whenRunningPiperCommand("nexusUpload", "--username=admin", "--password=admin123",
|
||||
"--npmRepository=npm-repo", "--url=http://localhost:8081")
|
||||
@ -107,7 +111,7 @@ func TestNexus3UploadNpm(t *testing.T) {
|
||||
assertFileCanBeDownloaded(t, container, "http://localhost:8081/repository/npm-repo/npm-nexus-upload-test/-/npm-nexus-upload-test-1.0.0.tgz")
|
||||
}
|
||||
|
||||
func TestNexus2Upload(t *testing.T) {
|
||||
func TestNexusIntegrationV2Upload(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
req := testcontainers.ContainerRequest{
|
||||
Image: "sonatype/nexus:2.14.18-01",
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestNPMIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -16,7 +17,7 @@ import (
|
||||
"github.com/testcontainers/testcontainers-go"
|
||||
)
|
||||
|
||||
func TestRunScriptsWithOptions(t *testing.T) {
|
||||
func TestNPMIntegrationRunScriptsWithOptions(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
||||
@ -67,7 +68,7 @@ cd /test
|
||||
assert.Contains(t, output, "info npmExecuteScripts - [ '--tag', 'tag1' ]")
|
||||
}
|
||||
|
||||
func TestRegistrySetInFlags(t *testing.T) {
|
||||
func TestNPMIntegrationRegistrySetInFlags(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
||||
@ -117,7 +118,7 @@ cd /test
|
||||
assert.Contains(t, output, "info npmExecuteScripts - https://foo.bar")
|
||||
}
|
||||
|
||||
func TestRegistrySetInNpmrc(t *testing.T) {
|
||||
func TestNPMIntegrationRegistrySetInNpmrc(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
||||
@ -167,7 +168,7 @@ cd /test
|
||||
assert.Contains(t, output, "info npmExecuteScripts - https://example.com")
|
||||
}
|
||||
|
||||
func TestRegistryWithTwoModules(t *testing.T) {
|
||||
func TestNPMIntegrationRegistryWithTwoModules(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestPiperIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -21,7 +22,7 @@ import (
|
||||
"github.com/SAP/jenkins-library/pkg/piperutils"
|
||||
)
|
||||
|
||||
func TestPiperHelp(t *testing.T) {
|
||||
func TestPiperIntegrationHelp(t *testing.T) {
|
||||
t.Parallel()
|
||||
piperHelpCmd := command.Command{}
|
||||
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestPythonIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -17,7 +18,7 @@ import (
|
||||
"github.com/testcontainers/testcontainers-go"
|
||||
)
|
||||
|
||||
func TestBuildPythonProject(t *testing.T) {
|
||||
func TestPythonIntegrationBuildProject(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
pwd, err := os.Getwd()
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestSonarIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -16,7 +17,7 @@ import (
|
||||
"github.com/SAP/jenkins-library/pkg/sonar"
|
||||
)
|
||||
|
||||
func TestSonarIssueSearch(t *testing.T) {
|
||||
func TestSonarIntegrationIssueSearch(t *testing.T) {
|
||||
t.Parallel()
|
||||
// init
|
||||
token := os.Getenv("PIPER_INTEGRATION_SONAR_TOKEN")
|
||||
@ -50,7 +51,7 @@ func TestSonarIssueSearch(t *testing.T) {
|
||||
// assert.NotEmpty(t, result.Organizations)
|
||||
}
|
||||
|
||||
func TestSonarMeasuresComponentSearch(t *testing.T) {
|
||||
func TestSonarIntegrationMeasuresComponentSearch(t *testing.T) {
|
||||
t.Parallel()
|
||||
// init
|
||||
token := os.Getenv("PIPER_INTEGRATION_SONAR_TOKEN")
|
||||
@ -75,7 +76,7 @@ func TestSonarMeasuresComponentSearch(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestSonarGetLinesOfCode(t *testing.T) {
|
||||
func TestSonarIntegrationGetLinesOfCode(t *testing.T) {
|
||||
t.Parallel()
|
||||
// init
|
||||
token := os.Getenv("PIPER_INTEGRATION_SONAR_TOKEN")
|
||||
|
@ -1,7 +1,8 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
// can be execute with go test -tags=integration ./integration/...
|
||||
// can be executed with
|
||||
// go test -v -tags integration -run TestVaultIntegration ./integration/...
|
||||
|
||||
package main
|
||||
|
||||
@ -21,7 +22,7 @@ import (
|
||||
|
||||
type SecretData = map[string]interface{}
|
||||
|
||||
func TestGetVaultSecret(t *testing.T) {
|
||||
func TestVaultIntegrationGetSecret(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
const testToken = "vault-token"
|
||||
@ -67,7 +68,7 @@ func TestGetVaultSecret(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestWriteVaultSecret(t *testing.T) {
|
||||
func TestVaultIntegrationWriteSecret(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
const testToken = "vault-token"
|
||||
@ -131,7 +132,7 @@ func TestWriteVaultSecret(t *testing.T) {
|
||||
assert.Equal(t, "value2", secret["key2"])
|
||||
}
|
||||
|
||||
func TestVaultAppRole(t *testing.T) {
|
||||
func TestVaultIntegrationAppRole(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
const testToken = "vault-token"
|
||||
@ -210,7 +211,7 @@ func TestVaultAppRole(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestTokenRevocation(t *testing.T) {
|
||||
func TestVaultIntegrationTokenRevocation(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
const testToken = "vault-token"
|
||||
|
@ -1,18 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Run all test if no arguments are given, run a single test function if it is passed as $1
|
||||
# For example: `./run-tests.sh TestRegistrySetInNpmrc`
|
||||
|
||||
TEST_NAME=$1
|
||||
# Run all test if no arguments are given, run tests if they've passed as arguments
|
||||
# For example: ./run-tests.sh TestNexusIntegration TestNPMIntegration
|
||||
|
||||
pushd ..
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags release -o piper
|
||||
|
||||
if [[ "$TEST_NAME" ]]
|
||||
if [[ "$*" ]]
|
||||
then
|
||||
go test -tags=integration -timeout 25m -run "$TEST_NAME" ./integration/...
|
||||
for testName in "$@"
|
||||
do
|
||||
go test -v -tags integration -run "$testName" ./integration/...
|
||||
done
|
||||
else
|
||||
go test -tags=integration -timeout 25m ./integration/...
|
||||
go test -v -tags integration ./integration/...
|
||||
fi
|
||||
|
||||
popd || exit
|
||||
|
Loading…
Reference in New Issue
Block a user