Showing posts with label Reference. Show all posts
Showing posts with label Reference. Show all posts

Monday, July 1, 2019

How to create a Ubuntu Desktop on Azure

We have multiple Linux offerings on Azure for the server but none for the desktop. How can we build one hassle-free?

Photo by XPS on Unsplash

Azure offers a variety of Linux servers including RHEL, CentOS, Debian and Ubuntu. But no desktop. As developers, it would be nice to have access to a development VM on the cloud with a GUI and software like Visual Studio Code and Chrome.

On this post, let's see how to install the necessary software to transform an Ubuntu server into a functional Ubuntu desktop including the necessary procedures to RDP into it from Windows, Mac and Linux.

What we will do

On this tutorial we will install the following tools:
If you need Visual Studio Code, please follow this tutorial.

Creating the Instance

The base image for our desktop will be Ubuntu Server 18.04 LTS. As this is a server image, it doesn't contain a GUI. We will install it ourselves as long as a browser and a tool to connect remotely via RDP. By default we can connect to it via SSH using our WSL or Putty. In Azure, click "Create a Resource" then select Ubuntu Server 18.04 LTS.

When this post was created 18.04 was the last LTS but now we have 20.04. Feel free to use it if you prefer. The steps are exactly the same!

Configuring the VM

Now let's configure the VM. Here we will set the username, password, VM name, resource group, region, etc that are adequate to you. For example, my configuration is show below:

Setting up Disks

The next step is disk setup. I selected Premium SSD with 10GB as seen below:

Setting up the Network

For the network interface, I created a new VNet/Subnet and requested a new IP. Note that the IP will only be available to us after creation. You also need to open inbound ports for SSH (22) and RDP (3389) as we'll need them later to access our instance remotely later: 

Review and Create

Review and if everything's correct, click on Create to proceed:
After a couple of minutes the instance should be created and running.

Connecting to our Instance

Once our instance is deployed, let's connect to it. Depending on how you configured during creation, it can be accessed via username/password or via SSH. You should use Azure's overview window to get important information as IP address and username.

To access it, click the Connect tab from where you should see:

Because I configured ssh and uploaded my ssh key, I simply have to open my WSL and enter the following command:
# connect to my remote server using ssh
ssh bruno@<my-ip>
This is the output of my first connection to that VM:
If you chose to provide an username/password during creation, you're still good to connect via SSH. The only difference is that you'll have to provide your password upon connection.

Diagnosing Connection Issues

If for some reason you get:

ssh: connect to host 13.66.228.253 port 22: Resource temporarily unavailable
it's because the port 22 (SSH) is not open for connection externally. And that's a good thing! It pretty much tells us that our connection is being blocked by a firewall. By default in Azure, VMs are wrapped into a Network Service Group (NSG) which is an extra layer of protection to our cloud artifacts. It basically provides full control over traffic that ingresses or egresses a virtual machine in a VNet.

In order to expose that port, click on the Networking tab to change the inbound rules:
To add a new one, we click the Add inbound port rule button and enter the rule as below:

Security Considerations

Please note that it's recommended that you only expose ports that are essentially necessary to to security threats. In our example, we should only expose ports 22 (SSH) and 3389 (RDP). It's also recommended to configure your NSG to restrict access to your IP only.

Once that's done, try to connect again with:

# connect to my remote server using SSH
ssh bruno@<my-ip>

Installing the Required Tools

With the VM up and running and with SSH access to it, it's time to install the required tools to make our server more user friendly. Remember, we'll have to install a desktop manager, some CLI tools and Firefox.

Updating the system

The first thing to do should be updating the system and the list of packages available to your Ubuntu instance with:
# Updating the package Sources
sudo apt update && sudo apt upgrade -y

Installing the CLI tools

The next step is to install useful CLI tools to work (some of them are already pre-installed with the Azure/Ubuntu image):
# install basic terminal tools
sudo apt install tmux git ranger vim

Installing LXDE

Now, let's install our desktop (LXDE). The good news is that Canonical, the good folks behind Ubuntu, already provide a metapackage called lubuntu-desktop that contains not only LXDE but Firefox and other very useful GNOME tools. We install it using the following command:
sudo apt install lubuntu-desktop -y
Please note that this installation take a while as ~2GB of files have to be downloaded and installed on your server.

Setting up Xrdp

