Author: way0utwest

  • My Second Pester Test

    I should write about my first one, but I just copied Rob’s test, so that’s not so exciting. Instead, I decided to take his advice and write some code, then decide how I test it. This isn’t really TDD, but I need to understand how Posh returns things, so I’ll figure that out first.

    I decided to work with SQL Clone, since that’s an area I’m working in a bit already. SQL Clone has a set of PoSh cmdlets that you can use to create database clones, so I thought that would be a good test.

    What do I test?

    My process is to remove a clone if it exists and then add one back. For testing, I need to consider what actually is happening here.

    • If a cloned database exists, remove it
    • Create a new cloned database

    The result of this process means that I’ll have a Clone, no matter whether I created a new one or had to remove one and recreate a new one. Or, if I had a Clone already and my script failed. This last one is something a tester needs to be aware of.

    In my case, I can determine if there is a new clone by looking at the created date of the database object. If that was later than the beginning of my test, then I could likely assume my clone was new.

    To start with, I created a function that would destroy and create a simple clone. Once I had that, I could now write my Pester test.

    I started with a “describe” element, in which I loaded my function and set a starting time.

    Then in the “it” section, I run my function and then check the instance, getting the CreateDate property of my clone database. If my function has worked, this will be a new clone, created since my test started. I compare that to complete the test.

    I ran this with Invoke-Pester, and it worked.

    2017-11-28 14_58_31-powershell

    This wasn’t simple. I had to test my test a few times, and use PoSh commands to verify it was doing what I thought. I also changed my function with a hardcoded db clone name to ensure the test fails. Results for that one here:

    2017-11-28 14_59_55-powershell

    Of course, I changed things back and tested again. Now, as I update my function to include adding in the instance name and image name,  this test should still pass. Of course, I can add in other tests, or change this one, to allow me to test on different images and instances as well.

    A simple test, maybe a silly one, but I learned a few things about my PoSh code (and how to write it cleaner) as well as Pester and adding in another unit test framework. Now I can expand this to test other PoSh items I have and practice writing better tests that will give me confidence my code works in a variety of situations.

  • Join Me Online Next Week for SQL in the City

    It’s one week to SQL in the City 2017, once again streamed. I’ll be traveling this weekend to the Redgate office and getting setup. After two days of rehearsing, I’ll be ready for the live broadcast Dec 13.

    Here’s a quick promo video as well:

    Once again, we’ll be covering a number of topics that you will be interested in such as code analysis, performance counters, Database DevOps, and more. Perhaps a topic that most of us need to learn more about is data protection and privacy. We’ll have a bit to discuss here as well. This is a topic that is important for us as GDPR will take effect in 2018 and will impact us, as well as many of you.

    You can see the full schedule, which is going to be broadcast twice. A lunch show for Europe and an evening show (for me) for the afternoon in the US. We’ll be live both times, so tune in and bring your

    A long day for me, though I hope to get out to the gym between the shows. We’ll see as I’m sure I’ll have a few meetings with product groups as well.

    Register today and I’ll see you online next week. Brings lots of questions and we’ll do our best to give you the answers you need to improve your database development.

  • Pluralsight is Amazing

    I used to work for a digital learning company early in the modern Internet. We were ahead of our time and struggled to sell online learning at the turn of the millennium. Bandwidth limitations held back video courses from widescale adoption. I moved on when the company folded, but I’ve watched other companies start to build and grow video training across the years. One of them that I’ve been most impressed with is Pluralsight. In fact, I very much appreciate their customer service.

    I try to make time every week to watch something. I don’t always get to any bits of learning, which is the way things go. Life is busy, and some days I don’t have the mental energy. I do try to download a course or two to my phone for long plane rides and other travel. I’ve even had a few modules playing on long drives or in my headphones while skiing. Of course, I can’t watch the screen during those events, but I can listen and try to learn something on the go. I’ve even whiled away sessions on the stationary bike with a Pluralsight course playing in front of me. It’s not deep learning, but it’s a way of looking at something that I find interesting. I often will go back and try a bit of code later.

    I don’t focus too tightly on SQL Server with Pluralsight as I get plenty of that elsewhere, but sometimes I use their courses for investigation into other areas. I’ve listened to Chef and Puppet courses, C#, ASP MVC, Python, and more. I don’t always use the skills directly, but a little learning does help me understand the larger view of how technology works. I’ve found throughout my career that having some good general knowledge in various areas helps me troubleshoot and understand the larger picture, often helping me find an issue in a complex system quicker. I also get ideas on why I might consider some other type of technology as a way of improving an application in the future.

    I certainly hope that most of you continue to come to SQLServerCentral to get ideas, learn something, and get questions answered. My mission with this site is to help others become better SQL Server professionals. We may add some video to go with our written work, and certainly I think we could improve some assessments and testing. If there are areas you’d like to see more content, let us know.

    However, we can’t do what Pluralsight does with their long courses and variety of topics. If you get the chance, or have a subscription, check them out. They provide a great learning resource that I’d recommend.

    Steve Jones

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( 3.7MB) podcast or subscribe to the feed at iTunes and Libsyn.

  • Can Data Save the World?

    Years ago I read one of the Freakonomics books. It was an interesting look at how we might examine our world in unexpected ways, using lots of data. While I didn’t always agree with the conclusions of the authors in different areas, I did find the idea of using data to probe and examine for patterns in our world to be fascinating.

    Recently I caught a podcast with the authors, and the opening question caught my eye. It was “can data save the world?”, and I was hooked, needing to stop and listen to the episode. That’s because I think data is the most important asset in the world today, and data is what really powers all the software we have. We need data, and we need to ensure our data has a high level of quality and integrity in order to glean information from all those bits and bytes to get value from software. Certainly software matters, but data, to me, is more important.

    The authors’ position is interesting in that they see data as an important part of analyzing data. The type of data, industry, organization, etc. doesn’t matter, but the data also isn’t necessarily enough to change someone’s mind or convince them of an argument. There needs to be a story as well, which requires a different skill from that needed for analyzing data. I do think that often the way in which we present an analysis can be just as important as the data. Perhaps even more so.

    What I do find interesting in the podcast is that younger companies (and people) are willing to embrace more data driven approaches. I see that often. There have been no shortage of clients in my career that were sure they knew the answer to some question about their business job without referring to any data analysis. They trusted their experience. Even if there was data that might show their conclusions were slightly erroneous, they often didn’t want to change their decision or conclusion.

    Humans are creatures of habit. Even those of us that embrace some change will find that we like change in some parts of our lives, but not others. If someone has had success in their career without using data to support or alter their opinions, it can be hard to get them to change. I wish I had a good method for convincing people to get started using more data, but really I think that the best idea is to find a different person to convince. If you can do so, and produce real results, then you may be able to go back to the first person and show them some evidence.

    The one part of the podcast that I wish turned out different is at the end, where the authors note there isn’t a good way to teach someone how to analyze data and tell a story. They thought about creating their own curriculum, but gave up. It’s too much work, and apparently they weren’t sure they could do a good job.

    They imply this is harder than teaching someone to program, which is disappointing as we have lots of programmers that need help as well. If we can’t teach programmers at any scale, what does that mean for data scientists? The one part I would agree with them on is that data science is a great area to move towards your career if you have the talent.

    Steve Jones

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( 4.3MB) podcast or subscribe to the feed at iTunes and Libsyn.