setup_container.sh #3

  • //
  • guest/
  • perforce_software/
  • sdp/
  • dev/
  • test/
  • docker/
  • setup_container.sh
  • View
  • Commits
  • Open Download .zip Download (2 KB)
#!/bin/bash
# This script sets up the base docker container for use with SDP testing.
# It expects to be run as root within the container.

# Create base directories for use by SDP (see mkdirs.sh)
mkdir /depotdata
mkdir /metadata
mkdir /logs

# Create Perforce group and user within that group, and allow them sudo privileges
groupadd perforce
useradd -d /p4 -s /bin/bash -m perforce -g perforce
echo 'perforce ALL=(ALL) NOPASSWD:ALL'> /tmp/perforce
chmod 0440 /tmp/perforce
chown root:root /tmp/perforce
mv /tmp/perforce /etc/sudoers.d
echo perforce:Password | chpasswd

#
# Helpful profile for perforce user login profile - for manual testing mainly
#
BASH_PROF=/p4/.bash_profile
echo 'export PATH=/sdp/Server/Unix/p4/common/bin:$PATH'> $BASH_PROF
echo 'export P4CONFIG=.p4config'>> $BASH_PROF
echo 'export P4P4PORT=1666'>> $BASH_PROF
chown perforce:perforce $BASH_PROF

#
# Script to reset SDP for tests in case of multiple runs.
#
RESET_SDP=/p4/reset_sdp.sh
echo '#!/bin/bash'> $RESET_SDP
echo 'sudo cp -R /sdp /depotdata'>> $RESET_SDP
echo 'sudo chown -R perforce:perforce /depotdata/sdp'>> $RESET_SDP
chmod +x $RESET_SDP
chown perforce:perforce $RESET_SDP

#
# Script to run SDP tests - run by Docker entry script below (or can be run
# manually).
#
RUN_SDP_TESTS=/p4/test_sdp.sh
echo '#!/bin/bash'> $RUN_SDP_TESTS
echo '/p4/reset_sdp.sh'>> $RUN_SDP_TESTS
echo 'ln -s /sdp/Server/test/test_SDP.py /p4/test_SDP.py'>> $RUN_SDP_TESTS
echo 'python3.4 /p4/test_SDP.py'>> $RUN_SDP_TESTS
echo '[[ $? -eq 0 ]] || tail /tmp/SDPTest.log'>> $RUN_SDP_TESTS
chmod +x $RUN_SDP_TESTS
chown perforce:perforce $RUN_SDP_TESTS

#
# The file run by docker - just runs the above script as perforce user
# Note that the output file is collected by script run_docker_tests.sh
#
DOCKER_ENTRY=/p4/docker_entry.sh
echo '#!/bin/bash'> $DOCKER_ENTRY
echo 'su -l perforce -c /p4/test_sdp.sh > /sdp/test/output/test-${TESTOS}.out 2>&1'>> $DOCKER_ENTRY
chmod +x $DOCKER_ENTRY
chown perforce:perforce $DOCKER_ENTRY
# Change User Description Committed
#8 25258 Robert Cowham Rework the containers in preparation for multi container testing
mkrep changes:
Remove -c cfg option which was unused anyway
Converted tabs to spaces
Fixed logic error causing forwarding replicas to bail due to unsupported p4d version
Standby servers require ReplicatingFrom field
Add seconds to log file name (useful for testing to avoid overwriting files)
#7 25149 Robert Cowham Changes to docker files as part of prep for multi-container work
Centos6 & 7 now install python 3.6 from ISU Community as pre-built
Refer to p4python==17.2 to avoid need to compile
Changes to test infrastructure only
#6 24580 Robert Cowham Update Docker - fix issues with install of p4python on CentOS.
#5 21267 Robert Cowham Fix failing tests.
Changed default filesystem names to:
DB1=hxmetadata1
DB2=hxmetadata2
DD=hxdepots
LG=hxlogs

hx=Helix. Updated docs to reflect this
#4 20882 Robert Cowham Fix error handling for Jenkins properly
#3 20880 Robert Cowham Improve error handling - tail the log file so errors more visible in Jenkins failures
#2 19130 Robert Cowham Added comments - no functional change
#1 19045 Robert Cowham Add docker file for Centos7
Refactor to move common stuff to a shell script.