The last and final step is to install Xrdp. As previously mentioned, this tool is required to connect to our instance using RDP. This installation downloads ~8Mb and runs very quickly after the above commands. Type the following on the shell:
# install xrdp
sudo apt install xrdp -y
Next step is to start the xrdp service so we can connect to it via RDP.
# start the xrdp service
sudo systemctl start xrdp

Connecting via RDP

All should be good to go now so let's try to connect to our machine. Simply enter the IP address on the RDP information and hit connect. On mine, I got the prompt:
Note that if when creating your VM on Azure you selected SSH, you have to setup a new password for your user. This is done with:
# setting up a new password for our user
sudo passwd bruno

LXDE 

If you enter your password correctly, you should login to your LXDE session. This is my awesome LXDE session running on Azure. By clicking on the blue icon above you'll have access to all the software included with the metapackage:

Persisting Changes

What happens after a reboot? Will the VM still run Xrdp? No. Unless we make the service permanent. If that's what you want, do that by running the below command on the terminal:
# permanently enable the Xrdp service during boot
sudo systemctl enable xrdp

Final Thoughts

The cloud is an awesome environment to test new things out. On this example I used Azure but you could reproduce pretty much everything here on your cloud provider of choice. It's also important to remember that two of the most fundamental aspects of a Linux system are customization and extensibility. So, installing/changing a GUI, trying out different software, adding/removing repos, etc should be simple on the cloud as is on a local VM. And that shouldn't prevent us from being creative and using our imagination.

I encourage you to play with Azure or your preferred cloud provider and experiment not only with a Ubuntu Linux VM but other operating systems. It's all a few clicks away and a fantastic learning experience!

References

See Also

Monday, May 21, 2018

Seven Databases in Seven Weeks, 2nd Edition

The book is an interesting heads-up on databases being used on different fields throughout the world.
You may or may not have heard about polyglot persistence. The fact is that more and more, software projects are making use of different technologies. And when it comes to the database world, the number of options is immense: it can be relational, document or columnar databases, key-value stores, graph databases, not to mention other cloud infrastructure options like service buses, blobs, storage accounts and queues.

What to use? Where? And how does that affects developers?

Choosing a database is perhaps one of the most important architectural decisions a developer can make. In that regard, I'd like to recommend a very interesting book that addresses some of that discussion: Seven Databases in Seven Weeks, 2nd Edition.

Why you should read this book

Because the book:
  • provides practical and conceptual introductions to Redis, Neo4J, CouchDB, MongoDB, HBase, PostgreSQL, and DynamoDB
  • introduces you to different technologies encouraging you to run your own experiences
  • revises important topics like the CAP Theorem
  • will give you an overview of what’s out there so you can choose the best tool for the job
  • explore some cutting-edge databases available - from a traditional relational database to newer NoSQL approaches
  • and make informed decisions about challenging data storage problems
  • tackle a real-world problem that highlights the concepts and features that make it shine

Conclusion

Whether you're a programmer building the next big thing, a data scientist seeking solutions to thorny problems, or a technology enthusiast venturing into new territory, you will find something to inspire you in this book.

Reference

See Also

Thursday, May 17, 2018

Windows command line reference available

In case you don't know, Windows does have a command line reference. Read to understand where to find it.
Microsoft published a Windows command line reference document that has 5 Mb and has 948 pages. Parameters are explained in detail in the doc and they are essentially the same information that you get when you run the command with the /? option on the command line.

There are also some examples for certain commands that you don't get with the /? option on the command line.

What I like in this format is that, by being a PDF document, I can search for commands or information quickly and you may get what you look for faster than searching online.

It's also a good doc to keep around when working offline.

Download

The document can be downloaded here: https://www.microsoft.com/en-us/download/confirmation.aspx?id=56846

See Also

Monday, December 18, 2017

Getting last modified software on Windows using PowerShell

Getting the list of the last modified software on Windows is actually simple, if using PowerShell
Photo by Miti on Unsplash
Whenever I get requests like "hey, how can I get the lastly installed software on my machine?", I try to resolve them with code and as simple as possible. Turns out that on Windows, PowerShell can be an excellent tool for scripts like those. On this post, let's address that using PowerShell and review how it became a fun, simple and quick exercise.

Using Get-WmiObject

