table addCaslib

Edge Case: Handling Invalid Paths and Directory Creation

Scénario de test & Cas d'usage

Business Context

A new user is attempting to create a personal, transient caslib for temporary data storage. They first specify a path that does not exist, testing the system's behavior. Then, they try to create the directory via the action, simulating a common user error and recovery path.
About the Set : table

Loading, saving, and managing in-memory tables.

Discover all actions of table
Data Preparation

Ensure the target directory for the caslib does not exist before starting the test to properly simulate the scenario.

Copied!
1/* Pre-requisite: The directory '/tmp/cas/user_temp_space' must not exist on the CAS controller's file system. */
2/* rm -rf /tmp/cas/user_temp_space */

Étapes de réalisation

1
Attempt to add a caslib with a path that does not exist, without requesting directory creation. This is an expected 'soft' failure.
Copied!
1PROC CAS;
2 TABLE.addCaslib /
3 name="UserTempSpace"
4 path="/tmp/cas/user_temp_space"
5 dataSource={srcType="PATH"}
6 createDirectory=false
7 transient=true;
8RUN; QUIT;
2
Verify that the caslib was created but is not functional. The caslibInfo action will succeed, but a subsequent fileInfo action should fail.
Copied!
1PROC CAS;
2 TABLE.caslibInfo / caslib="UserTempSpace";
3 TABLE.fileInfo / caslib="UserTempSpace"; /* This step is expected to produce an error in the log */
4RUN; QUIT;
3
Remove the non-functional caslib.
Copied!
1 
2PROC CAS;
3 
4TABLE.dropCaslib / caslib="UserTempSpace";
5RUN;
6 
7QUIT;
8 
4
Correct the action by adding the 'createDirectory=true' parameter to automatically create the missing path.
Copied!
1PROC CAS;
2 TABLE.addCaslib /
3 name="UserTempSpace"
4 path="/tmp/cas/user_temp_space"
5 dataSource={srcType="PATH"}
6 createDirectory=true
7 transient=true;
8RUN; QUIT;
5
Verify that the caslib is now functional by successfully listing its (empty) contents.
Copied!
1 
2PROC CAS;
3 
4TABLE.fileInfo / caslib="UserTempSpace";
5RUN;
6 
7QUIT;
8 

Expected Result


In step 1, the 'UserTempSpace' caslib is created successfully, but the log for step 2 shows an error indicating the path does not exist when fileInfo is called, confirming the QA point. After dropping and re-adding the caslib with 'createDirectory=true' in step 4, the fileInfo action in step 5 executes successfully (showing an empty directory), proving the caslib is now functional. The caslib will not persist after the server restarts because it is transient.