 acec05060d
			
		
	
	acec05060d
	
	
	
		
			
			Change license to BSD-3-Clause Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com>
		
			
				
	
	
		
			87 lines
		
	
	
		
			4.7 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			87 lines
		
	
	
		
			4.7 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/bash
 | |
| #
 | |
| # Copyright(c) 2012-2021 Intel Corporation
 | |
| # SPDX-License-Identifier: BSD-3-Clause
 | |
| #
 | |
| 
 | |
| # The line below specified that line under it should be used as the test's short description when launching test via run_tests script.
 | |
| # The text should not be longer than 80 chars - if it is, the script will strip addititonal characters
 | |
| # DESCRIPTION WB data integrity ext3/ext4/xfs after clean shutdown, no flush
 | |
| 
 | |
| # USE_IN_NIGHTLY
 | |
| # USE_IN_BVT
 | |
| # Standard beginning for every test - get the main tests directory and
 | |
| # link the cas_lib file for CAS API, then use "start_test $*" to pass params
 | |
| # and do other necessary checks and setup
 | |
| TESTS_DIR="$(dirname $0)/../"
 | |
| . $TESTS_DIR/cas_lib
 | |
| start_test $*
 | |
| 
 | |
| CACHE_MODE="wb"
 | |
| 
 | |
| # This is where the real test starts
 | |
| 
 | |
| # Use CACHE_DEVICE and CORE_DEVICE provided by configuration file and remove partitions from those devices
 | |
| TARGET_DEVICE_OPTION="$CACHE_DEVICE" remove_partitions
 | |
| TARGET_DEVICE_OPTION="$CORE_DEVICE" remove_partitions
 | |
| 
 | |
| # Create 3 primary partitions on CACHE_DEVICE, each of 2000M size
 | |
| TARGET_DEVICE_OPTION="$CACHE_DEVICE" PARTITION_SIZE_OPTION="2000M" PARTITION_IDS_OPTION="1 2 3" make_primary_partitions
 | |
| # Create 3 primary partitions on CORE_DEVICE, each of 4000M size
 | |
| TARGET_DEVICE_OPTION="$CORE_DEVICE" PARTITION_SIZE_OPTION="4000M" PARTITION_IDS_OPTION="1 2 3" make_primary_partitions
 | |
| 
 | |
| # Start cache on CACHE_DEVICE1 (/dev/sdd1, for example) with ID=1 and add a core device using CORE_DEVICE1 (/dev/sde1, for example)
 | |
| CACHE_ID_OPTION="1" CACHE_DEVICE_OPTION="${CACHE_DEVICE}-part1" CACHE_FORCE_OPTION="1" CACHE_MODE_OPTION=$CACHE_MODE start_cache
 | |
| CACHE_ID_OPTION="1" CORE_DEVICE_OPTION="${CORE_DEVICE}-part1" add_core
 | |
| 
 | |
| # Start cache on CACHE_DEVICE2 (/dev/sdd2, for example) with ID=2 and add a core device using CORE_DEVICE2 (/dev/sde2, for example)
 | |
| CACHE_ID_OPTION="2" CACHE_DEVICE_OPTION="${CACHE_DEVICE}-part2" CACHE_FORCE_OPTION="1" CACHE_MODE_OPTION=$CACHE_MODE start_cache
 | |
| CACHE_ID_OPTION="2" CORE_DEVICE_OPTION="${CORE_DEVICE}-part2" add_core
 | |
| 
 | |
| # Start cache on CACHE_DEVICE3 (/dev/sdd3, for example) with ID=3 and add a core device using CORE_DEVICE3 (/dev/sde3, for example)
 | |
| CACHE_ID_OPTION="3" CACHE_DEVICE_OPTION="${CACHE_DEVICE}-part3" CACHE_FORCE_OPTION="1" CACHE_MODE_OPTION=$CACHE_MODE start_cache
 | |
| CACHE_ID_OPTION="3" CORE_DEVICE_OPTION="${CORE_DEVICE}-part3" add_core
 | |
| 
 | |
| # Create filesystems on cached devices - we do this using run_cmd because it is not in the API (and probably won't be).
 | |
| # The test framework will accept invoking the commands directly (e.g. "mkfs.ext3 [...]" without the "run_cmd"), but the
 | |
| # results have to be checked manually by the test.
 | |
| TARGET_DEVICE_OPTION="${DEVICE_NAME}1-1" FILESYSTEM_TYPE="ext3" make_filesystem
 | |
| TARGET_DEVICE_OPTION="${DEVICE_NAME}2-1" FILESYSTEM_TYPE="ext4" make_filesystem
 | |
| TARGET_DEVICE_OPTION="${DEVICE_NAME}3-1" FILESYSTEM_TYPE="xfs" make_filesystem
 | |
| 
 | |
| # Specify a temporary file used for md5sums - note that it resides in $TMP_DIR, which is a special directory defined in cas_config.
 | |
| # Everytime we use temporary files, they should be placed in that special directory. Its contents are cleared after every test.
 | |
| MD5_FILE="$TMP_DIR/cas_md5_sum_"
 | |
| 
 | |
| # Mount the filesystems, then create the example files and save their MD5 sums locally in the temporary place
 | |
| # Note the usage of ${MOUNTPOINT} - mount_cache always mounts using following formula: ${MOUNTPOINT}-${CACHE_ID_OPTION}-${CORE_ID_OPTION}.
 | |
| for ID in 1 2 3 ; do
 | |
|     CACHE_ID_OPTION="$ID" CORE_ID_OPTION="1" mount_cache
 | |
|     run_cmd "dd if=/dev/urandom of=${MOUNTPOINT}-${ID}-1/test bs=50M count=1"
 | |
|     run_cmd "md5sum ${MOUNTPOINT}-${ID}-1/test > ${MD5_FILE}_${ID}"
 | |
| done
 | |
| 
 | |
| # Umount & stop the caches, then mount the core devices
 | |
| # Note the usage of ${MOUNTPOINT} - mount_cache always mounts using following formula: ${MOUNTPOINT}-${CACHE_ID_OPTION}-${CORE_ID_OPTION}.
 | |
| for ID in 1 2 3 ; do
 | |
|     run_cmd "umount ${MOUNTPOINT}-${ID}-1"
 | |
|     CACHE_ID_OPTION="$ID" flush_cache
 | |
|     CACHE_ID_OPTION="$ID" CACHE_DONT_FLUSH_DATA_OPTION="1" stop_cache
 | |
|     run_cmd dd if=/dev/zero of="${CACHE_DEVICE}-part${ID}" bs=1M count=1 oflag=direct
 | |
|     run_cmd "mount ${CORE_DEVICE}-part${ID} ${MOUNTPOINT}-${ID}-1"
 | |
| done
 | |
| 
 | |
| # Now check for files' presence and umount core devices
 | |
| # Note the usage of ${MOUNTPOINT} - mount_cache always mounts using following formula: ${MOUNTPOINT}-${CACHE_ID_OPTION}-${CORE_ID_OPTION}.
 | |
| for ID in 1 2 3 ; do
 | |
|     run_cmd "test -f ${MOUNTPOINT}-${ID}-1/test"
 | |
|     run_cmd "md5sum -c ${MD5_FILE}_${ID}"
 | |
|     run_cmd "umount ${MOUNTPOINT}-${ID}-1"
 | |
| done
 | |
| 
 | |
| # Always return 0 at the end of the test - if at any point something has failed
 | |
| # in the API functions, test will end and return a proper result.
 | |
| # If you need to check other things during the test and end the test earlier, you
 | |
| # should end the test using "end_test $retval" function
 | |
| end_test 0
 |