@@ -2869,4 +2869,51 @@ public static String[] getHosts() {
28692869 }
28702870 return null ;
28712871 }
2872+
2873+ // Disable automation for a LSQT enabled DB on a collection. Tests need to manually advance LSQT.
2874+ public static void disableAutomationOnTemporalCollection (String dbName , String collectionName , boolean enable )
2875+ throws Exception {
2876+ ObjectMapper mapper = new ObjectMapper ();
2877+ ObjectNode rootNode = mapper .createObjectNode ();
2878+ rootNode .put ("lsqt-enabled" , enable );
2879+
2880+ // Set automation value to false
2881+ ObjectNode automation = mapper .createObjectNode ();
2882+ automation .put ("enabled" , false );
2883+
2884+ rootNode .set ("automation" , automation );
2885+
2886+ System .out .println (rootNode .toString ());
2887+
2888+ DefaultHttpClient client = new DefaultHttpClient ();
2889+ client .getCredentialsProvider ().setCredentials (
2890+ new AuthScope (host_name , getAdminPort ()),
2891+ new UsernamePasswordCredentials ("admin" , "admin" ));
2892+
2893+ HttpPut put = new HttpPut ("http://" + host_name + ":" + admin_port + "/manage/v2/databases/" + dbName + "/temporal/collections/lsqt/properties?collection=" + collectionName );
2894+
2895+ put .addHeader ("Content-type" , "application/json" );
2896+ put .addHeader ("accept" , "application/json" );
2897+ put .setEntity (new StringEntity (rootNode .toString ()));
2898+
2899+ HttpResponse response = client .execute (put );
2900+ HttpEntity respEntity = response .getEntity ();
2901+ if (response .getStatusLine ().getStatusCode () == 400 ) {
2902+ HttpEntity entity = response .getEntity ();
2903+ String responseString = EntityUtils .toString (entity , "UTF-8" );
2904+ System .out .println (responseString );
2905+ }
2906+ else if (respEntity != null ) {
2907+ // EntityUtils to get the response content
2908+ String content = EntityUtils .toString (respEntity );
2909+ System .out .println (content );
2910+
2911+ System .out .println ("Temporal collection: " + collectionName + " created" );
2912+ System .out .println ("==============================================================" );
2913+ }
2914+ else {
2915+ System .out .println ("No Proper Response" );
2916+ }
2917+ client .getConnectionManager ().shutdown ();
2918+ }
28722919}
0 commit comments