Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recover #77

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
46 changes: 46 additions & 0 deletions shopping-cart-v2/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
pipeline {
agent { node { label 'maven' } }
environment { APP_NAMESPACE = 'ebomqy-recover' }
stages {
stage('Test') {
//options { timeout(time: 50, unit: 'SECONDS') }
steps {
dir('shopping-cart-v2') {
sh './mvnw clean test'
}
}
}
stage('Build Image') {
environment { QUAY = credentials('QUAY_USER') }
steps {
dir('shopping-cart-v2') {
sh './scripts/include-container-extensions.sh'
sh '''
./scripts/build-and-push-image.sh \
-u $QUAY_USR \
-p $QUAY_PSW \
-b $BUILD_NUMBER
'''
}
}
}
stage('Deploy') {
environment { QUAY = credentials('QUAY_USER') }
steps {
dir('shopping-cart-v2') {
script {
def status = sh(
script: "./scripts/tag-exists-in-quay.sh $QUAY_USR/do400-recover latest",
returnStatus: true
)
if (status != 0) {
error("Tag not found in Quay!")
}
}
sh './scripts/redeploy.sh $APP_NAMESPACE'
}
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
@QuarkusTest
@Tag("integration")
public class ShoppingCartTest {

@BeforeAll
public static void setup() {
CatalogStorage mockStorage = Mockito.mock(InMemoryCatalogStorage.class);

Mockito.when(mockStorage.containsKey(1)).thenReturn(true);
Mockito.when(mockStorage.containsKey(2)).thenReturn(true);
Mockito.when(mockStorage.containsKey(9999)).thenReturn(false);

Mockito.when(mockStorage.get(1)).thenReturn(new Product(1, 100));
Mockito.when(mockStorage.get(2)).thenReturn(new Product(2, 200));

QuarkusMock.installMockForType(mockStorage, CatalogStorage.class);
}

private int randomQuantity() {
return (new Random()).nextInt(10) + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ public class ShoppingCartTest {

@Inject
CartService cartService;

@BeforeAll
public static void setup() {
CatalogStorage mockStorage = Mockito.mock(InMemoryCatalogStorage.class);

Mockito.when(mockStorage.containsKey(1)).thenReturn(true);
Mockito.when(mockStorage.containsKey(9999)).thenReturn(false);

Mockito.when(mockStorage.get(1)).thenReturn(new Product(1, 100));

QuarkusMock.installMockForType(mockStorage, CatalogStorage.class);
}

@BeforeEach
void clearCart() {
Expand Down