Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test balena push with docker-compose using symlinks #2408

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions tests/commands/push.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,59 @@ describe('balena push', function () {
});
});

it('should create the expected tar stream (docker-compose, symbolic links in docker-compose, --gitignore)', async () => {
const projectPath = path.join(
projectsPath,
'docker-compose',
'symbolic-links',
);
const expectedFiles: ExpectedTarStreamFiles = {
'.balena/balena.yml': { fileSize: 197, type: 'file' },
'docker-compose.yml': { fileSize: 340, type: 'file' },
'service1/Dockerfile.template': { fileSize: 144, type: 'file' },
'service1/file1.sh': { fileSize: 12, type: 'file' },
'service1/test-ignore-from-symlink-path.txt': {
fileSize: 12,
type: 'file',
},
'service2/Dockerfile-alt': { fileSize: 13, type: 'file' },
'service2/src/file1.sh': { fileSize: 12, type: 'file' },
};
const regSecretsPath = await addRegSecretsEntries(expectedFiles);
const responseFilename = 'build-POST-v3.json';
const responseBody = await fs.readFile(
path.join(builderResponsePath, responseFilename),
'utf8',
);
const expectedResponseLines: string[] = [
...commonResponseLines[responseFilename],
...getDockerignoreWarn1(
[path.join(projectPath, 'service2', '.dockerignore')],
'push',
),
];
if (isWindows) {
expectedResponseLines.push(
`[Info] Converting line endings CRLF -> LF for file: ${path.join(
projectPath,
'service2',
'file2-crlf.sh',
)}`,
);
}

await testPushBuildStream({
builderMock: builder,
commandLine: `push testApp -s ${projectPath} -R ${regSecretsPath}`,
expectedFiles,
expectedQueryParams: commonQueryParams,
expectedResponseLines,
projectPath,
responseBody,
responseCode: 200,
});
});

it('should create the expected tar stream (single container, --multi-dockerignore)', async () => {
const projectPath = path.join(
projectsPath,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
build-variables:
global:
- MY_VAR_1=This is a variable
- MY_VAR_2=Also a variable
services:
service1:
- SERVICE1_VAR=This is a service specific variable
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
service1/test-ignore-from-actual-path.*
service1-symlink/test-ignore-from-symlink-path.*
**/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '2'
volumes:
resin-data:
services:
service1:
volumes:
- 'resin-data:/data'
build: ./service1-symlink
service2:
volumes:
- 'resin-data:/data'
build:
context: ./service2
dockerfile: Dockerfile-alt
args:
- 'COMPOSE_ARG=an argument defined in the docker-compose.yml file'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/file1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM busybox
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
line1
line2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM balenalib/%%BALENA_MACHINE_NAME%%-alpine
COPY ./file1.sh /
CMD i=1; while :; do echo "service1 $i $(uname -a)"; sleep 10; i=$((i+1)); done
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
line1
line2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test-ignore