Skip to content

Commit

Permalink
added notification tests and some output reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jess Portnoy committed Jul 8, 2015
1 parent a10abb3 commit ba9c543
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 35 deletions.
2 changes: 1 addition & 1 deletion RPM/SPECS/kaltura-base.spec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Summary: Kaltura Open Source Video Platform
Name: kaltura-base
Version: 10.15.0
Release: 3
Release: 4
License: AGPLv3+
Group: Server/Platform
Source0: https://github.com/kaltura/server/archive/%{codename}-%{version}.zip
Expand Down
6 changes: 4 additions & 2 deletions RPM/SPECS/kaltura-postinst.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Summary: Kaltura Open Source Video Platform
Name: kaltura-postinst
Version: 1.0.27
Release: 3
Release: 7
License: AGPLv3+
Group: Server/Platform
Source0: %{name}-%{version}.tar.gz
Expand Down Expand Up @@ -83,7 +83,9 @@ find %{_sysconfdir}/logrotate.d -type l -name "kaltura_*" -exec rm {} \;

%changelog
* Wed Jul 8 2015 Jess Portnoy <jess.portnoy@kaltura.com> - 1.0.27-3
- Added test to upload captions and search entry
- Added upload captions test
- Added search entry test
- Added notification tests

* Fri Jun 19 2015 Jess Portnoy <jess.portnoy@kaltura.com> - 1.0.26-5
- use $SUPER_USER when dropping db, do not assume root
Expand Down
56 changes: 56 additions & 0 deletions RPM/scripts/postinst/http_notifications.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
if($argc<4){
die('Usage: '.$argv[0] .' <partner id> <admin secret> <service_url>'."\n");
}
require_once('/opt/kaltura/web/content/clientlibs/php5/KalturaClient.php');
$userId = null;
$expiry = null;
$privileges = null;
$partnerId=$argv[1];
$secret = $argv[2];
$type = KalturaSessionType::ADMIN;
$config = new KalturaConfiguration($partnerId);
$config->serviceUrl = $argv[3];
$client = new KalturaClient($config);
$ks = $client->session->start($secret, $userId, $type, $partnerId, $expiry, $privileges);
$client->setKs($ks);

// list available HTTP templates:
$filter = new KalturaEventNotificationTemplateFilter();
$filter->systemNameEqual = 'HTTP_ENTRY_STATUS_CHANGED';
$pager = null;
$eventNotificationTemplate = new KalturaHttpNotificationTemplate();
$eventnotificationPlugin = KalturaEventnotificationClientPlugin::get($client);
$notification_templates = $eventnotificationPlugin->eventNotificationTemplate->listTemplates($filter, $pager);
// id for entry change:
if (isset($notification_templates->objects[0]->id)){
$template_id=$notification_templates->objects[0]->id;
}else{
die("\nNo HTTP templates exist.\n Try running:\nphp /opt/kaltura/app/tests/standAloneClient/exec.php /opt/kaltura/app/tests/standAloneClient/httpNotificationsTemplate.xml /tmp/out.xml\nPassing -2 as partner ID");
}

// clone the template to partner:
$result = $eventnotificationPlugin->eventNotificationTemplate->cloneAction($template_id, $eventNotificationTemplate);
$notification_id = $result->id;

// activate template
$status = KalturaEventNotificationTemplateStatus::ACTIVE;
$eventnotificationPlugin = KalturaEventnotificationClientPlugin::get($client);
$result = $eventnotificationPlugin->eventNotificationTemplate->updateStatus($notification_id, $status);

