Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
Signed-off-by: David Kwon <[email protected]>
  • Loading branch information
dkwon17 authored and AObuchow committed May 15, 2024
1 parent 20bfdaf commit d913c07
Show file tree
Hide file tree
Showing 9 changed files with 270 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ input:
workspace:
persistUserHome:
enabled: true
disableInitContainer: true
workspace:
components:
- name: testing-container-1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: "Creates init container from the first component when persistUserHome is enabled"

input:
devworkspaceId: "test-workspaceid"
config:
workspace:
persistUserHome:
enabled: true
workspace:
components:
- name: testing-container-1
container:
image: testing-image-1
volumeMounts:
- name: my-defined-volume
path: /my-defined-volume-path
- name: testing-container-2
container:
image: testing-image-2
volumeMounts:
- name: my-defined-volume
path: /my-defined-volume-path
- name: my-defined-volume
volume: {}

output:
workspace:
components:
- name: testing-container-1
container:
image: testing-image-1
volumeMounts:
- name: my-defined-volume
path: /my-defined-volume-path
- name: persistent-home
path: /home/user/
- name: testing-container-2
container:
image: testing-image-2
volumeMounts:
- name: my-defined-volume
path: /my-defined-volume-path
- name: persistent-home
path: /home/user/
- name: my-defined-volume
volume: {}
- name: init-persistent-home
container:
image: testing-image-1
volumeMounts:
- name: persistent-home
path: /home/user/
command:
- /bin/sh
- -c
args:
- |
(echo "Checking for stow command"
STOW_COMPLETE=/home/user/.stow_completed
if command -v stow &> /dev/null; then
if [ ! -f $STOW_COMPLETE ]; then
echo "Running stow command"
stow . -t /home/user/ -d /home/tooling/ --no-folding -v 2 > /home/user/.stow.log 2>&1
cp -n /home/tooling/.viminfo /home/user/.viminfo
cp -n /home/tooling/.bashrc /home/user/.bashrc
cp -n /home/tooling/.bash_profile /home/user/.bash_profile
touch $STOW_COMPLETE
else
echo "Stow command already run. If you wish to re-run it, delete $STOW_COMPLETE from the persistent volume and restart the workspace."
fi
else
echo "Stow command not found"
fi) || true
- name: persistent-home
volume: {}
commands:
- id: init-persistent-home
apply:
component: init-persistent-home
events:
prestart:
- init-persistent-home
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: "Creates init container when persistUserHome is enabled"

input:
devworkspaceId: "test-workspaceid"
config:
workspace:
persistUserHome:
enabled: true
workspace:
components:
- name: testing-container-1
container:
image: testing-image-1
volumeMounts:
- name: my-defined-volume
path: /my-defined-volume-path
- name: my-defined-volume
volume: {}

output:
workspace:
components:
- name: testing-container-1
container:
image: testing-image-1
volumeMounts:
- name: my-defined-volume
path: /my-defined-volume-path
- name: persistent-home
path: /home/user/
- name: my-defined-volume
volume: {}
- name: init-persistent-home
container:
image: testing-image-1
volumeMounts:
- name: persistent-home
path: /home/user/
command:
- /bin/sh
- -c
args:
- |
(echo "Checking for stow command"
STOW_COMPLETE=/home/user/.stow_completed
if command -v stow &> /dev/null; then
if [ ! -f $STOW_COMPLETE ]; then
echo "Running stow command"
stow . -t /home/user/ -d /home/tooling/ --no-folding -v 2 > /home/user/.stow.log 2>&1
cp -n /home/tooling/.viminfo /home/user/.viminfo
cp -n /home/tooling/.bashrc /home/user/.bashrc
cp -n /home/tooling/.bash_profile /home/user/.bash_profile
touch $STOW_COMPLETE
else
echo "Stow command already run. If you wish to re-run it, delete $STOW_COMPLETE from the persistent volume and restart the workspace."
fi
else
echo "Stow command not found"
fi) || true
- name: persistent-home
volume: {}
commands:
- id: init-persistent-home
apply:
component: init-persistent-home
events:
prestart:
- init-persistent-home
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ input:
workspace:
persistUserHome:
enabled: true
disableInitContainer: true
workspace:
components:
- name: testing-container-1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ input:
workspace:
persistUserHome:
enabled: true
disableInitContainer: true
workspace:
components:
- name: testing-container-1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Does not create persistent home volume if command with an id of 'init-persistent-home' is already defined"

input:
devworkspaceId: "test-workspaceid"
config:
workspace:
persistUserHome:
enabled: true
workspace:
components:
- name: testing-container-1
container:
image: testing-image-1
commands:
- id: init-persistent-home
apply:
component: testing-container-1

output:
error: "failed to add init container for home persistence setup: command with id init-persistent-home already exists in the devworkspace"
workspace:
components:
- name: testing-container-1
container:
image: testing-image-1
commands:
- id: init-persistent-home
apply:
component: testing-container-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: "Does not create persistent home volume if component named 'init-persistent-home' is already defined"

input:
devworkspaceId: "test-workspaceid"
config:
workspace:
persistUserHome:
enabled: true
workspace:
components:
- name: testing-container-1
container:
image: testing-image-1
volumeMounts:
- name: my-defined-volume
path: /my-defined-volume-path
- name: my-defined-volume
volume: {}
- name: init-persistent-home
container:
image: testing-image-1
command:
- echo helloworld
commands:
- id: init-persistent-home
apply:
component: init-persistent-home
events:
prestart:
- init-persistent-home

output:
error: "failed to add init container for home persistence setup: component named init-persistent-home already exists in the devworkspace"
workspace:
components:
- name: testing-container-1
container:
image: testing-image-1
volumeMounts:
- name: my-defined-volume
path: /my-defined-volume-path
- name: my-defined-volume
volume: {}
- name: init-persistent-home
container:
image: testing-image-1
command:
- echo helloworld
commands:
- id: init-persistent-home
apply:
component: init-persistent-home
events:
prestart:
- init-persistent-home
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Does not create persistent home volume if prestart event with an id of 'init-persistent-home' is already defined"

input:
devworkspaceId: "test-workspaceid"
config:
workspace:
persistUserHome:
enabled: true
workspace:
events:
prestart:
- init-persistent-home

output:
error: "failed to add init container for home persistence setup: command with id init-persistent-home already exists in the devworkspace"
workspace:
events:
prestart:
- init-persistent-home
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "No op if there are no components"

input:
devworkspaceId: "test-workspaceid"
config:
workspace:
persistUserHome:
enabled: true
workspace:
components: []

output:
workspace:
components: []

0 comments on commit d913c07

Please sign in to comment.