Skip to content

Commit

Permalink
Test balena push with docker-compose using symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
thgreasi committed Dec 13, 2021
1 parent 1cd7821 commit 2bb979f
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 0 deletions.
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 (single container, 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

0 comments on commit 2bb979f

Please sign in to comment.