// update url:
$eventNotificationTemplate->type = KalturaEventNotificationTemplateType::HTTP;
$eventNotificationTemplate->eventType = KalturaEventNotificationEventType::BATCH_JOB_STATUS;
$eventNotificationTemplate->eventObjectType = KalturaEventNotificationEventObjectType::ENTRY;
$eventNotificationTemplate->contentParameters = array();
$eventNotificationTemplate->contentParameters[0] = new KalturaEventNotificationParameter();
$eventNotificationTemplate->contentParameters[1] = new KalturaEventNotificationParameter();
$eventNotificationTemplate->contentParameters[2] = null;
$eventNotificationTemplate->contentParameters[3] = null;
$eventNotificationTemplate->url = 'http://localhost/1.php';
$KalturaHttpNotificationDataFields=new KalturaHttpNotificationDataFields();
$eventNotificationTemplate->data = $KalturaHttpNotificationDataFields;
$eventnotificationPlugin = KalturaEventnotificationClientPlugin::get($client);
$result = $eventnotificationPlugin->eventNotificationTemplate->update($notification_id, $eventNotificationTemplate);
echo('ID: '. $result->id. ', URL: "'.$result->url.'"');
?>
45 changes: 13 additions & 32 deletions RPM/scripts/postinst/kaltura-sanity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,7 @@ if $QUERY_COMMAND kaltura-batch >/dev/null 2>&1 || $QUERY_COMMAND kaltura-front
OUT=`php $DIRNAME/dropbox_test.php $SERVICE_URL $PARTNER_ID $ADMIN_PARTNER_SECRET /tmp/sanity-drop-$NOW-$HOSTNAME 2>&1`
RC=$?
END=`date +%s.%N`
if [ $RC -ne 0 ];then
report "Local dropfolder creation failed" $RC "$OUT" "`bc <<< $END-$START`"
else
report "Local dropfolder creation succeeded" $RC "$OUT" "`bc <<< $END-$START`"
fi
report "Local dropfolder creation" $RC "$OUT" "`bc <<< $END-$START`"
PARTNER_SECRET=`echo "select secret from partner where id=$PARTNER_ID" | mysql -N -h $DB1_HOST -p$DB1_PASS $DB1_NAME -u$DB1_USER -P$DB1_PORT`
PARTNER_ADMIN_SECRET=`echo "select admin_secret from partner where id=$PARTNER_ID" | mysql -N -h $DB1_HOST -p$DB1_PASS $DB1_NAME -u$DB1_USER -P$DB1_PORT`
ZERO_PARTNER_ADMIN_SECRET=`echo "select admin_secret from partner where id=0" | mysql -N -h $DB1_HOST -p$DB1_PASS $DB1_NAME -u$DB1_USER -P$DB1_PORT`
Expand All @@ -216,6 +210,12 @@ if $QUERY_COMMAND kaltura-batch >/dev/null 2>&1 || $QUERY_COMMAND kaltura-front
report "Delete flavor param" $RC "$FLAVOR_PARAM_ID" "`bc <<< $END-$START`"
fi
START=`date +%s.%N`
OUT=`php $DIRNAME/http_notifications.php $PARTNER_ID $PARTNER_ADMIN_SECRET $SERVICE_URL`
report "HTTP notification: $OUT" $RC "$OUT" "$TOTAL_T"
START=`date +%s.%N`
OUT=`php $DIRNAME/mail_notifications.php $PARTNER_ID $PARTNER_ADMIN_SECRET $SERVICE_URL`
report "Mail notification: $OUT" $RC "$OUT" "$TOTAL_T"
START=`date +%s.%N`
UPLOADED_ENT=`php $DIRNAME/upload_test.php $SERVICE_URL $PARTNER_ID $PARTNER_SECRET $WEB_DIR/content/templates/entry/data/kaltura_logo_animated_blue.flv 2>&1`
RC=$?
END=`date +%s.%N`
Expand Down Expand Up @@ -255,54 +255,35 @@ if $QUERY_COMMAND kaltura-batch >/dev/null 2>&1 || $QUERY_COMMAND kaltura-front
RC=$?
END=`date +%s.%N`
TOTAL_T=`bc <<< $END-$START`
if [ $RC -eq 0 ];then
report "Clipping $UPLOADED_ENT Succeeded" $RC "$OUT" "$TOTAL_T"
else
report "Clipping $UPLOADED_ENT failed" $RC "$OUT" "$TOTAL_T"
fi
report "Clipping $UPLOADED_ENT" $RC "$OUT" "$TOTAL_T"
START=`date +%s.%N`
OUT=`php $DIRNAME/clip_test.php $SERVICE_URL $PARTNER_ID $PARTNER_ADMIN_SECRET $UPLOADED_ENT 1`
RC=$?
END=`date +%s.%N`
TOTAL_T=`bc <<< $END-$START`
if [ $RC -eq 0 ];then
report "Trimming $UPLOADED_ENT Succeeded" $RC "$OUT" "$TOTAL_T"
else
report "Trimming $UPLOADED_ENT failed" $RC "$OUT" "$TOTAL_T"
fi
report "Trimming $UPLOADED_ENT" $RC "$OUT" "$TOTAL_T"
START=`date +%s.%N`
OUT=`php $DIRNAME/play.php --service-url=$SERVICE_URL --entry-id=$UPLOADED_ENT --partner=$PARTNER_ID --secret=$PARTNER_SECRET|sed "s@\"@@g"`
RC=$?
END=`date +%s.%N`
TOTAL_T=`bc <<< $END-$START`
if [ $RC -ne 0 ];then
report "Mock playback $UPLOADED_ENT failed" $RC "$OUT" "$TOTAL_T"
else
report "Mock playback $UPLOADED_ENT succeeded" $RC "$OUT" "$TOTAL_T"
fi
report "Mock playback $UPLOADED_ENT" $RC "$OUT" "$TOTAL_T"
START=`date +%s.%N`
OUT=`php $DIRNAME/add_caption.php $PARTNER_ID $PARTNER_ADMIN_SECRET $SERVICE_URL $UPLOADED_ENT $CAPTIONS_FILE EN`
RC=$?
END=`date +%s.%N`
TOTAL_T=`bc <<< $END-$START`
if [ $RC -ne 0 ];then
report "Adding captions to $UPLOADED_ENT failed" $RC "$OUT" "$TOTAL_T"
else
report "Addition captions to $UPLOADED_ENT succeeded" $RC "$OUT" "$TOTAL_T"
fi
report "Addition captions to $UPLOADED_ENT" $RC "$OUT" "$TOTAL_T"
sleep 2
START=`date +%s.%N`
# ',' means search for either one of these strings, i.e: logical OR
OUT=`php $DIRNAME/search_entry.php $PARTNER_ID $PARTNER_SECRET $SERVICE_URL "Example,Deja,Bold"`
RC=$?
END=`date +%s.%N`
TOTAL_T=`bc <<< $END-$START`
if [ $RC -ne 0 ];then
report "Searching for Example||Deja||Bold in $UPLOADED_ENT metadata failed" $RC "$OUT" "$TOTAL_T"
else
report "Searching for Example||Deja||Bold in $UPLOADED_ENT metadata succeded" $RC "$OUT" "$TOTAL_T"
fi
report "Searching for Example||Deja||Bold in $UPLOADED_ENT metadata" $RC "$OUT" "$TOTAL_T"
START=`date +%s.%N`
OUT=`php $DIRNAME/recon.php $SERVICE_URL $PARTNER_ID $PARTNER_ADMIN_SECRET $UPLOADED_ENT`
RC=$?
Expand Down
51 changes: 51 additions & 0 deletions RPM/scripts/postinst/mail_notifications.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
if($argc<4){
die('Usage: '.$argv[0] .' <partner id> <admin secret> <service_url>'."\n");
}
require_once('/opt/kaltura/web/content/clientlibs/php5/KalturaClient.php');
$userId = null;
$expiry = null;
$privileges = null;
$partnerId=$argv[1];
$secret = $argv[2];
$type = KalturaSessionType::ADMIN;
$config = new KalturaConfiguration($partnerId);
$config->serviceUrl = $argv[3];
$client = new KalturaClient($config);
$ks = $client->session->start($secret, $userId, $type, $partnerId, $expiry, $privileges);
$client->setKs($ks);