The Get-WmiObject cmdlet is what we need to get Windows diag information. By combining it with Export-Csv we can export all installed software on our machines with:
Get-WmiObject -Class Win32_Product | Export-Csv installed.csv

Using Get-ChildItem

The next part consists in using the Get-ChildItem cmdlet to filter out our exported data. That can be done with:
# getting last modified files
Get-ChildItem C:\ -rec | sort LastWriteTime | select -last 1000 | Export-Csv files.csv

Conclusion

Doing this simple exercise was fun, simple and quick using PowerShell. Don't know PowerShell yet? I would urge you to take a look and learn it (even if just the basics). PowerShell is a powerful tool used extensively in devops on Windows, Azure and Linux.

Oh, and yes, I really don't miss the days before PowerShell!

Monday, December 11, 2017

PowerShell - The server committed a protocol violation

Let's understand what that error means and review 3 different ways to fix it.
Photo by Max Rovensky on Unsplash

This sort article details a good trick for those getting the following error in PowerShell: 
The server committed a protocol violation
After googling ducking around, I found three different solutions for this problem:
  1. Modifying your powershell.exe.config;
  2. Modifying your request in order to avoid it stopping if your url is invalid in .NET
  3. Modifying your request in order to avoid it stopping if your url is invalid in PowerShell.
