Cloud Cost Fitness API

A library to express and test your cloud costs as architecture fitness functions.

License

License

GroupId

GroupId

de.qaware.cloud.cost
ArtifactId

ArtifactId

cloud-cost-fitness-api
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Cloud Cost Fitness API
A library to express and test your cloud costs as architecture fitness functions.
Project URL

Project URL

https://github.com/qaware/cloud-cost-fitness
Project Organization

Project Organization

QAware GmbH
Source Code Management

Source Code Management

http://github.com/qaware/cloud-cost-fitness/tree/master

Download cloud-cost-fitness-api

How to add to project

<!-- https://jarcasting.com/artifacts/de.qaware.cloud.cost/cloud-cost-fitness-api/ -->
<dependency>
    <groupId>de.qaware.cloud.cost</groupId>
    <artifactId>cloud-cost-fitness-api</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/de.qaware.cloud.cost/cloud-cost-fitness-api/
implementation 'de.qaware.cloud.cost:cloud-cost-fitness-api:1.0.1'
// https://jarcasting.com/artifacts/de.qaware.cloud.cost/cloud-cost-fitness-api/
implementation ("de.qaware.cloud.cost:cloud-cost-fitness-api:1.0.1")
'de.qaware.cloud.cost:cloud-cost-fitness-api:jar:1.0.1'
<dependency org="de.qaware.cloud.cost" name="cloud-cost-fitness-api" rev="1.0.1">
  <artifact name="cloud-cost-fitness-api" type="jar" />
</dependency>
@Grapes(
@Grab(group='de.qaware.cloud.cost', module='cloud-cost-fitness-api', version='1.0.1')
)
libraryDependencies += "de.qaware.cloud.cost" % "cloud-cost-fitness-api" % "1.0.1"
[de.qaware.cloud.cost/cloud-cost-fitness-api "1.0.1"]

Dependencies

runtime (1)

Group / Artifact Type Version
org.apache.commons : commons-math3 jar 3.6.1

Project Modules

There are no modules declared in this project.

Cloud Cost Fitness

Build Status Quality Gate Status Coverage License

A library to express and test your cloud costs as architecture fitness functions.

Usage

Dependency Definition

If you are using Gradle as a build tool the following dependency needs to be added to your project dependencies.

testImplementation 'de.qaware.cloud.cost:cloud-cost-fitness-api:1.0.0'
testRuntimeOnly 'de.qaware.cloud.cost:cloud-cost-fitness-aws:1.0.0'

If you are using Maven as a build tool the following dependency needs to be added to your project dependencies.

<dependency>
    <groupId>de.qaware.cloud.cost</groupId>
    <artifactId>cloud-cost-fitness-api</artifactId>
    <version>1.0.0</version>
    <type>test</type>
</dependency>
<dependency>
    <groupId>de.qaware.cloud.cost</groupId>
    <artifactId>cloud-cost-fitness-aws</artifactId>
    <version>1.0.0</version>
    <type>test</type>
</dependency>

Cloud Cost Fitness Tests using Spock

The Cloud Cost Fitness library can be used nicely in combination with the Spock Framework. Simply define a test specification, create a cost explorer for the desired cloud provider and implement a dedicated test for each cloud cost fitness function.

@Requires({ sys['aws.access.key'] && sys['aws.secret.key'] })
class CloudCostFitnessSpec extends Specification {
    @Shared
    CostExplorer costExplorer = CloudProvider.AMAZON_AWS.getCostExplorer()

    def "checks the total costs"() {
        expect: "the total costs to be less than a limit"
        costExplorer.during(YESTERDAY).getCosts().sum().lessThan(100.0)
    }

    @Unroll
    def "check the costs of EC2 instance #service"() {
        expect: "the cost is less than the limit"
        costExplorer.during(LAST_7_DAYS).forService(service).getCosts().sum().lessThan(250.0)

        where:
        service << costExplorer.forService("Amazon Elastic *").getNames()
    }
}

For the complete example have a look at CloudCostFitnessSpec.groovy found under src/test/groovy/.

Cloud Cost Fitness Tests using JUnit 5

The Cloud Cost Fitness library can also be used nicely in combination with JUnit 5. Simply define a test class, create a cost explorer for the desired cloud provider and implement a dedicated test for each cloud cost fitness function.

@EnabledIfSystemProperty(named = "aws.access.key", matches = ".*")
@EnabledIfSystemProperty(named = "aws.secret.key", matches = ".*")
class CloudCostFitnessTest {

    private static CostExplorer costExplorer;

    @BeforeAll
    static void setUpAll() {
        costExplorer = CloudProvider.AMAZON_AWS.getCostExplorer();
    }

    @Test
    void checkTheTotalCosts() {
        ValueWithUnit sum = costExplorer.during(YESTERDAY).getCosts().sum();
        assertTrue(sum.lessThan(42.0));
    }

    @ParameterizedTest
    @MethodSource("serviceNameFactory")
    void checkTheCostsOfElasticComputeInstance(String service) {
        ValueWithUnit sum = costExplorer.during(LAST_7_DAYS).forService(service).getCosts().sum();
        assertTrue(sum.lessThan(250.0));
    }

    static List<String> serviceNameFactory() {
        return costExplorer.forService("Amazon Elastic *").getNames();
    }
}

For the complete example have a look at CloudCostFitnessTest.java found under src/test/java/.

Maintainer

License

This software is provided under the Apache v2 open source license, read the LICENSE file for details.

de.qaware.cloud.cost

QAware GmbH

QAware ist ein Projekthaus für Softwaretechnik. Wir analysieren, renovieren, erfinden und realisieren Softwaresysteme für Kunden, deren Erfolg von IT abhängt.

Versions

Version
1.0.1