// list available email templates:
$filter = new KalturaEmailNotificationTemplateFilter();
$filter->systemNameEqual = 'Entry_Ready';
$pager = null;
$eventNotificationTemplate = new KalturaEmailNotificationTemplate();
$eventnotificationPlugin = KalturaEventnotificationClientPlugin::get($client);
$notification_templates = $eventnotificationPlugin->eventNotificationTemplate->listTemplates($filter, $pager);
// will return all available
$template_id=$notification_templates->objects[0]->id;
// clone the template to partner:
$result = $eventnotificationPlugin->eventNotificationTemplate->cloneAction($template_id, $eventNotificationTemplate);
$notification_id = $result->id;

// activate template
$status = KalturaEventNotificationTemplateStatus::ACTIVE;
$eventnotificationPlugin = KalturaEventnotificationClientPlugin::get($client);
$result = $eventnotificationPlugin->eventNotificationTemplate->updateStatus($notification_id, $status);

// update mail subject and body:

$eventNotificationTemplate->type = KalturaEventNotificationTemplateType::EMAIL;
$eventNotificationTemplate->eventType = KalturaEventNotificationEventType::BATCH_JOB_STATUS;
$eventNotificationTemplate->eventObjectType = KalturaEventNotificationEventObjectType::ENTRY;
$eventNotificationTemplate->contentParameters = array();
$eventNotificationTemplate->contentParameters[0] = new KalturaEventNotificationParameter();
$eventNotificationTemplate->contentParameters[1] = new KalturaEventNotificationParameter();
$eventNotificationTemplate->contentParameters[2] = new KalturaEventNotificationParameter();
$eventNotificationTemplate->contentParameters[3] = new KalturaEventNotificationParameter();
$eventNotificationTemplate->subject = 'Your video is ready to be played!';
$eventNotificationTemplate->body = 'Hello world:)';
$eventnotificationPlugin = KalturaEventnotificationClientPlugin::get($client);
$result = $eventnotificationPlugin->eventNotificationTemplate->update($notification_id, $eventNotificationTemplate);
echo('ID: '. $result->id. ', Subject: "'.$result->subject.'", Mail body: "'.$result->body.'"');
?>

0 comments on commit ba9c543

Please sign in to comment.