Automate Some Testing with API Image Download

Version 6

    When upgrading tableau server how can I easily make sure all my dashboard views still work and look like they use to?

    I’m going to outline the method I’ve used at a high level, if I get a few responses asking for further detail I’ll happily add that in, including code etc.

    Oh yeah, at your own risk, understand what the code is doing before your execute.

    There are many ways to skin this particular cat, here’s one that I’ve used to assist this process.

    The Tableau API can do a number of useful tasks one of those is to generate an image of a published dashboard.  We’re going to use that to download the initial view of workbook dashboard / sheet that is published, then we’ll do it again after a software update and compare the two images.

     

    Planning:

    • You’ll need your Tableau Server minimum version 10.2 (to support the API calls)
    • Use a test environment, while this method is sequential and shouldn’t kill a server, I don’t know how good or bad your content is.
    • A static data point will aid with automating later steps, if you’re mainly using extracts a tableau backup will do nicely.
    • A list of what is changing between steps.  For me this was changing server software from 10.2.2 to 10.5.0
    • Permissions, you can only test what you have access to. Being a tableau server administrator will make it easy, but even as interactor you will be able to run this with only a few code tweaks to specify which site you’re logging into etc.

     

    Overview:

    At its best your code will end up being able to

    • Log into Tableau server
    • Get a list of sites
      • For each site
      • Get a list of views
        • For each view
        • Download it and save to a file in a nicely sorted directory
    • Log out

     

    Now you’ve got an image of every view on your server, make your change and do it again, but save to a different folder

     

    Now you’ve got two folders which have an image of every view on your server.

     

    If you manage to do all this, not have any relative data filters and you’re not crossing the 10.4 “precision dashboard spacing” boarder, you might be able to do a simple file checksum to compare your output.

     

    I was traversing this version and also had some relative date calculations / filters so we decided to do some eyeball checking.  (we thought about various image comparison techniques, but we could foresee many small variances we didn’t care about and many small variances we did care about and we weren’t about to embark on some machine learning for this.

    So we just opened image view for each of our before and after folder and flipped through side by side. It was easy to spot to 10.4 version change and we also easily found a bug in 10.5.0 (file locales) that broke a lot of our Makeover Monday and training content

     

     

    My code sample:

    Here's the current version, It doesn't do the automatic site select or the super nice file handling, But it should work I've downloaded thousands of views with a lesser version of it.

    See the Attached file: https://community.tableau.com/servlet/JiveServlet/download/17861-3-254376/Tableau%20Server%20-%20Download%20PNG%20of%20V…

     

    How to use it

    I’m doing this on windows, should be fairly straight forward on Linux also,

    My boss / team uses R so this is all done in R.  I’m equally bad in all languages so not fussed. (except I hate perl)

    • Install Microsoft R libraries then R Studio
    • Open the attached script in R studio and run the install package lines
      • Highline the install.packages("jsonlite") portion without the leading # and press Ctrl-Enter
      • Do that for the other install.packages lines
    • Set the Variables to your environment
      • Vserver should the URL for your server eg. https:\\mytableauserver.company.com
      • Vsite  enter the name of the site you want to get the images from
      • VoutputDir folder you want the image files to save into,  note you'll need to put two \ for every real one  if you want c:\tableau\images, put in c:\\talbeau\\images\\
    • Run the script, it will prompt for a username and password that has access to tableau, It can only get view that the user has access too, a site admin will get the lot
      • You can run the script line by line by moving the cursor to the first line and pressing ctrl-enter on each line as you go (the loops etc will run as a single line)

     

    I've never had someone else run this, so post your errors....

     

    Limitations:

         Lots of these in this initial incarnation

    The API call to download the image was introduced in Tableau 10.2

    It’s only going to give you the initial dashboard view, so your fancy guided analytics dashboards might be mainly whitespace.

    If you’ve got a dashboard that asks for U/P for a data source, nup.

    If you’ve got some fancy row level security, this should work, but for the account you’re logged in as.

    Using relative dates will cause some difference in the output if your downloads are done on different days

     

    Handy Links:

    This is a nice short guide to API’s

    http://www.andrewhavens.com/posts/20/beginners-guide-to-creating-a-rest-api/

     

    Version 0.3 (draft - with some code) - have you run the code? let us know, what features would you like?