Let's review each of them and understand a little more about the problem.

    Solution 1 - Modifying powershell.exe.config

    This solution will apply to all PowerShell requests so use with caution. Also, this solution is not portable so, if you plan to run this script on a machine you don't have admin access to, this solution will probably not work.
    <system.net>
    <settings>
    <httpWebRequest useUnsafeHeaderParsing="true" />
    </settings>
    </system.net>

    Solution 2 - Modifying your request in .NET

    To modify your request, have the code below before you actually run Invoke-WebRequest:
    $netAssembly = [Reflection.Assembly]::GetAssembly([System.Net.Configuration.SettingsSection])

    if($netAssembly)
    {
        $bindingFlags = [Reflection.BindingFlags] "Static,GetProperty,NonPublic"
        $settingsType = $netAssembly.GetType("System.Net.Configuration.SettingsSectionInternal")

        $instance = $settingsType.InvokeMember("Section", $bindingFlags, $null, $null, @())

        if($instance)
        {
            $bindingFlags = "NonPublic","Instance"
            $useUnsafeHeaderParsingField = $settingsType.GetField("useUnsafeHeaderParsing", $bindingFlags)

            if($useUnsafeHeaderParsingField)
            {
              $useUnsafeHeaderParsingField.SetValue($instance, $true)
            }
        }
    }

    Solution 3 - Modifying your request in PowerShell

    This is probably the simplest. Just run the line below:
    [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }

    Conclusion

    On this post we reviewed three different ways to resolve a problem in PowerShell. Don't know PowerShell yet? I would urge you to take a look and learn it (even if just the basics). PowerShell is a powerful tool used extensively in devops on Windows, Azure and Linux.

    See Also

    Monday, October 2, 2017

    Interview questions for QA analysts

    Hiring a QA engineer? Here are some ideas.

    We were asked to provide feedback on what I would like to see in a potential QA analyst. Apart from the traditional and essential HR screening (which they know way better than us) this post is about what I would like to see in a QA engineer working in my team.

    Conceptual / Basic Questions

    Before everything, we're interested in knowing if the person has solid understanding on why that work is being done, why it's important and how to get good results out of it. So, we would like to know, for example:
    • In your understanding, what are the benefits of QA?
    • In your opinion, what is the role of a QA analyst in a project development?
    • What is severity and priority of a bug? Give examples;
    • Define bug triage;
    • Expect some sort of calculation using severity, number of tests, dependent tasks, etc;
    • How to Estimate Testing effort;

    Define why do we test software?

    Expect the answer to include thinks like:
    • the process of assuring that the product being developed is meeting all requirements.
    • the reason to perform testing is to find bugs and make sure that they get fixed.

    Why do we do QA?

    Expect the answer to include thinks like:
    • to find the bugs before the product is released to customer.
    • to improve the quality of the product
    • to evaluate that the product is according to requirements

    When is it the best moment to start QA in a project?

    Expect the answer to include thinks like:
    • A good time to start the QA is from the beginning of the project startup.
    • This will lead to plan the process which will make sure that product coming out meets the customer quality expectation.
    • QA also plays a major role in the communication between teams. It gives time to step up the testing environment.
    • The testing phase starts after the test plans are written, reviewed and approved.

    What are the key challenges of software testing?

    Expect the answer to include thinks like:
    • Application should be stable enough to be tested.
    • Testing always under time constraint
    • Understanding requirements, Domain knowledge and business user perspective understanding
    • Which tests to execute first?
    • Testing the Complete Application
    • Regression testing
    • Lack of skilled testers.
    • Changing requirements
    • Lack of resources, tools and training

    Define a testing lifecycle?

    There is no standard testing life cycle, but I like to have following phases and would expect some (if not all) of them being mentioned:
    • Test Planning (Test Strategy, Test Plan, Test Bed Creation)
    • Test Development (Test Procedures, Test Scenarios, Test Cases)
    • Test Execution
    • Result Analysis (compare Expected to Actual results)
    • Defect Tracking
    • Reporting

    List different types of tests

    I expect at least 5 of the following:
    • Manual testing
    • Smoke testing
    • Regression testing
    • Automated testing
    • Stress Test
    • Load Test
    • Performance Test
    • Exploratory Testing

    Programming Skills

    For me, developers (as sysadmins/devops engineers), would do their job way more efficiently if they knew how to programm. If she knows how to program, then I would ask:
    • to write a simple function that would, for example, write a string backwards;
    • if the person knows html, css? Exercise that a little;
    • does the person know how to hit a restful api to use browserstack, for example;
    • does the person know javascript;
    • does the person know some other scriptting language so he/she would be able to write some automation;

    SQL / NoSQL Questions

    I would also very interested in knowing if the person knows SQL. Not necessarily super well but well enough to deal with basic sql instructions and be independent. Also, in case you use NoSQl, ability to query your db in your query language like for example, MongoDb's query syntax or Lucene.

    Software Automation Questions

    In order to maximize the return of a QA in the team, test automation is a must. That said, the person needs to have enough programming skills write reproducible tests using selenium for example. Personally, I would like to know if the person: 
    • thinks automation is important?
    • knows when to automate?
    • knows what are the benefits of automating?
    • knows what are the downsides of automating?
    • have written automated tests?
    • have used selenium?
    Having already working selenium is a big advantage for me.

    Infrastructure Questions

    Expect the answer to include thinks like:
    • What's the difference between a build and a release?
    • Yes, I have used Azure or AWS before;
    • Yes, I know how to use ftp;
    • Yes, I know how to you check if a server is up;
    • have previously used git, github?
    • have previously you/written a wiki?
    • have previously used Firebug / Chrome Dev tools 
    • is able to inspect, communicate js/html issues;

    Board/Offline Exercise

    While I don't think we should always use the board, it would be interesting to use the board to check how the person would improvise on two scenarios:

    Scenario 1 - Write a test document based on a real use case

    In this scenario, I would present a simple use case such as how to create an account on my system (please, use a simple enough for your own system):
    1. Navigate to the landing page of my site;
    2. Click on the Register button;
    3. Enter essential information to create account;
    Then, ask user to:
    • List what he/she would have validated?
    • What boundary tests could be written?
    • Ask user to write test matrix;

    Scenario 2 - Write a bug report

    Still on the create account use case, let's assume that the system should email the new user a confirmation token but it didn't. I then would be interested in:
    • How would the person write a report in case the email didn't reach your inbox? 
    • If the person would document simple stuff as:
      • Date of the test, url, browser version, etc;
      • Steps:
        • clicked on button X;
        • Entered the following info...;
        • Clicked submit;
      • Expected result;
      • Actual result;
    That is what I, as a developer, would like to see in a basic bug reported: enough information to reproduce and fix the test. Less than that may be insufficient to reproduce it meaning the probably   the candidate is not a good fit.

    Differential

    I consider the following, differential to have:
    • Selenium/Automation experience;
    • Cloud experience;
    • Being able to discuss technical details with the developer
    • Linux/MacOS experience;

    Conclusion

    So, this is all that came to my mind. There's probably more to it but I think that the list above covers a good, very strong candidate. Note that this is by no means a checklist but how I describe a very strong QA candidate and I would be very happy to have someone with the above skills in my team.

    About the Author

    Bruno Hildenbrand      
    Principal Architect, HildenCo Solutions.