Search in sources :

Example 56 with Status

use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project yakc by manusa.

the class CustomResourceV1IT method deleteNamespacedMountain.

@Test
@DisplayName("deleteNamespacedMountain, should delete existing Mountain")
void deleteNamespacedMountain() throws IOException {
    // When
    final Status result = KC.create(MountainsV1Api.class).deleteNamespacedMountain(mountainName, NAMESPACE).get();
    // Then
    assertThat(result).isNotNull().hasFieldOrPropertyWithValue("status", "Success");
}
Also used : Status(com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status) CustomResourceDefinitionV1IT.deleteCustomResourceDefinitionForTest(com.marcnuri.yakc.CustomResourceDefinitionV1IT.deleteCustomResourceDefinitionForTest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 57 with Status

use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project yakc by manusa.

the class EventsV1ApiIT method deleteNamespacedEvent.

@Test
@DisplayName("deleteNamespacedEvent, should delete existing Event")
void deleteNamespacedEvent() throws IOException {
    // When
    final Status result = deleteEventForTest();
    // Then
    assertThat(result).isNotNull().extracting(Status::getStatus).isEqualTo("Success");
}
Also used : Status(com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 58 with Status

use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project yakc by manusa.

the class SecretIT method deleteNamespacedSecret.

@Test
@DisplayName("deleteNamespacedSecret, should delete existing Secret")
void deleteNamespacedSecret() throws IOException {
    // When
    final Status result = KC.create(CoreV1Api.class).deleteNamespacedSecret(secretName, NAMESPACE, DeleteOptions.builder().gracePeriodSeconds(1).build()).get();
    // Then
    assertThat(result).isNotNull().extracting(Status::getStatus).isEqualTo("Success");
}
Also used : Status(com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 59 with Status

use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project koronavilkku-backend by THLfi.

the class DiagnosisKeyControllerDemoIT method assertStatus.

private void assertStatus(BatchId previous, List<BatchId> expected, boolean v2) throws Exception {
    String statusUrl = v2 ? STATUS_URL_V2 : STATUS_URL;
    Status status = new Status(expected, Optional.of(configService.getLatestAppConfig()), Optional.of(configService.getLatestExposureConfig()), Optional.of(configService.getLatestV2ExposureConfig()));
    mockMvc.perform(get(statusUrl + previous)).andExpect(status().isOk()).andExpect(header().exists("Cache-Control")).andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(content().json(mapper.writeValueAsString(status)));
}
Also used : Status(fi.thl.covid19.exposurenotification.diagnosiskey.v1.Status) Matchers.containsString(org.hamcrest.Matchers.containsString)

Example 60 with Status

use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project atlas by lorenzleutgeb.

the class Run method run.

@Override
public void run() {
    final var start = Instant.now();
    Loader loader = Loader.atDefaultHome();
    /*
    try {
      loader.autoload();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }*/
    Program program;
    try {
        program = loader.load(fqns);
    // program = loader.loadMatching(pattern);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    if (name != null && !name.isBlank()) {
        program.setName(name);
    }
    if (program.isEmpty()) {
        System.out.println("Program to analyze is empty, nothing to do!");
        System.exit(3);
    }
    program.normalize();
    if (!program.infer()) {
        return;
    }
    program.unshare(true);
    program.analyzeSizes();
    // log.info("Loaded definitions:");
    // program.printAllSimpleSignaturesInOrder(System.out);
    System.out.println("Output Directory: " + program.getBasePath().toAbsolutePath());
    System.out.println();
    Map<String, Path> tacticsMap = new HashMap<>();
    // log.info(infer ? "Given for comparison:" : "Will check following types:");
    log.info("Manual tactics disabled. All tactics will be automatically generated.");
    System.out.println("Function Definitions:");
    for (int i = 0; i < program.getOrder().size(); i++) {
        final var stratum = program.getOrder().get(i);
        for (var fqn : stratum) {
            FunctionDefinition fd = program.getFunctionDefinitions().get(fqn);
            if (tactics != null) {
                var path = tactics.resolve(fd.getModuleName().replace(".", "/") + "/" + fd.getName() + ".txt");
                if (Files.exists(path) && Files.isReadable(path)) {
                    tacticsMap.put(fd.getFullyQualifiedName(), path);
                }
            }
            System.out.println(fd.getAnnotatedSignatureString());
            // log.info("\tDependencies: " + fd.getOcurringFunctionsNonRecursive());
            System.out.println("\tSource:       " + fd.getBody().getSource().getRoot());
            System.out.println("\tBound:        " + fd.getAnnotatedSignature().getAnnotation().map(a -> a.getBounds(fd.treeLikeArguments().stream().map(IdentifierExpression::getName).toList())).orElse("?"));
            if (tactics != null) {
                final var p = tacticsMap.get(fd.getFullyQualifiedName());
                if (p == null) {
                    System.out.println("\tTactic:       n/a (will be automatically generated)");
                } else {
                    System.out.println("\tTactic:       " + p.toAbsolutePath());
                }
            }
        }
    }
    System.out.println();
    System.setProperty(Util.getPropertyName(Prover.class, "tickAst"), useTickAst.toString());
    final var result = program.solve(new HashMap<>(), tacticsMap, infer, consistentModules, equalRanks, simpleAnnotations, !infer, Collections.emptySet());
    final var stop = Instant.now();
    System.out.println("Elapsed Walltime: " + Duration.between(start, stop));
    System.out.println();
    if (Status.UNSATISFIABLE.equals(result.getStatus())) {
        System.out.println("UNSAT");
        System.exit(1);
    } else if (Status.UNKNOWN.equals(result.getStatus())) {
        System.out.println("UNKNOWN");
        System.exit(2);
    } else if (Status.SATISFIABLE.equals(result.getStatus())) {
        if (!infer) {
            System.out.println("SAT");
            System.out.println();
        } else {
            System.out.println("Results:");
            program.printAllInferredAnnotationsAndBoundsInOrder(System.out);
            System.out.println();
        }
    } else {
        throw new RuntimeException("encountered unknown status");
    }
    /*
    if (json != null) {
      JsonObjectBuilder builder = Json.createObjectBuilder();

      builder.add("result", program.inferredSignaturesToJson());
      builder.add("duration", Json.createValue(Duration.between(start, stop).toString()));

      JsonObjectBuilder z3ObjectBuilder = Json.createObjectBuilder();
      z3ObjectBuilder.add("status", Json.createValue(result.getStatus().toString()));

      JsonObjectBuilder z3StatisticsBuilder = Json.createObjectBuilder();
      result.getStatistics().forEach(z3StatisticsBuilder::add);
      z3ObjectBuilder.add("statistics", z3StatisticsBuilder.build());

      if (result.getSmtFile().isPresent()) {
        z3ObjectBuilder.add("file", Json.createValue(result.getSmtFile().get().toString()));
      }

      builder.add("z3", z3ObjectBuilder.build());

      log.info("Writing JSON output to {}", json);
      try (final var out = output(json)) {
        Json.createWriter(out).writeObject(builder.build());
      } catch (IOException ioException) {
        log.error("Failed to write JSON output.", ioException);
      }
    }
     */
    // System.exit(result.toExitCode());
    System.exit(0);
}
Also used : Path(java.nio.file.Path) Program(xyz.leutgeb.lorenz.atlas.ast.Program) Files(java.nio.file.Files) FunctionDefinition(xyz.leutgeb.lorenz.atlas.ast.FunctionDefinition) Loader(xyz.leutgeb.lorenz.atlas.module.Loader) Util(xyz.leutgeb.lorenz.atlas.util.Util) Set(java.util.Set) IOException(java.io.IOException) HashMap(java.util.HashMap) Instant(java.time.Instant) IdentifierExpression(xyz.leutgeb.lorenz.atlas.ast.expressions.IdentifierExpression) Slf4j(lombok.extern.slf4j.Slf4j) Prover(xyz.leutgeb.lorenz.atlas.typing.resources.proving.Prover) Duration(java.time.Duration) Map(java.util.Map) Status(com.microsoft.z3.Status) Path(java.nio.file.Path) Collections(java.util.Collections) CommandLine(picocli.CommandLine) Program(xyz.leutgeb.lorenz.atlas.ast.Program) HashMap(java.util.HashMap) Prover(xyz.leutgeb.lorenz.atlas.typing.resources.proving.Prover) Loader(xyz.leutgeb.lorenz.atlas.module.Loader) IOException(java.io.IOException) IdentifierExpression(xyz.leutgeb.lorenz.atlas.ast.expressions.IdentifierExpression) FunctionDefinition(xyz.leutgeb.lorenz.atlas.ast.FunctionDefinition)

Aggregations

Status (com.microsoft.z3.Status)63 BoolExpr (com.microsoft.z3.BoolExpr)55 Test (org.junit.Test)49 Test (org.junit.jupiter.api.Test)17 Expr (com.microsoft.z3.Expr)10 IOException (java.io.IOException)10 JsonMapper.convertObjectToJsonString (com.arbindo.mimock.helpers.general.JsonMapper.convertObjectToJsonString)9 RandomDataGenerator.generateRandomAlphabeticString (com.arbindo.mimock.helpers.general.RandomDataGenerator.generateRandomAlphabeticString)9 Status (com.arbindo.mimock.manage.mimocks.models.v1.Status)9 Context (com.microsoft.z3.Context)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)9 Pageable (org.springframework.data.domain.Pageable)9 HttpStatus (org.springframework.http.HttpStatus)9 MvcResult (org.springframework.test.web.servlet.MvcResult)9 Mock (com.arbindo.mimock.entities.Mock)8 List (java.util.List)7 Solver (com.microsoft.z3.Solver)6 PageImpl (org.springframework.data.domain.PageImpl)6