Giter VIP home page Giter VIP logo

cf-inspec's Introduction

Build Status

inSpec Cloudfoundry resources

This InSpec resource pack that provides the required resources to write tests for cloudfoundry.

Prerequisites

You need inSpec :)

Usage

Create a new profile

  1. $ inspec init profile my-profile
name: my-profile
title: test
version: 0.1.0
depends:
  - name: cf-inspec
    url: https://github.com/ahelal/cf-inspec/archive/master.tar.gz
  1. Edit inspec.yml to reflect the depends
  2. Define your tests in your_profile/control

Configuration for Opsman resources

You need to export required opsman variables

  • OM_TARGET with schema eg. https://opsman.example.com
  • OM_USERNAME
  • OM_PASSWORD

Optional variables

  • OM_SKIP_SSL_VALIDATION defaults to false

Available resources

List of available resources

Examples

Check the Opsman examples

An example profile

control 'opsman should be reachable and using desired version' do
  describe bosh_info do
    its('version') { should match(/2.3/) }
  end
end

control 'Certificate should not expire in the next two months' do
  describe om_certificates(2, 'm') do
    its('expires') { should be_empty }
  end
end

describe om_director_properties do
  its(%w[director_configuration ntp_servers_string]) { should eq 'us.pool.ntp.org, time.google.com' }
  its(%w[iaas_configuration tls_enabled]) { should eq true }
  its(%w[syslog_configuration enabled]) { should eq true }
end

control 'PCF should be installed, and deigo_cell should be in desired the instance count and type' do
  describe om_deployed_products do
    its(%w[cf version]) { should match(/2.3.9/) }
  end
  describe om_resource_jobs do
    its(%w[cf diego_cell instances]) { should be > 10 }
    its(%w[cf diego_cell instance_type id]) { should eq 'm3.medium' }
  end
end

Running in Concourse

Add the following task to your pipeline and map the location of your tests to the specs input. if your test is located in a subdir you need to pass that too SPECS_SUBDIR: PATH/../

You should read the inspec EULA and if you agree flip the EULA: true

---
resources:
- name: cf-inspec-tasks
  type: git
  source:
    uri: https://github.com/ahelal/cf-inspec.git
    branch: master

- name: source-code
  type: git
  source:
    uri: https://github.com/<ORG>/<CODE>
    branch: master

jobs:
- name: run-inspec
  plan:
  - get: cf-inspec-tasks
  - get: source-code
  - task: run-inspec
    file: cf-inspec-tasks/task/task.yml
    input_mapping:
      specs: source-code
    params:
      OM_TARGET: ((OM_TARGET))
      OM_USERNAME: ((OM_USERNAME))
      OM_PASSWORD: ((OM_PASSWORD))
      SPECS_SUBDIR: test/examples/om
      INSPEC_CACHE_TIME: 0
      EULA: true

API caching

If you have many tests API calls might be slow. You can enable caching to increase test speed.

  • INSPEC_CACHE_TIME defaults to 0 seconds
  • INSPEC_CACHE_DIR defaults to ~/.inspec_cache

cf-inspec's People

Contributors

pjk25 avatar ahelal avatar mathias-ewald avatar dependabot[bot] avatar

Stargazers

Victor Pupim avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.